예제 #1
0
 public static function &instance($_module = '')
 {
     static $instance;
     if ($instance == NULL) {
         $instance = new SystemPreferences();
     }
     if (!empty($_module) && empty($prefs[$_module])) {
         $instance->loadModule($_module);
     }
     return $instance;
 }
예제 #2
0
 function handle(DataObject $model)
 {
     // Do we want to generate an account number?
     $system_prefs = SystemPreferences::instance();
     $autoGenerate = $system_prefs->getPreferenceValue('auto-account-numbering', 'contacts');
     if (!(empty($autoGenerate) || $autoGenerate === 'off')) {
         // Obviously not.
         return false;
     }
     if (isset($model->accountnumber)) {
         // Account number already filled in, so just return.
         return false;
     }
     return $model->createAccountNumber();
 }
예제 #3
0
 public static function useDefault($search_data = null, &$errors = array(), $defaults = null)
 {
     $search = new pordersSearch($defaults);
     // Get relevant module preferences
     $system_prefs = SystemPreferences::instance();
     $viewAll = $system_prefs->getPreferenceValue('show-all-orders', 'purchase_order');
     // Search by Raised_By
     if ($viewAll == 'on') {
         $search->addSearchField('order', 'order_is', 'porder_status', array('Raised by me', 'Other Orders'));
     } else {
         $search->addSearchField('order', 'order_is', 'porder_status', array('Raised by me'));
     }
     // Search by Order Number
     $search->addSearchField('order_number', 'order_number', 'equal', '', 'basic');
     // Search by Order Number
     $search->addSearchField('lines', 'Show Lines', 'show', '', 'basic', false);
     // Search by Supplier
     $search->addSearchField('plmaster_id', 'Supplier', 'select', 0, 'advanced');
     $supplier = DataObjectFactory::Factory('PLSupplier');
     $options = array('0' => 'All');
     $suppliers = $supplier->getAll(null, false, true, '', '');
     $options += $suppliers;
     $search->setOptions('plmaster_id', $options);
     // Search by Project
     $search->addSearchField('project_id', 'Project', 'select', '', 'advanced');
     $project = DataObjectFactory::Factory('Project');
     $options = array('' => 'All');
     $projects = $project->getAll();
     $options += $projects;
     $search->setOptions('project_id', $options);
     // Search by Description
     $search->addSearchField('description', 'Description Contains', 'contains', '', 'advanced');
     // Search by Order Date
     $search->addSearchField('order_date', 'order_date_after', 'after', '', 'advanced');
     // Search by Due Date
     $search->addSearchField('due_date', 'due_date_before', 'before', '', 'advanced');
     // Search by Transaction Type
     $search->addSearchField('type', 'type', 'select', '', 'advanced');
     $options = array('' => 'All', 'O' => 'Order', 'R' => 'Requisition');
     $search->setOptions('type', $options);
     // Search by Status
     $search->addSearchField('status', 'status', 'select', '', 'advanced');
     $porder = DataObjectFactory::Factory('POrder');
     $options = array_merge(array('' => 'All'), $porder->getEnumOptions('status'));
     $search->setOptions('status', $options);
     $search->setSearchData($search_data, $errors);
     return $search;
 }
예제 #4
0
파일: Company.php 프로젝트: uzerpllp/uzerp
 function __construct($tablename = 'company')
 {
     // Register non-persistent attributes
     // Construct the object
     parent::__construct($tablename);
     $this->idField = 'id';
     // Set specific characteristics
     $this->subClass = true;
     $this->fkField = 'party_id';
     $this->orderby = 'name';
     $this->identifier = 'name';
     $this->identifierField = 'name';
     // Define validation
     $this->validateUniquenessOf('accountnumber');
     $this->validateUniquenessOf('name');
     // Define relationships
     $this->hasMany('PartyContactMethod', 'contactmethods', 'party_id', 'party_id');
     $this->hasMany('PartyAddress', 'addresses', 'party_id', 'party_id');
     $this->hasMany('PartyAddress', 'mainaddress', 'party_id', 'party_id');
     $this->belongsTo('User', 'assigned', 'assigned_to');
     $this->belongsTo('Company', 'parent_id', 'company_parent');
     $this->belongsTo('CompanyClassification', 'classification_id', 'company_classification');
     $this->belongsTo('CompanyIndustry', 'industry_id', 'company_industry');
     $this->belongsTo('CompanyRating', 'rating_id', 'company_rating');
     $this->belongsTo('CompanySource', 'source_id', 'company_source');
     $this->belongsTo('CompanyStatus', 'status_id', 'company_status');
     $this->belongsTo('CompanyType', 'type_id', 'company_type');
     $this->addValidator(new DistinctValidator(array('id', 'parent_id'), 'Account cannot be it\'s own parent'));
     $this->actsAsTree('parent_id');
     $this->setParent();
     $this->hasOne('Party', 'party_id', 'party');
     $this->hasMany('Person', 'people');
     $this->hasMany('Opportunity', 'opportunities');
     $this->hasMany('Project', 'projects');
     $this->hasMany('Activity', 'activities');
     $this->hasMany('CompanyInCategories', 'categories');
     // Define field formats
     $this->getField('website')->setFormatter(new URLFormatter());
     $this->getField('website')->type = 'html';
     $system_prefs = SystemPreferences::instance();
     $autoGenerate = $system_prefs->getPreferenceValue('auto-account-numbering', 'contacts');
     if (!(empty($autoGenerate) && $autoGenerate === 'on')) {
         //$this->getField('accountnumber')->not_null=false;
         $this->_autohandlers['accountnumber'] = new AccountNumberHandler();
     } else {
         $this->getField('accountnumber')->setnotnull();
     }
 }
