예제 #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);
     })));
 }
예제 #2
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $this->setPropertiesDefine(array('customer_id' => array('display' => function (BusinessOrder $item) {
         return Customer::findOneByPk($item->customer_id)->company_alias_name;
     }, 'alias' => '公司简称'), 'customer_contact_id' => array('display' => function (BusinessOrder $item) {
         return CustomerContact::findOneByPk($item->customer_contact_id)->chinese_name;
     }, 'alias' => '联系人'), '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>';
     }), 'settle_currency_name' => array('getter' => function (BusinessOrder $item) {
         return $item->getPropertiesDefine('settle_currency')['options'][$item->settle_currency];
     }), 'sample_produce_order' => array('getter' => function (self $item) {
         return SampleProduceOrder::find('business_order_id=?', $item->id)->one();
     })));
 }