コード例 #1
0
ファイル: SampleProduceOrder.php プロジェクト: sasumi/SvnPQA
 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('logistics_company' => array('options' => function () {
         $tmp = LogisticsCompany::find('state=?', LogisticsCompany::STATE_ENABLED)->all(true);
         return array_combine(array_column($tmp, 'id'), array_column($tmp, 'name'));
     }, 'display' => function (self $item) {
         $tmp = LogisticsCompany::findOneByPk($item->logistics_company);
         if (!$tmp) {
             return '';
         }
         return $tmp->state == LogisticsCompany::STATE_ENABLED ? $tmp->name : '<del>' . $tmp->name . '</del>';
     }), 'fee_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->fee_currency_id]['unit_name'];
         }
         return '';
     }), 'deliver_date' => array('default' => date('Y-m-d'))));
 }