1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| foreach($block_data_array as $block_data) {
try {
if(empty($block_data['field_a'])){
//$this->addDebug("ERROR : field_a Tag missing or empty.");
//EXCEPTION concerning the field_a Tag missing or empty.
throw new doc_exception(330);
}else{
$internal_department_id = "";
if(empty($block_data['field_b'])){
//EXCEPTION concerning the tag field_b not existing or empty.
throw new doc_exception(3301);
}else {
$internal_department_id = $db->getOne("...");
if(empty($internal_department_id)){
//EXCEPTION concerning the tag field_b not existing in the table departments.
throw new doc_exception(3302,'field_b = '.$block_data["field_b"]);
}
}
$storage_unit_number = $block_data['field_a'];
$i=1;
do{
$this->addDebug("Test if an Storage_Type (tag field_c".$i.") is existing.");
if(empty($block_data['field_c'.$i])){
if($i==1){
//EXCEPTION concerning the tag field_c1 : if this one do not exist, The Block can't be handled.
throw new doc_exception(331,$storage_unit_number);
}else{
$this->addDebug("There is no more field_c in this Block.");
$i=4;
}
}else{
$storage_unit_type = $block_data['field_c'.$i];
$storage_unit_id = $db->getOne("...");
if(empty($storage_unit_id)){
//EXCEPTION concerning the tag field_c($i) and the tag field_a => We skip the insertion of this part if the
throw new doc_exception(332);
}
$storage_quantity = "";
$storage_quantity_unit_id = "";
try{
if(is_numeric($block_data['lhmg'.$i])){
$storage_quantity = $block_data['lhmg'.$i];
}else{
//EXCEPTION concerning the tag lhmg($i) if numeric or not
throw new doc_exception(333,'lhmg'.$i);
}
}catch (doc_exception $e){
$error_msg = $e->getMsgError();
if($error_msg!=""){$this->addDebug($error_msg);debugText($error_msg);}
if($e->getTypeError()){throw $e;}
}
try{
if(!empty($block_data['field_d'.$i])){
$storage_quantity_unit_id = $db->getOne("...");
if(empty($storage_quantity_unit_id)){
//EXCEPTION concerning
throw new doc_exception(3331,'field_d'.$i.'= '.$block_data['field_d'.$i]);
}
}else{
throw new doc_exception(333,'field_d'.$i);
}
}catch (doc_exception $e){
$error_msg = $e->getMsgError();
if($error_msg!=""){$this->addDebug($error_msg);debugText($error_msg);}
if($e->getTypeError()){throw $e;}
}
//TEST IF ALREADY EXISTING IN THE ARRAY
$test_exist = false;
foreach ($this->storage_unit_mapping as $storage_mapping){
if((($storage_mapping['internal_department_id'])==$internal_department_id)&&(($storage_mapping['storage_unit_id'])==$storage_unit_id)){
$test_exist = true;
}
}
if($test_exist){
$this->addDebug("this is existing in the array already.");
//EXCEPTION concerning
throw new doc_exception(334);
}
$this->addDebug("INSERT : ('internal_department_id' => $internal_department_id, 'storage_unit_id' => $storage_unit_id, 'storage_quantity' => $storage_quantity, 'storage_quantity_unit_id' => $storage_quantity_unit_id)");
$this->storage_unit_mapping[] = array(
'internal_department_id' => $internal_department_id,
'storage_unit_id' => $storage_unit_id,
'storage_quantity' => $storage_quantity,
'storage_quantity_unit_id' => $storage_quantity_unit_id
);
$i++;
}
}while ($i<4);
}
}catch (doc_exception $e){
$error_msg = $e->getMsgError();
if($error_msg!=""){$this->addDebug($error_msg);debugText($error_msg);}
if($e->getTypeError()){throw $e;}
}
} |
Partager