php xepan-base-Model_Table类(方法)实例源码

下面列出了php xepan-base-Model_Table 类(方法)源码代码实例,从而了解它的用法。

作者:xepa    项目:marketin   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\marketing\\MarketingCategory', 'marketing_category_id');
     $this->hasOne('xepan\\marketing\\Campaign', 'campaign_id');
     //$this->addCondition('type','CampaignCategory');
 }

作者:xepa    项目:account   
function load($id_name)
 {
     if (is_numeric($id_name)) {
         return parent::load($id_name);
     }
     $this->unload();
     $this->tryLoadBy('name', $id_name);
     if ($this->loaded()) {
         return $this;
     }
     foreach ($this->defaultGroups as $group) {
         if ($group['name'] == $id_name) {
             // balancesheet id set and parent id set if in array
             if ($group['parent_group']) {
                 $group['parent_group_id'] = $this->newInstance()->load($group['parent_group'])->get('id');
             }
             if ($group['root_group']) {
                 $group['root_group_id'] = $this->newInstance()->load($group['root_group'])->get('id');
             }
             $group['balance_sheet_id'] = $this->add('xepan\\accounts\\Model_BalanceSheet')->load($group['balance_sheet'])->get('id');
             $this->set($group)->save();
             return $this;
         }
     }
     throw $this->exception('Could Not Load Group');
 }

作者:xepa    项目:cr   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\base\\Contact', 'created_by_id')->defaultValue($this->app->employee->id);
     $this->hasOne('xepan\\communication\\Communication_Abstract_Email', 'communication_id');
     $this->hasOne('xepan\\crm\\SupportTicket', 'ticket_id');
     $this->addField('title');
     $this->addField('description')->type('text');
     $this->addField('type');
     $this->addField('created_at')->type('datetime')->defaultValue($this->app->now);
     $this->add('misc/Field_Callback', 'callback_date')->set(function ($m) {
         if (date('Y-m-d', strtotime($m['created_at'])) == date('Y-m-d', strtotime($this->app->now))) {
             return date('h:i a', strtotime($m['created_at']));
         }
         return date('M d', strtotime($m['created_at']));
     });
     $this->addExpression('collapse_header')->set(function ($m, $q) {
         return $q->expr("IF([0] is null or [0]='',[1],[2])", [$m->getElement('description'), $m->refSQL('communication_id')->fieldQuery('description'), $m->getElement('description')]);
     });
     $this->addExpression('from')->set(function ($m, $q) {
         return $m->refSQL('communication_id')->fieldQuery('from');
     });
     $this->addExpression('image')->set(function ($m, $q) {
         return $m->add('xepan\\base\\Model_Contact')->addCondition('id', $m->refSQL('communication_id')->fieldQuery('from_id'))->fieldQuery('image');
     });
     $this->addExpression('attach_count')->set(function ($m, $q) {
         return $m->refSQL('communication_id')->fieldQuery('attachment_count');
     });
 }

作者:xepa    项目:commerc   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\base\\Contact', 'contact_id');
     $this->hasOne('xepan\\commerce\\QSP_Detail', 'qsp_detail_id');
     $this->add('xepan\\filestore\\Field_File', 'file_id');
 }

作者:xepa    项目:commerc   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\commerce\\Item_CustomField_Generic', 'customfield_generic_id')->sortable(true);
     //->display(array('form'=>'autocomplete/Plus'));
     $this->hasOne('xepan\\commerce\\Item', 'item_id');
     $this->hasOne('xepan\\hr\\Department', 'department_id')->mandatory(true)->defaultValue(null)->sortable(true);
     $this->addField('status')->enum(['Active', 'DeActivate'])->defaultValue('Active')->sortable(true);
     $this->addField('group');
     $this->addField('order')->defaultValue(0)->sortable(true);
     $this->addField('can_effect_stock')->type('boolean')->defaultValue(false);
     $this->addField('is_optional')->type('boolean')->defaultValue(false);
     $this->hasMany('xepan\\commerce\\Item_CustomField_Value', 'customfield_association_id');
     $this->addExpression('name')->set(function ($m, $q) {
         return $m->refSQL('customfield_generic_id')->fieldQuery('name');
     })->sortable(true);
     $this->addExpression('display_type')->set(function ($m, $q) {
         return $m->refSQL('customfield_generic_id')->fieldQuery('display_type');
     });
     $this->addExpression('type')->set("'CustomFieldAssociation'");
     $this->addExpression('CustomFieldType')->set($this->refSQL('customfield_generic_id')->fieldQuery('type'));
     $this->addExpression('is_filterable')->set($this->refSQL('customfield_generic_id')->fieldQuery('is_filterable'));
     $this->addExpression('is_system')->set($this->refSQL('customfield_generic_id')->fieldQuery('is_system'));
     $this->addHook('beforeDelete', $this);
     $this->addHook('beforeSave', $this);
     $this->is(['customfield_generic_id|required', 'item_id|required']);
 }

