示例#1
0
 /**
  * Override set() to do idno_stub lookups on lots
  *
  * @param mixed $pm_fields
  * @param mixed $pm_value
  * @param array $pa_options Most options are handled by subclasses. Options defined here include:
  *		assumeIdnoStubForLotID = set to force lookup of lot_id values as ca_object_lots.idno_stub values first not matter what, before consideration as a numeric lot_id. The default is false, in which case integer values are considered lot_ids and non-numeric values possible idno_stubs.
  *		
  * @return int 
  */
 public function set($pm_fields, $pm_value = "", $pa_options = null)
 {
     if (!is_array($pm_fields)) {
         $pm_fields = array($pm_fields => $pm_value);
     }
     $pb_assume_idno_stub_for_lot_id = caGetOption('assumeIdnoStubForLotID', $pa_options, false);
     foreach ($pm_fields as $vs_fld => $vs_val) {
         if ($vs_fld == 'lot_id' && ($pb_assume_idno_stub_for_lot_id || preg_match("![^\\d]+!", $vs_val))) {
             $t_lot = new ca_object_lots();
             if ($t_lot->load(array('idno_stub' => $vs_val))) {
                 $vn_lot_id = (int) $t_lot->getPrimaryKey();
                 $pm_fields[$vs_fld] = $vn_lot_id;
             }
         }
     }
     return parent::set($pm_fields, null, $pa_options);
 }