Ejemplo n.º 1
0
 public function view()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $transaction = $this->_uses[$this->modeltype];
     $id = $transaction->id;
     $this->view->set('transaction', $transaction);
     $elements = new WHTransferruleCollection(new WHTransferrule());
     $sh = new SearchHandler($elements, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('whaction_id', '=', $id));
     $sh->extractOrdering();
     $sh->extractPaging();
     $elements->load($sh);
     $this->view->set('elements', $elements);
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Show', array('all' => array('tag' => 'All Actions', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'index'))), 'locations' => array('tag' => 'All Stores', 'link' => array_merge($this->_modules, array('controller' => 'WHStores', 'action' => 'index')))));
     $sidebarlist = array();
     $sidebarlist['edit'] = array('tag' => 'Edit', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'edit', 'id' => $id)));
     $sidebarlist['delete'] = array('tag' => 'Delete', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'delete', 'id' => $id)));
     if (is_null($transaction->max_rules) || $elements->count() < $transaction->max_rules) {
         $sidebarlist['Add'] = array('tag' => 'Add Rule', 'link' => array_merge($this->_modules, array('controller' => 'WHTransferrules', 'action' => 'new', 'whaction_id' => $id)));
     }
     $sidebar->addList('This Action', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     $this->view->set('clickaction', 'view');
     $this->view->set('clickcontroller', 'WHTransferrules');
     $this->view->set('no_ordering', true);
 }
Ejemplo n.º 2
0
 public function _new()
 {
     parent::_new();
     // For new actions the stitem_id and from_uom_id will be set
     // For edit actions, the id will be set pointing to the uom conversion to be edited
     if ($this->_data['action'] == 'edit') {
         $stuom = $this->_uses[$this->modeltype];
         $stitem_id = $stuom->stitem_id;
         $stitem_uom_id = $stuom->from_uom_id;
         $stitem_uom_name = $stuom->from_uom_name;
     } else {
         $stitem = new STitem();
         $stitem->load($this->_data['stitem_id']);
         $stitem_id = $stitem->id;
         $stitem_uom_id = $stitem->uom_id;
         $stitem_uom_name = $stitem->uom_name;
     }
     $this->view->set('stitem_id', $stitem_id);
     $this->view->set('stitem_uom_id', $stitem_uom_id);
     $this->view->set('stitem_uom_name', $stitem_uom_name);
     $this->view->set('stitem', Stuomconversion::getStockItem($stitem_id));
     $elements = new STuomconversionCollection(new STuomconversion());
     $sh = new SearchHandler($elements, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('stitem_id', '=', $stitem_id));
     $sh->setOrderBy('from_uom_name');
     $sh->extractOrdering();
     $sh->extractPaging();
     $elements->load($sh);
     $this->view->set('elements', $elements);
     $this->view->set('no_ordering', true);
 }
Ejemplo n.º 3
0
 public function showParts($id)
 {
     $elements = new MFWOStructureCollection(new MFWOStructure());
     $sh = new SearchHandler($elements, false);
     $sh->addConstraint(new Constraint('work_order_id', '=', $id));
     $sh->setOrderBy('line_no');
     $sh->extractOrdering();
     $elements->load($sh);
     return $elements;
 }
