本文整理匯總了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();
}
}
示例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));
}