无法添加作业Cakephp 2.6

时间:2019-04-14 07:04:55

标签: php cakephp cakephp-2.6

到上周,该系统在过去9年中运行良好,开始显示无法添加作业的错误。

this is the error which I'm getting in my system

这是控制器和视图中的代码

查看

 <?php $currentid=null;?>
<script type="text/javascript">
    var currentid = -1;
    var insiderow = 1;
    $(document).ready(function() {
    $('#TicketJobDate').datepicker({dateFormat:'yy-mm-dd'}); 
    $('#TicketJobDueDate').datepicker({dateFormat:'yy-mm-dd'});
    $('#TicketJobDueDate').focus(function() {
    $('#TicketJobDueDate').blur();
    });
    });
    /*function sum() {
            var n1 = document.getElementById('fare').value;
            var n2 = document.getElementById('tax').value;
            var n3 = document.getElementById('commission2').value;
            var result = (parseFloat(n1) * parseFloat(n3)) + parseFloat(n2);
            if (!isNaN(result)) {
                document.getElementById('cost_price').value = result;
            }
        }*/
    function sum1(){
        var commval =0;
        var fare = document.getElementById('fare').value;
        var tax = document.getElementById('tax').value;
        var result = 0;
        commval = document.getElementById('commission1').value;
        commnet = parseInt(fare) * parseInt(commval) / 100;
        result = parseInt(fare) - commnet + parseInt(tax);
        if (!isNaN(commnet)) {
                document.getElementById('commission2').value = commnet;
                document.getElementById('cost_price').value = result;
            }
    }
</script>
<?php
    echo $this->form->create('TicketJob', array('type' => 'file', 'enctype' => 'multipart/form-data'));
    $options = array('Galileo' => 'Galileo', 'Travel Agency' => 'Travel Agency', 'Airlines' => 'Airlines', 'Sabre' => 'Sabre');
    echo "<div class='form-element-groupnew'>";
    echo "<h1>Add Ticketing</h1>";
    echo $this->form->input('date', array('type'=>'text'));
    echo $this->form->input('lpo');
    //echo $this->form->input('invoice_number', array('type'=>'text', 'value' => 0));
    echo $this->form->input('passenger');
    echo $this->form->input('route');
    echo $this->form->input('airline_code');
    echo $this->form->input('ticket_number'); 
    echo '</div>';
    echo "<div class='form-element-groupnew'>"; ?>
    <span style="font-size: 10px;">Fare</span>
    <input type="text" name="fare" id="fare" />
    <span style="font-size: 10px;">Tax</span><input type="text" id="tax" name="tax"/>
    <span style="font-size: 10px;">Comm(%)</span> <input type="text" name="commission1" id="commission1" onkeyup="sum1();" />
    <span style="font-size: 10px;">Comm</span> <input type="text" name="commission2" id="commission2"/>
    <span style="font-size: 10px;">Cost Price</span> <input type="text" name="cost_price" id="cost_price"/>
    <?php echo '</div>';
    echo "<div class='form-element-groupnew'>"; 
    echo $this->form->input('selling_price', array('type'=>'text'));
    echo $this->form->input('contact', array('type'=>'text', 'class' => 'popup-field3'));
    echo $this->form->input('contact_id', array('type'=>'hidden'));
    echo $this->form->input('officer_id');
    echo $this->form->input('system', array('type' => 'select','options' => $options));
    echo $this->form->input('remarks');
    echo $this->form->end('Add Ticket Jobs');
    echo "</div>"; ?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#popup-listing3").jqGrid(
    /* '#list' is the ID of the table in which you want populated results */
    {
        url:'<?php echo $this->Html->url(array("controller" => "contacts", "action" => "index_grid")); ?>',
        datatype: "json",
        mtype: "GET",
        colNames:['ID','Full Name','Services','responsible_person','Phone','Mobile','Fax','Address','City','Country','Email Address 1'],
        colModel:[
            //{name: 'myac', width:80, fixed:true, sortable:false, resize:false, formatter:'actions', formatoptions:{keys:true}},
            {name:'id',index:'id', width:20},
            {name:'full_name',index:'full_name', width:250, editable:true},
            {name:'Service.title',index:'Service.title', width:50, search:true},
        {name:'responsible_person',index:'responsible_person', width:75, editable:true},
            {name:'phone',index:'phone', width:75, editable:true},
            {name:'mobile',index:'mobile', width:75, editable:true},
            {name:'fax',index:'fax', width:75, editable:true},
            //{name:'type_id',index:'type_id',width:100, editable:true,edittype:'select',formatter:'select',stype:'select',editoptions:{ value:"1:Company - Supplier;2:Company - Customer;3:Individual"}},
            //{name:'ContactType.title',index:'ContactType.title', width:100, editable:true,edittype:'select',formatter:'select',stype:'select',editoptions:{sopt:['eq'],value:categoriesStr}},
            //{name:'ContactType.title',index:'ContactType.title', width:100, editable:true,edittype:'select',formatter:'select',stype:'select',editoptions:{ value:"Company - Supplier:Company - Supplier;Company - Customer:Company - Customer;Individual:Individual"}},
            {name:'address',index:'address', width:150, editable:true},
            {name:'city',index:'city', width:50, editable:true},
            {name:'country',index:'country', width:50, editable:true},
            {name:'email_address1',index:'email_address1', width:200, editable:true}


        ],
        rowNum:10,
        rowList:[10,20,30],
        pager: '#popup-pager3', /* id of the pagination element */
        sortname: 'id',
        viewrecords: true,
        sortorder: "asc",
        caption:"Select the Customer",
        height:"auto",
        toolbarfilter:true,
        autowidth: true,

        //multiselect: true,
        /*beforeSelectRow: function (id) {
            alert("Button: "+id + " is clicked");

            },*/
        editurl: '<?php echo $this->Html->url(array("controller" => "contacts", "action" => "edit")); ?>',

        onSelectRow: function(id){
            var row = jQuery("#popup-listing3").getRowData(id);
            var name = row['full_name'];
            jQuery('#TicketJobContact').val(name);
            jQuery('#TicketJobContactId').val(id);
            jQuery('#popup-box3').fadeOut("slow");
            jQuery("#wrap").css({   
                    "opacity": "1"
            });

        }

    });
    jQuery("#popup-listing3").jqGrid('navGrid','#popup-pager3',
    {edit:false,add:true,del:false,search:false}
    );

    jQuery("#popup-listing3").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true,
        defaultSearch: 'cn', ignoreCase: true});

});
</script>   
<div id="popup-pager3" style="height: 80px;"></div>