作者:xepa    项目:blo   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\blog\\BlogPost');
     $this->addField('date')->display(['form' => 'DateTimePicker'])->type('datetime');
     $this->addField('is_posted')->defaultValue(0);
 }

作者:xepa    项目:commerc   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\commerce\\QSP_Detail', 'qsp_detail_id');
     $this->hasOne('xepan\\hr\\Department', 'department_id');
     $this->addExpression('Quantity')->set(function ($m, $q) {
         return $m->refSQL('qsp_detail_id')->fieldQuery('quantity');
     });
     $this->addField('status')->defaultValue('Waiting');
     $this->addField('is_open')->type('boolean')->defaultValue(true)->system(true);
     // status of previous department jobcard .. if any or null
     $this->addExpression('production_level')->set(function ($m, $q) {
         return $m->refSQL('department_id')->fieldQuery('production_level');
     });
     $this->addExpression('order_no')->set($this->refSQL('qsp_detail_id')->fieldQuery('qsp_master_id'));
     $this->addExpression('qsp_order_contact')->set($this->refSQL('qsp_detail_id')->fieldQuery('order_contact'));
     // $this->addExpression('previous_status')->set(function($m,$q){
     // 	return "'Todo'";
     // 	// my departments
     // 	// my previous departments : leftJOin
     // 	// job cards of my same orderitem_id from previous departments
     // 	// limit 1
     // 	//
     // 	return $m->refSQL('xProduction/JobCard')->_dsql()->limit(1)->del('fields')->field('status');
     // });
     // hasMany JobCards
     $this->hasMany('xepan\\production\\Jobcard', 'order_item_departmental_status_id');
     $this->addHook('beforeDelete', [$this, 'deleteJobcard']);
 }

作者:xepa    项目:bas   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\base\\Epan_Category');
     $this->hasOne('xepan\\base\\Contact', 'created_by_id');
     $this->addField('name')->hint('Identification for your epan');
     $this->addField('type')->defaultValue('Epan')->system(true);
     $this->addField('status')->defaultValue('Trial');
     $this->addField('created_at')->type('datetime')->defaultValue(isset($this->app->now) ? $this->app->now : null)->system(true);
     $this->addField('is_published')->defaultValue(null);
     $this->addField('extra_info')->type('text');
     $this->addField('aliases')->type('text');
     $this->addField('xepan_template_id');
     $this->addField('epan_dbversion');
     $this->hasMany('xepan\\base\\Epan_InstalledApplication', null, null, 'InstalledApplications');
     $this->hasMany('xepan\\communication\\Communication_EmailSetting', null, null, 'EmailSettings');
     $this->hasMany('xepan\\base\\Contact');
     $this->hasMany('xepan\\base\\User', null, null, 'Users');
     $this->hasMany('xepan\\base\\Epan_Configuration', null, null, 'Configurations');
     // $this->addHook('beforeDelete',[$this,'deleteAllEmailSettings']);
     // $this->addHook('beforeDelete',[$this,'deleteInstallApplications']);
     // $this->addHook('beforeDelete',[$this,'deleteContacts']);
     // $this->addHook('beforeDelete',[$this,'deleteUsers']);
     $this->is(['epan_category_id|required', 'name|required|to_trim|unique']);
 }