예제 #5
0
 /**
  * @param SLCustomer $customer SLCustomer instance
  * @return bool
  */
 private function actionAllowedOnStop($customer)
 {
     try {
         // Get module preferences
         $system_prefs = SystemPreferences::instance();
         $pref = $system_prefs->getPreferenceValue('disable-orders-stopped', 'sales_order');
         if (get_class($customer) != 'SLCustomer') {
             throw new Exception('SordersController::actionAllowedOnStop: Invalid parameter value, function requires SLCustomer instance.');
         }
         if ($customer->accountStopped() and $pref === 'on') {
             return false;
         }
         return true;
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #6
0
 public function save_preferences()
 {
     $flash = Flash::Instance();
     $module = SystemPreferences::instance($this->setup_module);
     $this->registerPreference();
     $preferenceNames = $this->preferences->getPreferenceNames();
     $result = TRUE;
     // FIXME: Validate incoming data against supplied values
     foreach ($preferenceNames as $preferenceName) {
         $preference = $this->preferences->getPreference($preferenceName);
         if (isset($this->_data[$preferenceName])) {
             if (isset($preference['type']) && $preference['type'] == 'numeric') {
                 if (!is_numeric($this->_data[$preferenceName])) {
                     $flash->addError($preference['display_name'] . ' must be numeric');
                     $result = FALSE;
                     continue;
                 }
             }
             $module->setPreferenceValue($preferenceName, $this->_data['__moduleName'], $this->_data[$preferenceName]);
         } else {
             switch ($preference['type']) {
                 case 'checkbox':
                     $module->setPreferenceValue($preferenceName, $this->_data['__moduleName'], 'off');
                     break;
                 case 'select_multiple':
                     $module->setPreferenceValue($preferenceName, $this->_data['__moduleName'], array());
                     break;
             }
         }
     }
     $handled = $this->preferences->getHandledPreferences();
     foreach ($handled as $name => $preference) {
         if (!empty($this->_data[$name]) && isset($preference['callback'])) {
             $callback = array($module, $preference['callback']);
             call_user_func($callback, $this->_data);
         }
     }
     if ($result) {
         $flash->addMessage('Preferences saved OK');
     } else {
         $errors[] = 'Error saving preferences';
         $flash->addErrors($errors);
     }
     sendBack();
 }
예제 #7
0
 public function converttoaccount()
 {
     $company = $this->_uses['Lead'];
     if (isset($this->_data['Lead']) && isset($this->_data['Lead'][$company->idField])) {
         $id = $this->_data['Lead'][$company->idField];
         $data = $this->_data['Lead'];
     } elseif (isset($this->_data[$company->idField])) {
         $id = $this->_data[$company->idField];
     } else {
         $flash = Flash::Instance();
         $flash->addError('Select a Lead to convert');
         sendTo('leads', 'index', array('contacts'));
     }
     $company->load($id);
     if (!$company->isLoaded()) {
         $flash = Flash::instance();
         $flash->addError('You do not have permission to edit this lead.');
         sendTo($this->name, 'index', $this->_modules);
         return;
     }
     $pl = new PreferencePageList('recently_viewed_leads' . EGS_COMPANY_ID);
     $pl->removePage(new Page(array('module' => 'contacts', 'controller' => 'leads', 'action' => 'view', 'id' => $company->id), 'company', $company->name));
     $pl->save();
     $pl = new PreferencePageList('recently_viewed_companies' . EGS_COMPANY_ID);
     $pl->addPage(new Page(array('module' => 'contacts', 'controller' => 'companys', 'action' => 'view', 'id' => $company->id), 'company', $company->name));
     $pl->save();
     $system_prefs = SystemPreferences::instance();
     $autoGenerate = $system_prefs->getPreferenceValue('auto-account-numbering', 'contacts');
     if (!(empty($autoGenerate) || $autoGenerate === 'off')) {
         $company->update($id, array('is_lead', 'accountnumber'), array('false', $company->createAccountNumber()));
         sendTo('companys', 'view', array('contacts'), array('id' => $company->id));
     } else {
         if (isset($data['accountnumber'])) {
             $company->update($id, array('is_lead', 'accountnumber'), array('false', $data['accountnumber']));
             sendTo('companys', 'view', array('contacts'), array('id' => $company->id));
         } else {
             parent::_new();
         }
     }
 }