我已经和我的假人一起检查了编码是否也很好

控制器

public function add(){
            $this->layout = 'popup-search';
            //$ids = $this->TicketJob->find('list', array('fields' => 'TicketJob.id'),array('order'=>array('TicketJob.id'=>'desc')));
            $ids = $this->TicketJob->find('first', array('fields' => array('id','invoice_number'), 'order' => 'id DESC'));       
            $PrevId = $ids['TicketJob']['id'];
            $invoice = $ids['TicketJob']['invoice_number'];

            if ($invoice > 0) {
            $invoice = $invoice + 1;

            if(!empty($this->request->data))
                {            
                $this->request->data['TicketJob']['created_by'] = $this->Auth->user('id');
                $this->TicketJob->create();

                $this->request->data['TicketJob']['fare'] = $this->data['fare'];
                $this->request->data['TicketJob']['tax'] = $this->data['tax'];
                $this->request->data['TicketJob']['commission'] = $this->data['commission2'];
                $this->request->data['TicketJob']['cost_price'] = $this->data['cost_price'];
                if ($this->TicketJob->save($this->request->data)) {

                $LastInsertId = $this->TicketJob->getLastInsertID();
                $this->TicketJob->updateAll(array('invoice_number' => $invoice), array('TicketJob.id' => $LastInsertId));

                $this->Session->setFlash('New Ticket Job has been created.');
                $this->redirect(array('action' => 'index'));
                }else {
                $this->Session->setFlash('Unable to create new Ticket Job.');
                }
                }
            } else {
                $this->Session->setFlash('Unable to create new Ticket Job.');
                $this->redirect(array('action' => 'index'));
            }
                $officers = $this->getUsersByRole(9);
                //$customers  = $this->TicketJob->Customer->find('all');
                //$statuses = $this->TicketJob->Status->find('list');
                $this->set(compact('officers','customers'));
                //$contacts = $this->TicketJob->Customer->find('list');
                //$this->Model->find('all',array('fields'=>array('Model.fieldName')))
        }

这是我的票务索引