作者:xepa    项目:commerc   
function init()
 {
     parent::init();
     // $this->hasOne('xepan\base\Epan','epan_id');
     // $this->addCondition('epan_id',$this->app->epan->id);
     $this->hasOne('xepan\\base\\Contact', 'created_by_id')->defaultValue($this->app->employee->id)->system(true);
     $this->hasOne('xepan\\base\\Contact', 'updated_by_id')->defaultValue($this->app->employee->id)->system(true);
     $this->hasOne('xepan\\commerce\\Category', 'on_category_id');
     $this->addField('name')->caption('Voucher Number');
     $this->addField('start_date')->caption('Starting Date')->type('date')->defaultValue(date('Y-m-d'))->mandatory(true);
     $this->addField('expire_date')->type('date');
     $this->addField('no_of_person')->type('Number')->defaultValue(1)->hint('How many person ? (i.e. customer for online purchasing)');
     $this->addField('one_user_how_many_time')->type('Number')->defaultValue(1)->hint('How many time it can be used by one customer during online purchasing ?');
     $this->addField('on')->setValueList(['price' => "Price", 'shipping' => "Shipping", 'gross' => 'Gross (Both)'])->defaultValue('price');
     $this->addField('include_sub_category')->type('boolean');
     $this->addField('based_on')->setValueList(['gross_amount' => "Gross Amount"]);
     $this->addField('created_at')->type('date')->defaultValue($this->app->now)->sortable(true)->system(true);
     $this->addField('updated_at')->type('date')->defaultValue($this->app->now)->sortable(true)->system(true);
     $this->hasMany('xepan/commerce/DiscountVoucherCondition', 'discountvoucher_id');
     $this->hasMany('xepan/commerce/DiscountVoucherUsed', 'discountvoucher_id');
     $this->addField('type');
     $this->addField('status')->enum(['Active', 'DeActive'])->defaultValue('Active');
     $this->addCondition('type', 'Discount_Voucher');
     $this->is(['name|to_trim|required|unique_in_epan', 'start_date|required', 'expire_date|required', 'no_of_person|number|>0', 'one_user_how_many_time|number|>0', 'on|required']);
     $this->addHook('beforeDelete', $this);
 }

作者:xepa    项目:h   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\hr\\Employee', 'employee_id');
     $this->addField('from_date')->type('datetime');
     $this->addField('to_date')->type('datetime')->defaultValue(null);
     $this->addExpression('fdate')->set('DATE(from_date)');
     $this->addExpression('tdate')->set('DATE(to_date)');
     $this->addExpression('official_day_start')->set(function ($m, $q) {
         return $q->expr('CONCAT([0]," ",[1])', [$m->getElement('fdate'), $m->refSQL('employee_id')->fieldQuery('in_time')]);
     });
     $this->addExpression('official_day_end')->set(function ($m, $q) {
         return $q->expr('CONCAT([0]," ",[1])', [$m->getElement('fdate'), $m->refSQL('employee_id')->fieldQuery('out_time')]);
     });
     $this->addExpression('actual_day_ending')->set(function ($m, $q) {
         return $q->expr('IFNULL([0],[1])', [$q->getField('to_date'), $m->getElement('official_day_end')]);
     });
     $this->addExpression('actual_day_start_time')->set('date_format(from_date,"%H:%i:%s")');
     $this->addExpression('actual_day_end_time')->set(function ($m, $q) {
         return $q->expr('date_format([0],"%H:%i:%s")', [$m->getElement('actual_day_ending')]);
     });
     $this->addExpression('late_coming')->set(function ($m, $q) {
         return $q->expr('TIMESTAMPDIFF(MINUTE,[0],[1])', [$m->getElement('official_day_start'), $q->getField('from_date')]);
     });
     $this->addExpression('extra_work')->set(function ($m, $q) {
         return $q->expr('TIMESTAMPDIFF(MINUTE,[0],[1])', [$m->getElement('actual_day_ending'), $m->getElement('official_day_end')]);
     });
     $this->addExpression('working_hours')->set(function ($m, $q) {
         return $q->expr('TIMESTAMPDIFF(HOUR,[0],[1])', [$q->getField('from_date'), $m->getElement('actual_day_ending')]);
     });
 }

作者:xepa    项目:commerc   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\commerce\\Item', 'item_id');
     $this->addField('name');
     //->sortable(true); // To give special name to a quantity Set .. leave empty to have qty value here too
     $this->addField('qty')->type('number')->mandatory(true);
     //->sortable(true);
     $this->addField('old_price')->type('money')->mandatory(true)->caption('Unit Old Price');
     //->sortable(true);
     $this->addField('price')->type('money')->mandatory(true)->caption('Unit Price');
     //->sortable(true);
     $this->addField('is_default')->type('boolean')->defaultValue(false);
     $this->hasMany('xepan\\commerce\\Item\\Quantity\\Condition', 'quantity_set_id');
     $this->addExpression('custom_fields_conditioned')->set(function ($m, $q) {
         $temp = $m->add('xepan\\commerce\\Model_Item_Quantity_Condition')->addCondition('quantity_set_id', $q->getField('id'));
         return $temp->_dsql()->group('quantity_set_id')->del('fields')->field('count(*)');
     });
     //->sortable(true);
     $this->addExpression('conditions')->set(function ($m, $q) {
         $x = $m->add('xepan\\commerce\\Model_Item_Quantity_Condition', ['table_alias' => 'qtycondition_str']);
         return $x->addCondition('quantity_set_id', $q->getField('id'))->_dsql()->del('fields')->field($q->expr('group_concat([0] SEPARATOR "<br/>")', [$x->getElement('customfield_value')]));
     })->allowHTML(true);
     $this->addExpression('type')->set("'QuantitySet'");
     $this->addHook('beforeSave', $this);
     $this->addHook('beforeDelete', $this);
 }

