Ejemplo n.º 1
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->setPropertiesDefine(array('customer_id' => array('options' => function (SampleProduceOrder $item = null) {
         if ($item && $item->customer_id) {
             $company_alias_name = Customer::findOneByPk($item->customer_id)->company_alias_name;
             return array($item->customer_id => $company_alias_name);
         }
         return null;
     }, 'alias' => '客户'), 'customer' => array('getter' => function (self $item) {
         if ($item) {
             return Customer::findOneByPk($item->customer_id);
         }
         return null;
     }), 'contact' => array('getter' => function (SampleProduceOrder $item) {
         if ($item->contact_id) {
             return CustomerContact::findOneByPk($item->contact_id);
         }
         return null;
     }), 'contact_id' => array('options' => function (SampleProduceOrder $item = null) {
         if ($item && $item->contact_id) {
             $contact_name = CustomerContact::findOneByPk($item->contact_id)->chinese_name;
             return array($item->contact_id => $contact_name);
         }
         return null;
     }, 'alias' => '联系人'), 'boss_head_employee_id' => array('options' => function () {
         $tmp = Employee::find('state=?', Employee::STATE_ENABLED)->all(true);
         return array_combine(array_column($tmp, 'id'), array_column($tmp, 'name'));
     }, 'display' => function (self $item) {
         $tmp = Employee::findOneByPk($item->boss_head_employee_id);
         if (!$tmp) {
             return '';
         }
         return $tmp->state == Employee::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>';
     }, 'alias' => '负责人'), 'produce_finish_date' => array('default' => date('Y-m-d')), 'currency_id' => array('options' => function () {
         $tmp = Currency::find()->all(true);
         return array_combine(array_column($tmp, 'id'), array_column($tmp, 'unit_name'));
     }, 'display' => function (self $item) {
         if ($item) {
             $tmp = Currency::find()->all(true);
             $tmp = array_group($tmp, 'id', true);
             return $tmp[$item->currency_id]['unit_name'];
         }
         return '';
     }), 'product_fee' => array('description' => 'RMB'), 'business_order' => array('getter' => function (self $item) {
         return BusinessOrder::findOneByPk($item->business_order_id);
     })));
 }
 /**
  * @param $get
  * @param $post
  * @return \Lite\Core\Result|void
  */
 public function update($get, $post)
 {
     $id = $get['id'];
     $business_order_id = $get['business_order_id'];
     $r = Result::convert(parent::update($get, $post));
     if ($post) {
         if ($r->isSuccess()) {
             if (!$id) {
                 $order = BusinessOrder::findOneByPk($business_order_id);
                 $order->setValue('state', BusinessOrder::STATE_CONFIRM);
                 $order->save();
             }
             $r->setJumpUrl($this->getBackUrl());
         }
     }
     return $r;
 }
Ejemplo n.º 3
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     parent::__construct($data);
     $this->setPropertiesDefine(array('append_file_url' => array('type' => 'file', 'rel' => 'upload-file'), 'business_order' => array('getter' => function (BusinessOrderPayment $item) {
         return BusinessOrder::findOneByPk($item->business_order_id);
     }), 'pay_type_id' => array('options' => function () {
         $tmp = PayType::find('state=?', PayType::STATE_ENABLED)->all(true);
         return array_combine(array_column($tmp, 'id'), array_column($tmp, 'name'));
     }, 'display' => function (self $item) {
         $tmp = PayType::findOneByPk($item->pay_type_id);
         if (!$tmp) {
             return '';
         }
         return $tmp->state == PayType::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>';
     })));
 }
Ejemplo n.º 4
0
 public function update($get, $post)
 {
     $order = SampleProduceOrder::findOneByPk($get['id']) ?: new SampleProduceOrder();
     if ($post) {
         if ($post['produce_type'] == SampleProduceOrder::TYPE_ORDER) {
             if ($post['business_order_no']) {
                 $post['business_order_id'] = BusinessOrder::find('order_no=?', $post['business_order_no'])->ceil('id');
             }
             if (!$post['business_order_id']) {
                 return new Result('您输入的订单号没有对应的订单:' . $post['business_order_no']);
             }
         }
         $org_id = $order->boss_head_employee_id;
         $order->setValues($post);
         if (!$order->id) {
             $order->boss_head_employee_id = Auth::instance()->getLoginUserId();
         } else {
             $order->boss_head_employee_id = $org_id;
         }
         $result = parent::update($get, $post);
         if ($result->isSuccess()) {
             return new Result('操作成功', true);
         }
     }
     $customer_list = Customer::find()->all();
     $current_contact_list = array();
     if ($order->id) {
         $current_contact_list = CustomerContact::find('customer_id =?', $order->contact->customer_id)->all();
     }
     $all_contact_list = CustomerContact::find()->all(true);
     $all_contact_list = array_group($all_contact_list, 'customer_id');
     return array('order' => $order, 'customer_list' => $customer_list, 'all_contact_list' => $all_contact_list, 'current_contact_list' => $current_contact_list);
 }
Ejemplo n.º 5
0
 /**
  * 添加订单的样品
  * @param $get
  * @param $post
  * @return array
  */
 public function addSample($get, $post)
 {
     $order_id = $get['id'];
     $order = BusinessOrder::findOneByPk($order_id);
     if ($post) {
         $order_sample = BusinessOrderSamples::find('id=? AND sample_id = ?', $order_id, $post['sample_id'])->count();
         if ($order_sample) {
             return new Result('已经添加了相同包装相同货号的样品');
         }
         $p = new BusinessOrderSamples($post);
         $p->save();
         return $this->getCommonResult(true);
     }
     return array('order' => $order);
 }
Ejemplo n.º 6
0
    ?>
" value="<?php 
    echo h($v);
    ?>
">
		<?php 
}
?>

		<table class="frm-tbl">
			<caption>订单生产单确认</caption>
			<tbody>
				<tr>
					<td class="col-label">订单总金额</td>
					<td><?php 
echo BusinessOrder::findOneByPk($_GET['business_order_id'])->total_price;
?>
</td>
				</tr>
				<?php 
foreach ($update_fields as $field => $alias) {
    ?>
				<tr>
					<td class="col-label"><?php 
    echo $alias;
    ?>
</td>
					<td>
						<?php 
    if ($defines[$field]['rel'] == 'upload-image') {
        ?>