Ejemplo n.º 4
0
 public function detail()
 {
     $errors = array();
     $s_data = $this->setSearch();
     $constrain = FALSE;
     $fields = array('slmaster_id', 'product_group', 'cs_failurecode_id', 'start', 'end');
     // if failure code is 'any' remove it from the search, we've got other criteria to search by...
     if (isset($this->_data['cs_failurecode_id']) && strtolower($this->_data['cs_failurecode_id']) === 'any') {
         // don't let the standard search do anything with the cs_failurecode_id field
         unset($s_data['cs_failurecode_id']);
         $constrain = TRUE;
         // constrain where failure code has not been set...
         $cc1 = new ConstraintChain();
         $cc1->add(new Constraint('cs_failurecode_id', 'IS', 'NULL'));
         // and another constraint chain for the failed order
         $cc2 = new ConstraintChain();
         $cc2->add(new Constraint('despatch_date', '>', '(due_despatch_date)'));
         $cc2->add(new Constraint('order_qty', '>', '(despatch_qty)'), 'OR');
     }
     $customerservice = new CustomerServiceCollection($this->_templateobject);
     if (!isset($this->_data['orderby']) && !isset($this->_data['page']) && !($this->isPrintDialog() || $this->isPrinting())) {
         $sh = $customerservice->setSearch($s_data, false);
         $sh->setOrderby(array('product_group', 'customer', 'order_number', 'due_despatch_date'), array('ASC', 'ASC', 'DESC', 'DESC'));
     } else {
         // $sh = $customerservice->setSearch($s_data, TRUE);
         // echo '$s_data<pre>'.print_r($s_data, true).'</pre><br>';
         $sh = new SearchHandler($customerservice, TRUE);
     }
     $this->search = customerServicesSearch::useDefault($s_data, $errors, $customerservice);
     if (count($errors) > 0) {
         $flash = Flash::Instance();
         $flash->addErrors($errors);
         $this->search->clear();
     }
     if (isset($this->search) && !isset($this->_data['ajax_print']) && !isset($this->_data['orderby']) && !isset($this->_data['page'])) {
         // cache the search string
         $search_string_array = array('fop' => $this->search->toString('fop'), 'html' => $this->search->toString('html'));
         $_SESSION['search_strings'][EGS_USERNAME][$sh->search_id] = $search_string_array;
     }
     if ($constrain === TRUE) {
         // add the two constraint chains seperately
         $sh->addConstraintChain($cc1);
         $sh->addConstraintChain($cc2);
     }
     $sh->extractOrdering();
     $sh->setFields(array('id', 'product_group', 'customer', 'stitem', 'order_number', 'despatch_number', 'due_despatch_date', 'despatch_date', 'order_qty', 'despatch_qty', 'failurecode', 'cs_failurecode_id', 'cs_failure_note'));
     if (isset($this->search) && ($this->isPrintDialog() || $this->isPrinting())) {
         $sh->setLimit(0);
         $customerservice->load($sh);
         return parent::printCollection($customerservice);
     } else {
         $sh->extractPaging();
         $customerservice->load($sh);
     }
     $this->view->set('num_records', $customerservice->num_records);
     $this->view->set('num_pages', $customerservice->num_pages);
     $this->view->set('cur_page', $customerservice->cur_page);
     $this->view->set(strtolower($customerservice->getModelName()) . 's', $customerservice);
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Actions', array('all' => array('link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'index')), 'tag' => 'Customer Service Summary'), 'failurecodes' => array('link' => array_merge($this->_modules, array('controller' => 'csfailurecodes', 'action' => 'index')), 'tag' => 'View Failure Codes')));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
Ejemplo n.º 5
0
 /**
  * fills a collection of the specified model type with the fields specified,
  * also gives correct click controller, action and edit handlers so
  * that smarty datatable will work correctly.
  * finally outputs specified smarty variable as the collection for
  * datatable to use
  * used for alternate controller to display specific contents of a different
  * controller
  */
 public function fillCollection($modelname, $fields, $constraints, $clickcontroller, $clickaction, $editclickaction, $deletecontroller, $smartyname, $tablename = null, $deleteaction = null, $newtext = null, $limit = null, $orderdir = null, $offset = null)
 {
     $collectionname = $modelname . 'Collection';
     $collection = new $collectionname();
     $sh = new SearchHandler($collection);
     $sh->fields = $fields;
     $sh->constraints = $constraints;
     $sh->extractOrdering();
     $sh->extractPaging();
     $sh->perpage = 900000;
     if (isset($orderdir)) {
         $sh->orderdir = $orderdir;
     }
     if (isset($limit) && isset($offset)) {
         $sh->setLimit($limit, $offset);
     }
     if (isset($tablename)) {
         $collection->_tablename = $tablename;
     }
     $collection->load($sh);
     $collection->clickcontroller = $clickcontroller;
     $collection->clickaction = $clickaction;
     $collection->editclickaction = $editclickaction;
     $collection->deletecontroller = $deletecontroller;
     if (isset($deleteaction)) {
         $collection->deleteclickaction = $deleteaction;
     }
     if (isset($newtext)) {
         $collection->newtext = $newtext;
     }
     $this->view->set($smartyname, $collection);
 }