作者:xepa    项目:h   
function init()
 {
     parent::init();
     $this->addField('name');
     $this->addField('date')->type('datetime');
     $this->addField('narration')->type('text');
 }

作者:xepa    项目:commerc   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\commerce\\Item_CustomField_Association', 'customfield_association_id');
     $this->addField('name');
     $this->addField('status')->enum(['Active', 'DeActive'])->defaultValue('Active');
     $this->addField('highlight_it')->type('boolean')->defaultValue(false);
     $this->addExpression('field_name_with_value')->set(function ($m, $q) {
         return $q->expr('CONCAT_WS(" :: ",[0],[1])', [$m->refSQL('customfield_association_id')->fieldQuery('customfield_generic'), $m->getElement('name')]);
     });
     $this->addExpression('customfield_name')->set(function ($m, $q) {
         return $m->refSQL('customfield_association_id')->fieldQuery('name');
     });
     $this->addExpression('customfield_type')->set(function ($m, $q) {
         return $m->refSQL('customfield_association_id')->fieldQuery('CustomFieldType');
     });
     $this->addExpression('item_id')->set($this->refSQL('customfield_association_id')->fieldQuery('item_id'));
     $this->hasMany('xepan\\commerce\\Item_Image', 'customfield_value_id');
     $this->hasMany('xepan\\commerce\\Item_Quantity_Condition', 'customfield_value_id');
     $this->hasMany('xepan\\commerce\\Store_TransactionRowCustomFieldValue', 'customfield_value_id');
     // $this->hasMany('xShop/CustomFieldValueFilterAssociation','customefieldvalue_id');
     $this->addExpression('type')->set("'CustomFieldValue'");
     $this->addHook('beforeDelete', $this);
     $this->addHook('beforeSave', $this);
     $this->is(['name|required', 'status|required']);
 }

作者:xepa    项目:commerc   
function init()
 {
     parent::init();
     $this->addField('name');
     $this->addField('status')->enum(['Active', 'Inactive']);
     $this->hasMany('xepan/commerce/FreelancerCatAndCustomerAssociation', 'freelancer_category_id');
 }

作者:xepa    项目:bas   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\base\\Epan');
     $this->addField('head');
     $this->addField('value')->type('text')->display(['form' => 'xepan\\base\\RichText']);
     $this->addField('application');
 }

作者:xepa    项目:marketin   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\marketing\\Lead', 'lead_id');
     $this->hasOne('xepan\\marketing\\MarketingCategory', 'marketing_category_id');
     $this->addField('created_at')->type('datetime')->defaultValue($this->app->now);
     // $this->addExpression('name')->set("'hello'");
 }

作者:xepa    项目:bas   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\base\\Document', 'document_id');
     $this->add('xepan\\filestore\\Field_File', 'file_id');
     $this->addHook('beforeDelete', $this);
     $this->is(['file_id|required']);
 }

作者:xepa    项目:h   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\hr\\Employee', 'employee_id');
     $this->hasOne('xepan\\hr\\Salary', 'salary_id');
     $this->addField('amount')->type('int');
     $this->addField('unit')->enum(['monthly']);
 }

作者:xepa    项目:h   
function init()
 {
     parent::init();
     $this->hasOne('xepan\\hr\\Employee', 'employee_id');
     $this->addField('name')->caption('Qualification')->hint('Name of Degree/Course');
     $this->addField('qualificaton_level')->hint('Graduation/Master/Phd/Others');
     $this->addField('remarks')->type('text');
 }

作者:xepa    项目:bas   
function init()
 {
     parent::init();
     $this->addField('name')->mandatory(true)->hint('Identification for Category');
     $this->hasMany('Epan');
     $this->is(['name|unique|to_trim|required']);
     $this->addHook('beforeDelete', $this);
 }


问题


面经


文章

微信
公众号

扫码关注公众号