当前位置: 首页>>代码示例>>PHP>>正文


PHP Shipment::bulkOrder方法代码示例

本文整理汇总了PHP中Shipment::bulkOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP Shipment::bulkOrder方法的具体用法?PHP Shipment::bulkOrder怎么用?PHP Shipment::bulkOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shipment的用法示例。


在下文中一共展示了Shipment::bulkOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionBulkentry

 public function actionBulkentry()
 {
     if (!$this->token instanceof Token) {
         echo CJSON::encode($this->statusError('You have to login first'));
         Yii::app()->end();
     }
     ini_set('max_execution_time', 300);
     $model = new FOrderDataEntry();
     if (isset($_FILES['FOrderDataEntry'])) {
         $model->attributes = $_FILES['FOrderDataEntry'];
         $model->setScenario('api');
         if ($model->validate(array('file'))) {
             $model->setScenario('insert');
             $customer = Customer::model()->findByPk($this->token->customer_id);
             $contact = $customer->getContactData();
             $csvFile = CUploadedFile::getInstance($model, 'file');
             $tempLoc = $csvFile->getTempName();
             $rawdatas = file($tempLoc);
             $city_routing = IntraCityRouting::model()->findByAttributes(array('postcode' => $contact->postal));
             if ($city_routing instanceof IntraCityRouting) {
                 $routing_code = $city_routing->code;
             } else {
                 $routing_code = '';
             }
             try {
                 $trans = Yii::app()->db->beginTransaction();
                 $bulk = Shipment::bulkOrder($rawdatas, $customer, $contact, $routing_code);
                 $list_failed = implode(', ', $bulk['failed']);
                 $list_success = implode(', ', $bulk['success']);
                 echo CJSON::encode($this->statusSuccess(array('failed' => $list_failed, 'success' => $list_success)));
                 Yii::app()->end();
                 $trans->commit();
             } catch (ServiceControllerException $e) {
                 CVarDumper::dump($e, 10, TRUE);
                 exit;
                 $trans->rollBack();
             }
         } else {
             echo CJSON::encode($this->statusError($model->getErrors()));
             Yii::app()->end();
         }
     } else {
         echo CJSON::encode($this->statusError('The File is not exixst'));
         yii::app()->end();
     }
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:46,代码来源:ServiceController.php

示例2: actionEntryBulkOrder

 public function actionEntryBulkOrder()
 {
     ini_set('max_execution_time', 300);
     $this->layout = '//layouts/column2';
     $model = new FOrderDataEntry();
     if (isset($_POST['FOrderDataEntry'])) {
         $model->attributes = $_POST['FOrderDataEntry'];
         if ($model->validate()) {
             $customer = Customer::model()->findByAttributes(array('accountnr' => $model->customer_account));
             $contact = $customer->getContactData();
             $csvFile = CUploadedFile::getInstance($model, 'file');
             $tempLoc = $csvFile->getTempName();
             $rawdatas = file_get_contents($tempLoc);
             $rawdatas = trim($rawdatas);
             $data = explode("\r", $rawdatas);
             $data = count($data) != 1 ? $data : explode("\n", $rawdatas);
             $city_routing = IntraCityRouting::model()->findByAttributes(array('postcode' => $contact->postal));
             if ($city_routing instanceof IntraCityRouting) {
                 $routing_code = $city_routing->code;
             } else {
                 $routing_code = '';
             }
             try {
                 $trans = Yii::app()->db->beginTransaction();
                 $bulk = Shipment::bulkOrder($data, $customer, $contact, $routing_code);
                 if (count($bulk['failed']) != 0) {
                     $counter = array();
                     foreach ($bulk['failed'] as $key => $val) {
                         array_push($counter, $val['counter']);
                     }
                     $list_failed = implode(', ', $counter);
                     Yii::app()->user->setFlash('error', 'Failed at line : ' . $list_failed);
                 } else {
                     Yii::app()->user->setFlash('success', 'Success importing all datas');
                 }
                 $trans->commit();
             } catch (Exception $e) {
                 CVarDumper::dump($e, 10, TRUE);
                 exit;
                 $trans->rollBack();
             }
         }
     }
     $this->render("importDataEntry", array('model' => $model));
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:45,代码来源:ShipmentController.php


注:本文中的Shipment::bulkOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。