Example #1
0
                 db_query('UPDATE ?:rus_sdek_call_recipient SET ?u WHERE order_id = ?i AND shipment_id =?i ', $call_recipient, $params['order_id'], $shipment_id);
             } else {
                 db_query('INSERT INTO ?:rus_sdek_call_recipient ?e', $call_recipient);
             }
             fn_sdek_get_ticket_order($data_auth, $params['order_id'], $shipment_id);
         }
         $date_status = RusSdek::orderStatusXml($data_auth, $params['order_id'], $shipment_id);
         RusSdek::addStatusOrders($date_status);
     }
 } elseif ($mode == 'sdek_call_courier') {
     foreach ($params['add_sdek_info'] as $shipment_id => $sdek_info) {
         if (!empty($sdek_info['CallCourier']['Date']) && !empty($sdek_info['CallCourier']['TimeBeg']) && !empty($sdek_info['CallCourier']['TimeEnd'])) {
             list($_shipments) = fn_get_shipments_info(array('order_id' => $params['order_id'], 'advanced_info' => true, 'shipment_id' => $shipment_id));
             $shipment = reset($_shipments);
             $params_shipping = array('shipping_id' => $shipment['shipping_id'], 'Date' => date("Y-m-d", $shipment['shipment_timestamp']));
             $data_auth = RusSdek::dataAuth($params_shipping);
             if (empty($data_auth)) {
                 continue;
             }
             $total_weight = db_get_field("SELECT SUM(weight) FROM ?:rus_sdek_products WHERE order_id = ?i AND shipment_id = ?i", $params['order_id'], $shipment_id);
             if (!empty($total_weight) && $total_weight != 0) {
                 $total_weight = $total_weight;
             } else {
                 $total_weight = 0.01;
             }
             $sdek_info['CallCourier'] = array_diff($sdek_info['CallCourier'], array('', '0.00'));
             unset($data_auth['Number']);
             $data_auth['CallCount'] = "1";
             $xml = RusSdek::arraySimpleXml('CallCourier', $data_auth, 'open');
             $sdek_info['CallCourier']['Date'] = date("Y-m-d", strtotime($sdek_info['CallCourier']['Date']));
             $sdek_info['CallCourier']['SendCityCode'] = $sdek_info['Order']['SendCityCode'];