<?php
$roleid = $this->Session->read('Auth.User.role_id');
$uid = $this->Session->read('Auth.User.id');
//print $roleid;
?>
<h1>List of Ticket Jobs</h1>
<script type="text/javascript">
jQuery(document).ready(function(){
var rowsToColor = [];
    jQuery("#list").jqGrid(
    /* '#list' is the ID of the table in which you want populated results */
    {
        url:'<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "index_grid")); ?>',
        datatype: "json",
        mtype: "GET",
        colNames:['ID', 'Date', 'LPO','Invoice Number','Passenger','Route','Air-Code','Ticket Number','Price','System','Contact','Operator','Officer','Status','Actions'],
        colModel:[
            {name:'TicketJob.id',index:'TicketJob.id', width:5, search:true},
            {name:'TicketJob.date',index:'TicketJob.date', width:10, align:'left', search:true,editable:true, edittype:'text'},
            {name:'lpo',index:'lpo', width:10, align:'left', search:true,editable:true, edittype:'text'},
            {name:'invoice_number',index:'invoice_number', width:10, search:true, editable:true, edittype:'text'},
            {name:'passenger',index:'passenger', search:true, align:'center', width:18, sortable:true, editable:true, edittype:'text'},
            {name:'route',index:'route', width:10, search:true, editable:true, edittype:'text'},
            {name:'airline_code',index:'airline_code', width:5, search:true, editable:true, edittype:'text'},
            {name:'ticket_number',index:'ticket_number', width:10, search: true, editable:true, edittype:'text'},
            {name:'selling_price',index:'selling_price', width:10, search:true, editable:true, edittype:'text'},
            //{name:'TicketPayment.amount',index:'TicketPayment.amount', width:10, search:true, editable:true, edittype:'text'},
            {name:'system',index:'system', width:10, search:true, editable:true, edittype:'text'},
           // {name:'TicketPayment.amount',index:'TicketPayment.amount', width:10, search:true, editable:true, edittype:'text'},
           // {name:'TicketRefund.refund_to_customer',index:'TicketRefund.refund_to_customer', width:10, search:true, editable:true, edittype:'text'},
           // {name:'TicketRefund.remarks',index:'TicketRefund.remarks', width:10, search:true, editable:true, edittype:'text'},
            {name:'Contact.full_name',index:'Contact.full_name', width:10, search:true, editable:true, edittype:'text'},
            {name:'Author.username',index:'Author.username', width:10, search:true, editable:true, edittype:'text'},
            {name:'Officer.username',index:'Officer.username', width:10, search:true, editable:true, edittype:'text'},
            {name:'Status.title',index:'Status.title', width:10, search:true, editable:true, edittype:'text', formatter: rowColorFormatter},
            {name:'id',index:'id', search:true, width:20, sortable:false, formatter: actionLink}
        ],
        toppager: true,
        rowNum:100,
        rowList:[10,20,30],
        pager: '#pager', /* id of the pagination element */
        pgbuttons: true,  
        sortname: 'id',
        viewrecords: true,
        sortorder: "desc",
        caption:"Ticket Jobs",
        height:"auto",
        toolbarfilter:true,
        autowidth: true,
        gridComplete: function () {                   


                    for (var i = 0; i < rowsToColor.length; i++) {
                    var status = $("#" + rowsToColor[i]).find("td").eq(13).html();

                    if (status == "Amt-Pending") { 
                        $("#" + rowsToColor[i]).find("td").css("color", "#FF9900");
                    }else
                    if (status == "Amt-Received") { 
                        $("#" + rowsToColor[i]).find("td").css("color", "#FF0099");
                    } else
                    if (status == "Cancelled") { 
                        $("#" + rowsToColor[i]).find("td").css("color", "red");
                    } else {
                        $("#" + rowsToColor[i]).find("td").css("color", "#3366FF"); 
                    }

            }
        }

    });
    jQuery("#list").navGrid('#pager',{edit:false,add:false,del:false,search:false});

    jQuery("#list").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true,
        defaultSearch: 'cn', ignoreCase: true});
    <?php if($uid == 66 || $uid == 68) { ?>
    function actionLink(cellvalue, options, rowObject) {
        //return "<a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "edit")); ?>/" + options.rowId + "' >Edit</a> | <a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "view")); ?>/" + options.rowId + "' >View</a> | <a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "filter_list")); ?>/" + options.rowId + "' >Invoice</a>";
        //return "<a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "edit")); ?>/" + options.rowId + "' >Edit</a> | <a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "view")); ?>/" + options.rowId + "' >View</a> | <a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "invoice_pdf")); ?>/" + options.rowId + "' >Invoice</a>";
        return "<a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "edit")); ?>/" + options.rowId + "' >Edit</a> | <a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "view")); ?>/" + options.rowId + "' >View</a> | <a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "invoice_pdf1")); ?>/" + options.rowId + "' >Invoice</a>";
    }
    <?php } else { ?>
    function actionLink(cellvalue, options, rowObject) {
        return "<a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "view")); ?>/" + options.rowId + "' >View</a> | <a href='<?php echo $this->Html->url(array("controller" => "ticket_jobs", "action" => "invoice_pdf1")); ?>/" + options.rowId + "' >Invoice</a>";
    }
    <?php } ?>
    function rowColorFormatter(cellValue, options, rowObject) {
        if ((cellValue == "Amt-Pending") || (cellValue == "Amt-Received")) {
            rowsToColor[rowsToColor.length] = options.rowId;
        }
        return cellValue;
    }

});
</script>
<table id="list" style="height:auto;"></table>
<div id="pager" style="height: 80px;"></div>
<?php if($roleid !=14) {echo $this->html->link('Add Ticketing', array('controller' => 'ticket_jobs', 'action' => 'add')); } ?>

我也替换了代码,但仍然没有给出任何结果

1 个答案:

答案 0 :(得分:0)

在票务表上从MySQL删除了损坏的数据条目