コード例 #1
0
 public function _new()
 {
     parent::_new();
     $permissions = new PermissionCollection(new Permission());
     $sh = new SearchHandler($permissions, FALSE);
     $sh->addConstraint(new Constraint('parent_id', 'is', 'NULL'));
     $sh->setOrderby('title');
     $permissions->load($sh);
     $systemcompany = $this->_uses[$this->modeltype];
     if ($systemcompany->isLoaded()) {
         $companypermissions = new CompanypermissionCollection(new Companypermission());
         $checked = $companypermissions->getPermissionIDs($systemcompany->id);
         $this->view->set('checked', $checked);
         $debug = DebugOption::getCompanyOption($systemcompany->id);
         $this->view->set('debug_id', $debug->id);
         $this->view->set('selected_options', $debug->getOptions());
         foreach ($permissions as $permission) {
             $permission->setAdditional('permissions');
             if (isset($checked[$permission->id])) {
                 $permission->permissions = TRUE;
             } else {
                 $permission->permissions = FALSE;
             }
         }
     }
     $this->view->set('permissions', $permissions);
     $debug = new DebugOption();
     $this->view->set('debug_options', $debug->getEnumOptions('options'));
 }
コード例 #2
0
 function index()
 {
     $this->view->set('clickaction', 'view');
     $s_data = array();
     $s_data['owner'] = EGS_USERNAME;
     $this->setSearch('CalendarSearch', 'useDefault', $s_data);
     parent::index(new CalendarCollection($this->_templateobject));
     $calendar = new CalendarCollection($this->_templateobject);
     $sh = new SearchHandler($calendar, false);
     $sh->addConstraint(new Constraint('owner', '=', EGS_USERNAME));
     $sh->setOrderby('name', 'ASC');
     $calendar->load($sh);
     if (isset($this->search) && ($this->isPrintDialog() || $this->isPrinting())) {
         $this->printCollection($calendar);
     }
     $this->view->set('calendar', $calendar);
     $this->view->set('num_records', $calendar->num_records);
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Events', array('new_event' => array('link' => array('module' => 'calendar', 'controller' => 'calendarevents', 'action' => 'new'), 'tag' => 'new_event'), 'view_events' => array('link' => array('module' => 'calendar', 'controller' => 'calendarevents', 'action' => 'index'), 'tag' => 'view_events')));
     $sidebar->addList('Tasks', array('new_task' => array('link' => array('module' => 'projects', 'controller' => 'tasks', 'action' => 'new'), 'tag' => 'new_task'), 'view_tasks' => array('link' => array('module' => 'projects', 'controller' => 'tasks', 'action' => 'index'), 'tag' => 'view_tasks')));
     $sidebar->addList('calendar_views', array('view_calendar' => array('link' => array('module' => 'calendar'), 'tag' => 'View Calendar')));
     $sidebar->addList('calendars', array('new_personal_calendar' => array('link' => array('module' => 'calendar', 'controller' => 'calendars', 'action' => 'new_personal'), 'tag' => 'new_personal_calendar'), 'new_group_calendar' => array('link' => array('module' => 'calendar', 'controller' => 'calendars', 'action' => 'new_group'), 'tag' => 'new_group_calendar'), 'add_google_calendar' => array('link' => array('module' => 'calendar', 'controller' => 'calendars', 'action' => 'new_gcal'), 'tag' => 'add_google_calendar')));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
コード例 #3
0
 function __construct($getCurrentValues = true)
 {
     parent::__construct();
     $userPreferences = UserPreferences::instance();
     $this->setModuleName('contacts');
     $roleCollection = new RoleCollection();
     $sh = new SearchHandler($roleCollection, false);
     $sh->AddConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
     $sh->setOrderby('name');
     $roleCollection->load($sh);
     $roles = array();
     foreach ($roleCollection->getContents() as $role) {
         $roles[$role->id] = array('value' => $role->id, 'label' => $role->name);
         if ($getCurrentValues) {
             if (in_array($role->id, $userPreferences->getPreferenceValue('default-read-roles', 'contacts'))) {
                 $roles[$role->id]['selected'] = true;
             }
         }
     }
     $this->registerPreference(array('name' => 'default-read-roles', 'display_name' => 'Default Read Access', 'type' => 'select_multiple', 'data' => $roles, 'default' => array()));
     foreach ($roleCollection->getContents() as $role) {
         $roles[$role->id] = array('value' => $role->id, 'label' => $role->name);
         if ($getCurrentValues) {
             if (in_array($role->id, $userPreferences->getPreferenceValue('default-write-roles', 'contacts'))) {
                 $roles[$role->id]['selected'] = true;
             }
         }
     }
     $this->registerPreference(array('name' => 'default-write-roles', 'display_name' => 'Default Write Access', 'type' => 'select_multiple', 'data' => $roles, 'default' => array()));
 }
コード例 #4
0
 public function index()
 {
     $id = $this->_data['stitem_id'];
     $transaction = new STItem();
     $transaction->load($id);
     $this->view->set('transaction', $transaction);
     $outside_ops = new MFOutsideOperationCollection($this->_templateobject);
     $sh = new SearchHandler($outside_ops, false);
     $cc = new ConstraintChain();
     $cc->add(new Constraint('stitem_id', '=', $id));
     $db = DB::Instance();
     $date = Constraint::TODAY;
     $between = $date . ' BETWEEN ' . $db->IfNull('start_date', $date) . ' AND ' . $db->IfNull('end_date', $date);
     $cc->add(new Constraint('', '', '(' . $between . ')'));
     $sh->addConstraintChain($cc);
     $sh->setOrderby('op_no');
     $outside_ops->load($sh);
     $this->view->set('outside_ops', $outside_ops);
     $this->view->set('linkfield', 'id');
     $this->view->set('linkvaluefield', 'id');
     $this->view->set('clickaction', 'view');
     $this->view->set('clickcontroller', 'MFOutsideOperations');
     $this->view->set('no_ordering', true);
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Show', array('allItems' => array('tag' => 'All Items', 'link' => array_merge($this->_modules, array('controller' => 'STItems', 'action' => 'index'))), 'thisItem' => array('tag' => 'Item Detail', 'link' => array_merge($this->_modules, array('controller' => 'STItems', 'action' => 'view', 'id' => $id))), 'addoperation' => array('tag' => 'Add Outside Operation', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'new', 'stitem_id' => $id)))));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
コード例 #5
0
 function getPeople($category_id)
 {
     $sh = new SearchHandler($this, false);
     $sh->addConstraint(new Constraint('category_id', '=', $category_id));
     $sh->setOrderby('surname');
     $this->load($sh);
 }
コード例 #6
0
 function remittanceList($trans_id)
 {
     $sh = new SearchHandler($this, false);
     $sh->addConstraint(new Constraint('status', '=', 'P'));
     $sh->addConstraint(new Constraint('cross_ref', '=', $trans_id));
     $sh->setOrderby('transaction_date');
     $this->load($sh);
 }
コード例 #7
0
 function getPermissionIDs($systemcompany, $orderby = 'permission')
 {
     $sh = new SearchHandler($this, false, false);
     $sh->setFields(array('permissionid', 'permission'));
     $sh->addConstraint(new Constraint('usercompanyid', '=', $systemcompany));
     $sh->setOrderby($orderby);
     $this->load($sh);
     return $this->getAssoc();
 }
コード例 #8
0
 function getPermissions($systemcompany, $roles = null, $orderby = 'permission')
 {
     $sh = new SearchHandler($this, false);
     $sh->addConstraint(new Constraint('usercompanyid', '=', $systemcompany));
     if (!empty($roles)) {
         $sh->addConstraint(new Constraint('roleid', 'in', '(' . $roles . ')'));
     }
     $sh->setOrderby($orderby);
     $this->load($sh);
 }
コード例 #9
0
 function getCompanies($category_id)
 {
     $sh = new SearchHandler($this, false);
     if (is_array($category_id)) {
         $sh->addConstraint(new Constraint('category_id', 'in', '(' . implode(',', $category_id) . ')'));
     } else {
         $sh->addConstraint(new Constraint('category_id', '=', $category_id));
     }
     $sh->setOrderby('company');
     $this->load($sh);
 }
コード例 #10
0
ファイル: StcostsController.php プロジェクト: uzerpllp/uzerp
 public static function getOutsideOperationCosts(ConstraintChain $cc, $type = 'latest')
 {
     $mfoutsideops = new MFOutsideOperationCollection();
     $sh = new SearchHandler($mfoutsideops, false);
     $sh->addConstraintChain($cc);
     $fields = array('id', 'op_no', 'description', $type . '_osc');
     $sh->setFields($fields);
     $sh->setOrderby('op_no');
     $mfoutsideops->load($sh);
     return $mfoutsideops;
 }
コード例 #11
0
ファイル: GLPeriod.php プロジェクト: uzerpllp/uzerp
 function getCurrentPeriod()
 {
     //
     //	Returns one row containing the 'current' period
     //  i.e. the oldest period that is still open
     //
     $sh = new SearchHandler(new GLPeriodCollection($this), false);
     $sh->fields = '*';
     $sh->addConstraint(new Constraint('closed', 'is not', 'true'));
     $sh->setOrderby('enddate', 'ASC');
     $this->loadBy($sh);
 }
コード例 #12
0
ファイル: MFShiftOutput.php プロジェクト: uzerpllp/uzerp
 public function getWorkOrders($stitem_id = '')
 {
     if (empty($stitem_id)) {
         return array();
     }
     $mfworkorders = new MFWorkorderCollection();
     $sh = new SearchHandler($mfworkorders, false);
     $sh->addConstraint(new Constraint('stitem_id', '=', $stitem_id));
     $sh->setOrderby('wo_number', 'DESC');
     $mfworkorders->load($sh);
     return $mfworkorders->getAssoc('wo_number');
 }
コード例 #13
0
ファイル: GLCentre.php プロジェクト: uzerpllp/uzerp
 public function __construct($tablename = 'gl_centres')
 {
     parent::__construct($tablename);
     $this->identifierField = 'cost_centre || \' - \' || description';
     $this->hasMany('GLAccountCentre', 'accounts', 'glcentre_id');
     $this->orderby = 'cost_centre';
     $this->validateUniquenessOf('cost_centre');
     $sh = new SearchHandler(new GLAccountCentreCollection(new GLAccountCentre()), false);
     $sh->setOrderby('glaccount');
     $this->addSearchHandler('accounts', $sh);
     // Define related item rules
     $this->linkRules = array('accounts' => array('actions' => array(), 'rules' => array()));
 }
コード例 #14
0
 function remittanceList($trans_id)
 {
     $allocation = DataObjectFactory::Factory('PLAllocation');
     $allocation->loadBy('transaction_id', $trans_id);
     if ($allocation->isLoaded()) {
         $sh = new SearchHandler($this, false);
         $sh->addConstraint(new Constraint('transaction_type', '!=', 'P'));
         $sh->addConstraint(new Constraint('status', '=', 'P'));
         $sh->addConstraint(new Constraint('allocation_id', '=', $allocation->allocation_id));
         $sh->setOrderby('transaction_date');
         $this->load($sh);
     }
 }
コード例 #15
0
ファイル: SOrderCollection.php プロジェクト: uzerpllp/uzerp
 public function getItemDates($cc = "")
 {
     $sh = new SearchHandler($this, FALSE);
     $DisplayFields = array('due_date', 'stitem_id', 'stitem', 'required');
     $sh->setOrderby('due_date');
     $sh->setFields($DisplayFields);
     if (!empty($cc) && $cc instanceof ConstraintChain) {
         $sh->addConstraintChain($cc);
     }
     $this->_tablename = 'so_itemdates';
     $this->load($sh);
     return $this;
 }
コード例 #16
0
 static function getDefinitionTree($definition_id, $parent_id = null)
 {
     $nextlevel = new DataDefinitionDetailCollection(new DataDefinitionDetail());
     $sh = new SearchHandler($nextlevel, false);
     $sh->addConstraint(new Constraint('data_definition_id', '=', $definition_id));
     if (empty($parent_id)) {
         $sh->addConstraint(new Constraint('parent_id', 'is', 'NULL'));
     } else {
         $sh->addConstraint(new Constraint('parent_id', '=', $parent));
     }
     $sh->setOrderby('position');
     $nextlevel->load($sh);
     return $nextlevel;
 }
コード例 #17
0
 function getLocationList($cc = "")
 {
     $sh = new SearchHandler($this, false);
     if ($cc instanceof ConstraintChain) {
         $sh->addConstraintChain($cc);
     }
     $sh->setOrderby(array('whstore', 'location'));
     $this->load($sh);
     $list = array();
     if ($this->count() > 0) {
         foreach ($this as $location) {
             $list[$location->id] = $location->whstore . '/' . $location->location . '-' . $location->description;
         }
     }
     return $list;
 }
コード例 #18
0
 function paymentsList($supplier_id = '')
 {
     $sh = new SearchHandler($this, false);
     if (!empty($supplier_id)) {
         $sh->addConstraint(new Constraint('id', '=', $supplier_id));
     }
     $sh->setOrderby('name');
     $this->load($sh);
     if ($this) {
         foreach ($this as $key => $supplier) {
             $sh = new SearchHandler(new PLTransactionCollection(), false);
             $sh->addConstraint(new Constraint('status', '=', 'O'));
             $sh->setOrderby(array('due_date'), array('ASC'));
             $supplier->addSearchHandler('transactions', $sh);
         }
     }
 }
コード例 #19
0
 function agedSummary()
 {
     $this->_tablename = 'sl_aged_debtors_summary';
     $sh = new SearchHandler($this, false);
     $sh->setOrderby('');
     $this->load($sh);
     $this->agedBalances['Total'] = 0;
     for ($i = 0; $i <= $this->agedMonths; $i++) {
         $this->agedBalances[$i] = 0;
     }
     $total = 0;
     foreach ($this as $agedcreditors) {
         $total = bcadd($total, $agedcreditors->value);
         if ($agedcreditors->id > $this->agedMonths) {
             $this->agedBalances[$this->agedMonths] += $agedcreditors->value;
         } else {
             $this->agedBalances[$agedcreditors->id] = $agedcreditors->value;
         }
     }
     $this->agedBalances['Total'] = $total;
     return $this->agedBalances;
 }
コード例 #20
0
ファイル: Calendar.php プロジェクト: uzerpllp/uzerp
 /**
  * getWritableCalendars
  * 
  * Used to return an array of calendars that a specific user has write access to
  * This will automatically exclude gcal until write functionality has been developed
  *
  * @return array of writable calendars
  */
 function getWritableCalendars($calendar_id = '')
 {
     $calendar = new CalendarCollection($this);
     $sh = new SearchHandler($calendar, false);
     if (!empty($calendar_id)) {
         $sh->addConstraint(new Constraint('id', '=', $calendar_id));
     }
     $sh->addConstraint(new Constraint('type', '!=', 'gcal'));
     $sh->addConstraint(new Constraint('owner', '=', EGS_USERNAME));
     $cc = new ConstraintChain();
     $cc->add(new Constraint('type', '=', 'group'));
     $cc->add(new Constraint('username', '=', EGS_USERNAME));
     $sh->addConstraintChain($cc, 'OR');
     $sh->setOrderby('name');
     $sh->setGroupBy('id');
     $calendar->load($sh);
     $calendar_id = array();
     foreach ($calendar as $key => $value) {
         $calendar_id[$value->id] = $value->name . " (" . $value->owner . ")";
     }
     return $calendar_id;
 }
コード例 #21
0
 function getPermissionTree($permissions = array(), $parent = null)
 {
     $nextlevel = new PermissionCollection();
     $sh = new SearchHandler($nextlevel, false);
     if (!empty($permissions)) {
         $sh->addConstraint(new Constraint('id', 'in', '(' . implode($permissions, ',') . ')'));
     }
     if (empty($parent)) {
         $sh->addConstraint(new Constraint('parent_id', 'is', 'NULL'));
     } else {
         $sh->addConstraint(new Constraint('parent_id', '=', $parent));
     }
     $sh->setOrderby('position');
     $rows = $nextlevel->load($sh, null, RETURN_ROWS);
     $tree = array();
     if (!empty($rows)) {
         foreach ($rows as $permission) {
             $tree[$permission['id']] = $permission;
             $tree[$permission['id']]['children'] = $this->getPermissionTree($permissions, $permission['id']);
         }
     }
     return $tree;
 }
コード例 #22
0
 public function reconcile()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $account = $this->_uses[$this->modeltype];
     $s_data = array();
     $transactions = new CBTransactionCollection(new CBTransaction());
     $sh = new SearchHandler($transactions, false);
     //		$sh->extract();
     $sh->setLimit(375);
     $sh->addConstraint(new Constraint('cb_account_id', '=', $this->_data['id']));
     $sh->addConstraint(new Constraint('status', '=', 'N'));
     $sh->setOrderby(array('transaction_date', 'payment_type', 'reference', 'ext_reference'));
     parent::index($transactions, $sh);
     $this->view->set('num_records', $transactions->num_records);
     $this->view->set('num_pages', 1);
     $this->view->set('cur_page', 1);
     $this->view->set('transactions', $transactions);
     $this->view->set('CBAccount', $account);
     $this->view->set('clickcontroller', 'cbtransactions');
     $this->view->set('clickaction', 'view');
 }
コード例 #23
0
ファイル: GLAccount.php プロジェクト: uzerpllp/uzerp
 function __construct($tablename = 'gl_accounts')
 {
     // Register non-persistent attributes
     // Contruct the object
     parent::__construct($tablename);
     // Set specific characteristics
     $this->identifierField = 'account || \' - \' || description';
     // Set ordering attributes
     $this->orderby = 'account';
     // Define validation
     $this->validateUniquenessOf('account');
     // Define relationships
     $this->belongsTo('GLAnalysis', 'glanalysis_id', 'analysis');
     $this->hasMany('GLAccountCentre', 'centres', 'glaccount_id');
     $sh = new SearchHandler(new GLAccountCentreCollection(new GLAccountCentre()), false);
     $sh->setOrderby('glcentre');
     $this->addSearchHandler('centres', $sh);
     // Define field formats
     // Define enumerated types
     $this->setEnum('actype', array('P' => 'Profit & Loss', 'B' => 'Balance Sheet'));
     // Define system defaults
     // Define related item rules
     $this->linkRules = array('centres' => array('actions' => array(), 'rules' => array()));
 }
コード例 #24
0
 public function ordersForInvoicing()
 {
     $sh = new SearchHandler($this, false);
     $DisplayFields = array('order_id', 'order_number');
     $sh->setOrderby(array('order_number'), array('ASC'));
     $sh->setFields($DisplayFields);
     $sh->setGroupBy($DisplayFields);
     $order = DataObjectFactory::Factory('Sorder');
     $sh->addConstraint(new Constraint('status', '=', $order->despatchStatus()));
     $this->load($sh);
     return $this;
 }
コード例 #25
0
 public function printMultipleBalance()
 {
     $flash = Flash::Instance();
     $errors = array();
     $extra = array();
     if (!isset($this->_data['WHLocation_location']) || empty($this->_data['WHLocation_location'])) {
         $errors[] = 'Location is a required field';
     }
     if (!isset($this->_data['WHBin_bins']) || empty($this->_data['WHBin_bins'])) {
         $errors[] = 'Bin is a required field';
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
         sendBack();
     }
     // Check and set default print set
     $userPreferences = UserPreferences::instance(EGS_USERNAME);
     $defaultPrinter = $userPreferences->getPreferenceValue('default_printer', 'shared');
     if (empty($defaultPrinter)) {
         $flash->addError('Cannot print without a default printer set');
         sendBack();
     } else {
         $this->_data['printtype'] = 'pdf';
         $this->_data['printaction'] = 'Print';
         $this->_data['printer'] = $defaultPrinter;
     }
     // construct constraint against bins
     $stbalances = new STBalanceCollection();
     $sh = new SearchHandler($stbalances, FALSE);
     $sh->addConstraint(new Constraint('balance', '<>', 0));
     $sh->addConstraint(new Constraint('whstore_id', '=', $this->_data['WHStore_store']));
     $sh->addConstraint(new Constraint('whlocation_id', '=', $this->_data['WHLocation_location']));
     $binlist = implode(',', $this->_data['WHBin_bins']);
     $sh->addConstraint(new Constraint('whbin_id', 'in', '(' . $binlist . ')'));
     $sh->setOrderby(array('whbin', 'stitem'), array('ASC', 'ASC'));
     $stbalances->load($sh);
     // set title
     $WHLocation = $this->_templateobject;
     $WHLocation->load($this->_data['WHLocation_location']);
     $WHStore = DataObjectFactory::Factory('WHStore');
     $WHStore->load($this->_data['WHStore_store']);
     $extra['title'] = 'Stock Balance for ' . $WHStore->description . ' / ' . $WHLocation->description . ' as at ' . un_fix_date(fix_date(date(DATE_FORMAT)));
     // construct xml
     $xml = $this->generateXML(array('model' => $stbalances, 'load_relationships' => FALSE, 'extra' => $extra));
     // build a basic list of options
     $options = array('report' => 'MF_MultipleStockBalance', 'xmlSource' => $xml);
     // construct the document, caputre the response
     $response = json_decode($this->constructOutput($this->_data, $options));
     // output success / failure message
     if ($response->status !== TRUE) {
         $flash->addError("Error printing document » " . $response->message);
     } else {
         $flash->addMessage("Document printed successfully");
     }
     // return back to eglet
     sendBack();
 }
コード例 #26
0
 function getVAT($data, $glperiod_ids, $control_accounts, $sum = false, $paging = false)
 {
     if (count($glperiod_ids) > 0) {
         $glperiods = implode(', ', $glperiod_ids);
         // Set data source
         switch ($data['box']) {
             // Tax overview
             case 1:
             case 4:
             case 7:
             case 6:
                 $this->_tablename = 'gltransactions_vat';
                 break;
                 // EU sales
             // EU sales
             case 8:
                 $this->_tablename = 'gl_taxeusales';
                 break;
                 // EU purchases
             // EU purchases
             case 2:
             case 9:
                 $this->_tablename = 'gl_taxeupurchases';
                 break;
         }
         // Set constraints
         $cc = new ConstraintChain();
         $cc->add(new Constraint('glperiods_id', ' IN', '(' . $glperiods . ')'));
         switch ($data['box']) {
             // VAT output
             case 1:
                 $cc->add(new Constraint('glaccount_id', '=', $control_accounts['vat_output']));
                 break;
                 // EU acquisitions
             // EU acquisitions
             case 2:
             case 9:
                 $cc->add(new Constraint('glaccount_id', '=', $control_accounts['eu_acquisitions']));
                 break;
                 // VAT input - also requires value from box 2
             // VAT input - also requires value from box 2
             case 4:
                 $cc->add(new Constraint('glaccount_id', '=', $control_accounts['vat_input']));
                 break;
                 // VAT output
             // VAT output
             case 6:
             case 8:
                 $cc->add(new Constraint('glaccount_id', '=', $control_accounts['vat_output']));
                 break;
                 // VAT input
             // VAT input
             case 7:
                 $cc->add(new Constraint('glaccount_id', '=', $control_accounts['vat_input']));
                 break;
         }
         if (isset($data['page'])) {
             $sh = new SearchHandler($this, true);
         } else {
             $sh = new SearchHandler($this, false);
         }
         if ($sum) {
             $fields = array('1');
             $sh->setGroupBy($fields);
             $sh->setOrderby($fields);
             // Set aggregate field
             switch ($data['box']) {
                 // VAT output
                 case 1:
                     $fields[] = 'SUM(vat) * -1 AS sum';
                     break;
                     // EU acquisitions (positive values only)
                 // EU acquisitions (positive values only)
                 case 2:
                     // VAT input/EU acquisitions (positive values only)
                 // VAT input/EU acquisitions (positive values only)
                 case 4:
                     $fields[] = 'SUM(vat) AS sum';
                     break;
                     // VAT output
                 // VAT output
                 case 6:
                 case 8:
                     $fields[] = 'SUM(net) * -1 AS sum';
                     break;
                     // VAT input
                 // VAT input
                 case 7:
                 case 9:
                     $fields[] = 'SUM(net) AS sum';
                     break;
             }
         } else {
             //				$this->num_pages = 1;
             //				$this->cur_page = 1;
             $fields = array('id', 'docref', 'glaccount_id', 'glcentre_id', 'glperiods_id', 'transaction_date', 'source', 'comment', 'type', 'usercompanyid');
             switch ($data['box']) {
                 // VAT output
                 case 1:
                 case 6:
                 case 8:
                     $fields[] = 'vat * -1 AS vat';
                     $fields[] = 'net * -1 AS net';
                     break;
                 default:
                     $fields[] = 'vat';
                     $fields[] = 'net';
                     break;
             }
             $sh->setOrderby(array('transaction_date', 'docref'));
             if ($paging) {
                 $sh->extract();
             }
         }
         $sh->setFields($fields);
         $sh->addConstraintChain($cc);
         $this->load($sh);
     }
 }
コード例 #27
0
 public function select_for_payment()
 {
     $errors = array();
     $supplier = DataObjectFactory::Factory('plsupplier');
     if (isset($this->_data['plmaster_id'])) {
         $supplier->load($this->_data['plmaster_id']);
     }
     // Search
     $s_data = array();
     // Set context from calling module
     if ($supplier) {
         $s_data['plmaster_id'] = $supplier->id;
     }
     $params = DataObjectFactory::Factory('GLParams');
     $s_data['currency_id'] = $params->base_currency();
     $paytype = DataObjectFactory::Factory('PaymentType');
     $cc = new ConstraintChain();
     $cc->add(new Constraint('method_id', 'is not', 'NULL'));
     $paytypes = $paytype->getAll($cc);
     $paytype_ids = array_keys($paytypes);
     $s_data['payment_type_id'] = $paytype_ids[0];
     $this->setSearch('pltransactionsSearch', 'select_payments', $s_data);
     // End of search
     $cc = '';
     if (isset($this->search)) {
         $cc = new ConstraintChain();
         $cc = $this->search->toConstraintChain();
     }
     $transaction = DataObjectFactory::Factory('PLTransaction');
     $transactions = new PLTransactionCollection($transaction, 'pl_allocation_overview');
     $sh = new SearchHandler($transactions, false);
     $sh->addConstraint(new Constraint('status', '=', 'O'));
     $sh->addConstraintChain($cc);
     $sh->setOrderby(array('supplier', 'our_reference'));
     $transactions->load($sh);
     $this->view->set('transactions', $transactions);
     $this->view->set('no_ordering', true);
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $this->sidebarIndex($sidebarlist);
     $this->sidebarAllPayments($sidebarlist);
     $sidebar->addList('Actions', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
コード例 #28
0
 public function printStatement($status = 'generate')
 {
     // Set the time limit on entry - may be one of a batch of statements
     set_time_limit(30);
     $customer = DataObjectFactory::Factory('SLCustomer');
     $customer->load($this->_data['id']);
     $bank_account = $customer->bank_account_detail;
     /*
      * if (SYSTEM_COMPANY<>'') {
      * $data['subject']='Statement from '.SYSTEM_COMPANY;
      * }
      */
     // set options
     $options = array('type' => array('pdf' => '', 'xml' => ''), 'output' => array('print' => '', 'save' => '', 'email' => '', 'view' => ''), 'report' => 'Statement', 'filename' => 'Statements_' . fix_date(date(DATE_FORMAT)));
     if (strtolower($this->_data['printaction']) == 'printstatement' && !is_null($customer->email_statement())) {
         $options['default_print_action'] = 'email';
         $options['email'] = $customer->email_statement();
         $options['email_subject'] = 'Statement';
     }
     // if we're dealing with the dialog, just return the options...
     if (strtolower($status) == 'dialog') {
         return $options;
     }
     // ...otherwise continue with the function
     $sh = new SearchHandler(new SLTransactionCollection(), false);
     $sh->addConstraint(new Constraint('status', '<>', 'P'));
     $sh->setOrderby(array('due_date'), array('ASC'));
     $customer->addSearchHandler('transactions', $sh);
     $extra = array();
     // get the company address
     $company_address = array('name' => $this->getCompanyName());
     $company_address += $this->formatAddress($this->getCompanyAddress());
     $extra['company_address'] = $company_address;
     // get the company details
     $extra['company_details'] = $this->getCompanyDetails();
     // get the invoice address
     $payment_address = array();
     $payment_address['name'] = $customer->name;
     $payment_address += $this->formatAddress($customer->getBillingAddress());
     $extra['payment_address'] = $payment_address;
     // get current date
     $extra['current_date'] = un_fix_date(fix_date(date(DATE_FORMAT)));
     // get aged debtor summary
     foreach ($customer->getAgedDebtorSummary(3) as $key => $value) {
         $extra['aged_debtor_summary'][]['line'] = $value;
     }
     // get bank details
     if (!is_null($bank_account->bank_account_number)) {
         $extra['bank_account']['bank_name'] = $bank_account->bank_name;
         $extra['bank_account']['bank_sort_code'] = $bank_account->bank_sort_code;
         $extra['bank_account']['bank_account_number'] = $bank_account->bank_account_number;
         $extra['bank_account']['bank_address'] = $bank_account->bank_address;
         $extra['bank_account']['bank_iban_number'] = $bank_account->bank_iban_number;
         $extra['bank_account']['bank_bic_code'] = $bank_account->bank_bic_code;
     }
     // generate the XML, include the extras array too
     $options['xmlSource'] = $this->generateXML(array('model' => $customer, 'extra' => $extra, 'relationship_whitelist' => array('transactions')));
     // construct the document, capture the response
     $json_response = $this->constructOutput($this->_data['print'], $options);
     // decode response, if it was successful update the print count
     $response = json_decode($json_response, true);
     if ($response['status'] === true) {
         if (!$customer->update($customer->id, 'last_statement_date', fix_date(date(DATE_FORMAT)))) {
             // if we cannot update the date, update json_responce with an error
             $json_response = $this->returnResponse(false, array('message' => 'Statement output correctly, but failed to update statement date for customer ' . $customer->name));
         }
     }
     // now we've done our checks, output the original JSON for jQuery to use
     // echo the response if we're using ajax, return the response otherwise
     if (isset($this->_data['ajax'])) {
         echo $json_response;
     } else {
         return $json_response;
     }
     exit;
 }
コード例 #29
0
ファイル: Employee.php プロジェクト: uzerpllp/uzerp
 public function getOutstandingTransactions($extract = true, $cc = '')
 {
     $transactions = new ELTransactionCollection();
     $sh = new SearchHandler($transactions, false);
     if ($extract) {
         $sh->extract();
     }
     $sh->addConstraint(new Constraint('status', '=', 'O'));
     if ($this->id) {
         $sh->addConstraint(new Constraint('employee_id', '=', $this->id));
     }
     if (!empty($cc) && $cc instanceof ConstraintChain) {
         $sh->addConstraintChain($cc);
     }
     $sh->setOrderby(array('employee', 'our_reference'));
     $transactions->load($sh);
     return $transactions;
 }
コード例 #30
0
 function getTopSales($top = 10, $type = 'customer')
 {
     $startdate = fix_date('01/' . date('m/Y'));
     $enddate = fix_date(date(DATE_FORMAT, strtotime("-1 days", strtotime("+1 months", strtotime($startdate)))));
     $fields = array();
     switch ($type) {
         case 'customer':
             $fields[] = 'customer';
             $sumby = 'base_net_value';
             break;
         case 'item by qty':
             $fields[] = 'stitem';
             $sumby = 'sales_qty';
             $sh->addConstraint(new Constraint('stitem', 'is not', 'NULL'));
             break;
         case 'item by value':
             $fields[] = 'stitem';
             $sumby = 'base_net_value';
             $sh->addConstraint(new Constraint('stitem', 'is not', 'NULL'));
             break;
     }
     $invoice_fields = $fields;
     $invoices = clone $this;
     $sh = new SearchHandler($invoices, false);
     $sh->setGroupBy($invoice_fields);
     $sh->setOrderby($invoice_fields);
     $invoice_fields[] = 'sum(' . $sumby . ') as value';
     $sh->setFields($invoice_fields);
     $sh->addConstraint(new Constraint('invoice_date', 'between', "'" . $startdate . "' and '" . $enddate . "'"));
     $sh->addConstraint(new Constraint('transaction_type', '=', 'I'));
     $invoice_data = $invoices->load($sh, null, RETURN_ROWS);
     $credit_fields = $fields;
     $sh = new SearchHandler($this, false);
     $sh->setGroupBy($credit_fields);
     $sh->setOrderby($credit_fields);
     $credit_fields[] = 'sum(' . $sumby . ') as value';
     $sh->setFields($credit_fields);
     $sh->addConstraint(new Constraint('invoice_date', 'between', "'" . $startdate . "' and '" . $enddate . "'"));
     $sh->addConstraint(new Constraint('transaction_type', '=', 'C'));
     $credits = $this->load($sh, null, RETURN_ROWS);
     $data = array();
     if (is_array($invoice_data)) {
         foreach ($invoice_data as $invoice) {
             $data[$invoice['id']] = $invoice['value'];
         }
     }
     if (is_array($credits)) {
         foreach ($credits as $credit) {
             if (isset($data[$credit['id']])) {
                 $data[$credit['id']] -= $credit['value'];
             }
         }
     }
     arsort($data, SORT_NUMERIC);
     $typesarray = array('customer' => 'By Customer', 'item by qty' => 'By Item Quantity', 'item by value' => 'By Item Value');
     $this->customerorders = array('source' => 'invoices', 'controller' => 'sinvoices', 'submodule' => 'sales_invoicing', 'types' => $typesarray, 'type' => $type, 'details' => array());
     $count = 0;
     foreach ($data as $key => $value) {
         if ($count < $top) {
             $this->customerorders['details'][$key] = $value;
         } else {
             break;
         }
         $count++;
     }
     return $this->customerorders;
 }