代码点火器:创建一个重试按钮并调用相同的函数


Codeigniter: Create a retry button and call the same function?

我遇到了一个问题,当发送数据失败而不是转到主页并再次发送数据时,请在函数中调用相同的函数。我将在下面发布我的代码:

法典:

function send_order($order,$wcustid,$customer_address_id) { // function to call
    $this->load->model("order_product_m");
    $msg='';    
    $order_ref = $order[0]->order_no;
    $payment_method='payment';
    $currency='currency';
    $currency_rate='1.00';
    //get shippingn method 
     $shipping=$this->order_m->getShippingMethod($order[0]->shipping_id);
    $ship_method = 'Delivered';
    $ship_amount = $shipping[0]->amount;
     $addOrderHeaderToWarehouse = $this->BLWP_CreateOrderHeader($wcustid, $customer_address_id, $order_ref, $ship_method,$ship_amount,$payment_method, $currency, $currency_rate);
$status_ord_header = explode("=", $addOrderHeaderToWarehouse[1]);
if(strpos($addOrderHeaderToWarehouse[1], 'OK')== true) {
$ord = explode("=", $addOrderHeaderToWarehouse[3]);
 $warehouseOredrId=$ord[1];
 $w_ordid=(int)$warehouseOredrId;
$this->order_m->addWwarehouseorder($order[0]->id,$warehouseOredrId); //update order with warehouse id
//update table orders with warehouse order id
//SAVE WAREHOUSE ORDER ID FOR CRM ORDERS
        $order_products=$this->order_m->getOrderProducts($order[0]->id);
    $orderlineitem=0;
        foreach($order_products as $order_product) {

            //get warehouse order id from local db
            $w_ord_id=$this->order_m->getwarehouseOrderId($order_product->order_id);

            $prod=$this->product_m->getProductCode($order_product->product_id);
            $product_code = $prod[0]->product_code;
            $addorderproduct = $this->BLWP_CreateOrderLine($w_ord_id[0]->warehouse_order_id, $product_code, $order_product->quantity, $order_product->sales_price,'');
            if(strpos($addorderproduct[1], 'OK')== true) {
            $ordline = explode("=", $addorderproduct[3]);
            $w_order_line_id=$ordline[1];
            //add order line id for each product in the table order product
            $this->order_product_m->update_order_line_id($order_product->order_id,$order_product->product_id,$w_order_line_id);
            $orderlineitem=1;
            }
            else $msg="Order line item not created";
        }
        //Process order================================
        if($orderlineitem==1) {
    $process_ord_response = $this->BLWP_ProcessOrder($w_ordid);     
    $process_order = explode("=", $process_ord_response[3]);
    $w_ord_status= $process_order[1];
    $this->order_m->addWarehouseorderStatus($order[0]->id,$w_ord_status); //update order with warehouse id/
    }
    else $msg.="<br>Order not processed";
    //============================================
    $msg.=" Order sent to warehouse";
}
else 
    $msg="Order could not be sent to warehouse";
    //want to create the retry button here.
return $msg;
}

我想调用下面的send_order函数$msg= Order could not be sent to warehouse

如果要调用成员函数,请使用$this

function send_order($order,$wcustid,$customer_address_id) { // function to call
    $this->load->model("order_product_m");
    $msg='';    
    $order_ref = $order[0]->order_no;
    $payment_method='payment';
    $currency='currency';
    $currency_rate='1.00';
    //get shippingn method 
     $shipping=$this->order_m->getShippingMethod($order[0]->shipping_id);
    $ship_method = 'Delivered';
    $ship_amount = $shipping[0]->amount;
     $addOrderHeaderToWarehouse = $this->BLWP_CreateOrderHeader($wcustid, $customer_address_id, $order_ref, $ship_method,$ship_amount,$payment_method, $currency, $currency_rate);
$status_ord_header = explode("=", $addOrderHeaderToWarehouse[1]);
if(strpos($addOrderHeaderToWarehouse[1], 'OK')== true) {
$ord = explode("=", $addOrderHeaderToWarehouse[3]);
 $warehouseOredrId=$ord[1];
 $w_ordid=(int)$warehouseOredrId;
$this->order_m->addWwarehouseorder($order[0]->id,$warehouseOredrId); //update order with warehouse id
//update table orders with warehouse order id
//SAVE WAREHOUSE ORDER ID FOR CRM ORDERS
        $order_products=$this->order_m->getOrderProducts($order[0]->id);
    $orderlineitem=0;
        foreach($order_products as $order_product) {

            //get warehouse order id from local db
            $w_ord_id=$this->order_m->getwarehouseOrderId($order_product->order_id);

            $prod=$this->product_m->getProductCode($order_product->product_id);
            $product_code = $prod[0]->product_code;
            $addorderproduct = $this->BLWP_CreateOrderLine($w_ord_id[0]->warehouse_order_id, $product_code, $order_product->quantity, $order_product->sales_price,'');
            if(strpos($addorderproduct[1], 'OK')== true) {
            $ordline = explode("=", $addorderproduct[3]);
            $w_order_line_id=$ordline[1];
            //add order line id for each product in the table order product
            $this->order_product_m->update_order_line_id($order_product->order_id,$order_product->product_id,$w_order_line_id);
            $orderlineitem=1;
            }
            else $msg="Order line item not created";
        }
        //Process order================================
        if($orderlineitem==1) {
    $process_ord_response = $this->BLWP_ProcessOrder($w_ordid);     
    $process_order = explode("=", $process_ord_response[3]);
    $w_ord_status= $process_order[1];
    $this->order_m->addWarehouseorderStatus($order[0]->id,$w_ord_status); //update order with warehouse id/
    }
    else $msg.="<br>Order not processed";
    //============================================
    $msg.=" Order sent to warehouse";
}
else 
{
    $msg="Order could not be sent to warehouse";
$this->send_order($order,$wcustid,$customer_address_id);
    //want to create the retry button here.
}
return $msg;
}