Ejemplo n.º 1
0
 public function end_lines()
 {
     $productlines = new POProductlineCollection(DataObjectFactory::Factory('POProductline'));
     $sh = new SearchHandler($productlines, FALSE);
     $sh->addConstraint(new Constraint('productline_header_id', '=', $this->id));
     $cc = new ConstraintChain();
     $cc->add(new Constraint('end_date', 'is', 'NULL'));
     $cc->add(new Constraint('end_date', '>', $this->end_date), 'OR');
     $sh->addConstraint($cc);
     return $productlines->update('end_date', $this->end_date, $sh);
 }
Ejemplo n.º 2
0
 public function make_inactive()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $supplier = $this->_uses[$this->modeltype];
     $flash = Flash::Instance();
     // Check to make sure no-one has updated the customer
     if ($supplier->hasCurrentActivity()) {
         $flash->addError('Error making supplier inactive - supplier is still active');
     } else {
         $supplier->date_inactive = fix_date(date(DATE_FORMAT));
         $db = DB::Instance();
         $db->StartTrans();
         if (!$supplier->save()) {
             $flash->addError('Error making supplier inactive: ' . $db->ErrorMsg());
             $db->FailTrans();
         } else {
             // Now close off any open PO Product Lines for the Supplier
             $poproductline = DataObjectFactory::Factory('POProductline');
             $poproductlines = new POProductlineCollection($poproductline);
             $sh = new SearchHandler($poproductlines, FALSE);
             $sh->addConstraintChain($poproductline->currentConstraint());
             $sh->addConstraint(new Constraint('plmaster_id', '=', $supplier->id));
             if ($poproductlines->update('end_date', $supplier->date_inactive, $sh) !== FALSE) {
                 $flash->addMessage('Supplier marked as inactive');
             } else {
                 $flash->addError('Error closing off supplier product lines: ' . $db->ErrorMsg());
                 $db->FailTrans();
             }
         }
         $db->CompleteTrans();
     }
     sendBack();
 }