Ejemplo n.º 6
0
 public function select_for_output()
 {
     // Search
     $errors = array();
     $s_data = array();
     // Set context from calling module
     if (isset($this->_data['Search'])) {
         $this->_data['type'] = $this->_data['Search']['type'];
         if (!empty($this->_data['Search']['clear'])) {
             $_SESSION['selected_output'][$this->_data['type']] = array('count' => 0);
         }
     }
     if (!$this->checkParams('type')) {
         sendBack();
     }
     $type = $this->_data['type'];
     $selected = empty($_SESSION['selected_output'][$type]) ? array() : $_SESSION['selected_output'][$type];
     $output_details = $this->output_types[$this->_data['type']];
     $s_data = $output_details['search_defaults'];
     $s_data['type'] = $_GET['type'] = $type;
     $this->setSearch($output_details['search_do'], $output_details['search_method'], $s_data, array(), TRUE);
     // End of search
     if (!isset($this->_data['page']) && !isset($this->_data['orderby'])) {
         $collection = new $output_details['collection']($this->_templateobject);
         if (!isset($this->_data['orderby']) && !isset($this->_data['page'])) {
             $sh = new SearchHandler($collection, FALSE);
         } else {
             $sh = new SearchHandler($collection);
         }
         $sh->setFields($output_details['collection_fields']);
         $cc = $this->search->toConstraintChain();
         $sh->addConstraintChain($cc);
         $sh->extractOrdering();
         $collection->load($sh);
         $selected = empty($_SESSION['selected_output'][$type]) ? array() : $_SESSION['selected_output'][$type];
         $new_selection = array('count' => 0);
         foreach ($collection as $detail) {
             if (isset($selected[$detail->id])) {
                 $new_selection[$detail->id] = $selected[$detail->id];
                 if ($selected[$detail->id]['select'] == 'true') {
                     $new_selection['count']++;
                 }
             } else {
                 if (isset($output_details['identifier'])) {
                     $new_selection[$detail->id]['description'] = prettify($output_details['identifier']) . ' : ' . $detail->{$output_details}['identifier'];
                 } else {
                     $new_selection[$detail->id]['description'] = $detail->getIdentifierValue();
                 }
                 if (empty($new_selection[$detail->id]['description'])) {
                     $new_selection[$detail->id]['description'] = 'no identifier set';
                 }
                 // Need a beter way of identifying the print action
                 // - in SLCustomer, there is the invoice method enum
                 // - in PrintController there is the printaction enum
                 // These are not equivalent; e.g. the print controller printaction needs to list
                 // methods that can be handled within the code whereas the SLCustomer invoice_method
                 // defines how an invoice is sent which may be handled within the code or externally.
                 // As an example, invoices can be faxed, but this cannot currently be done from within code,
                 // so the invoice must be printed and manually faxed.
                 // Therefore, perhaps the SLCustomer invoice_method Fax needs to be implemented internally
                 // as Print until a fax model is implemented
                 if (!is_null($detail->method)) {
                     switch ($detail->method) {
                         case 'E':
                             $new_selection[$detail->id]['printaction'] = 'email';
                             break;
                         case 'D':
                             $new_selection[$detail->id]['printaction'] = 'edi';
                             break;
                         case 'F':
                         case 'P':
                             $new_selection[$detail->id]['printaction'] = 'print';
                             break;
                         default:
                             $new_selection[$detail->id]['printaction'] = strtolower($detail->method);
                     }
                 } elseif ($detail->email == '') {
                     $new_selection[$detail->id]['printaction'] = 'print';
                 } else {
                     $new_selection[$detail->id]['printaction'] = 'email';
                 }
                 $new_selection[$detail->id]['email'] = $detail->email;
                 $new_selection[$detail->id]['select'] = 'false';
             }
         }
         $_SESSION['selected_output'][$type] = $selected = $new_selection;
     }
     $collection = new $output_details['collection']($this->_templateobject);
     $sh = $this->setSearchHandler($collection);
     $sh->setFields($output_details['collection_fields']);
     parent::index($collection, $sh);
     $this->view->set('type', $this->_data['type']);
     $this->view->set('fields', $output_details['display_fields']);
     $this->view->set('clickaction', 'view');
     $this->view->set('no_ordering', TRUE);
     $this->view->set('collection', $this->view->getTemplateVars(strtolower($collection->getModelName()) . 's'));
     $this->_data['printaction'] = $output_details['printaction'];
     $this->_data['filename'] = $output_details['filename'];
     unset($this->printaction['view']);
     $this->printAction();
     $this->view->set('page_title', $this->getPageName("", $output_details['title']));
     $this->view->set('selected_output', $selected);
     $this->view->set('count_selected', $selected['count']);
     foreach ($this->_modules as $key => $value) {
         $modules[] = $key . '=' . $value;
     }
     $link = implode('&', $modules) . '&controller=' . $this->name . '&action=adjust_selection&type=' . $type;
     $this->view->set('link', $link);
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['summary'] = array('tag' => 'Show ' . $this->_data['type'] . 's Summary List', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'output_summary', 'type' => $type));
     $sidebar->addList('action', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
Ejemplo n.º 7
0
 public function showFulfilled()
 {
     $mfworkorders = new MFWorkorderCollection($this->_templateobject);
     $sh = new SearchHandler($mfworkorders);
     $sh->extract();
     $sh->addConstraint(new Constraint('status', '=', 'O'));
     $sh->addConstraint(new Constraint('made_qty', '>=', '(order_qty)'));
     $sh->extractOrdering();
     $sh->extractPaging();
     $mfworkorders->load($sh);
     $this->view->set('clickaction', 'view');
     $this->view->set('mfworkorders', $mfworkorders);
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['viewAll'] = array('tag' => 'View', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index'));
     $sidebar->addList('All Works Orders', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }