Esempio n. 1
0
 function copyStructure($data, &$errors)
 {
     $mfstructures = new MFStructureCollection(DataObjectFactory::Factory('MFStructure'));
     $cc1 = new ConstraintChain();
     $cc1->add(new Constraint('stitem_id', '=', $data->stitem_id));
     $cc1->add(new Constraint('start_date', '<=', fix_date(date(DATE_FORMAT))));
     $cc2 = new ConstraintChain();
     $cc2->add(new Constraint('end_date', '>=', fix_date(date(DATE_FORMAT))));
     $cc2->add(new Constraint('end_date', 'is', 'NULL'), 'OR');
     $sh = new SearchHandler($mfstructures, false);
     $sh->addConstraintChain($cc1);
     $sh->addConstraintChain($cc2);
     $mfstructures->load($sh);
     $wo_structure = array();
     $wo_structures = array();
     $copyfields = array('line_no', 'qty', 'uom_id', 'remarks', 'waste_pc', 'ststructure_id');
     foreach ($mfstructures as $input) {
         $wo_structure['work_order_id'] = $data->id;
         foreach ($copyfields as $field) {
             $wo_structure[$field] = $input->{$field};
         }
         $wo_structures[$input->line_no] = DataObject::Factory($wo_structure, $errors, 'MFWOStructure');
     }
     return $wo_structures;
 }
Esempio n. 2
0
 public static function getStructureCosts(ConstraintChain $cc, $type = 'latest')
 {
     $mfstructures = new MFStructureCollection();
     $sh = new SearchHandler($mfstructures, false);
     $sh->addConstraintChain($cc);
     $fields = array('id', 'line_no', 'stitem_id', 'ststructure_id', 'qty', 'uom_id', 'waste_pc', $type . '_mat', $type . '_lab', $type . '_osc', $type . '_ohd', $type . '_cost');
     $sh->setFields($fields);
     $sh->setOrderby('line_no');
     $mfstructures->load($sh);
     return $mfstructures;
 }