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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| <?php
// MTAO Div
/*
* This function returns the content of a column (left or right)
* Be acreful, we need to pass as argument the TWording and Translate, because this is not visible in the function
*/
$Translate = Zend_Registry::get('Zend_Translate');
/*
* DISPLAY SETTING
*
*/
$itemsWorkType .= "<div class='work'>";
// Comments
$itemsWorkType .="<div class='comments'>
<h2>".$this->_helper->DecodeTranslation('Notes', 1)."</h2>
<div class='hr'></div>
";
$itemsWorkType .= "<table class='tableFields'>";
// Get the name of the description field:
$sDescriptionFieldName = $this->_VWork->getFieldObs($workInfos['work_code']);
if ($workInfos[$sDescriptionFieldName] == '1'){
$commentValue = $this->_helper->DecodeTranslation('No notes have been added.', 1);
} else {
$commentValue = $workInfos[$sDescriptionFieldName];
}
$itemsWorkType .= "<tr>
<td><div class='commentsValue'>".$commentValue."</div></td>
</tr>";
// end Comments
$itemsWorkType .= "</table></div>
<hr class='separation'/>
";
/*
* We extract the fields with the SQL command DESCRIBE
* We keep all the fields excepted those with 'obs' and with work_code
*/
$workDescFields = array();
foreach ( $this->_VWork->getFields($workInfos['work_code']) as $fieldName)
{
if(!preg_match('#work_code#',$fieldName) && !preg_match('#obs#',$fieldName))
$workDescFields[] = $fieldName;
}
$iMax = count($workDescFields);
if ($iMax > 5 )//In this case we do 2 columns
{
// MTAO Fields Description (col-left)
$itemsWorkType .="<div class='col-left'>
<h2>".$this->_helper->DecodeTranslation('Description', 1)."</h2>
<div class='hrsmallblock'></div>";
$itemsWorkType .= workColumnContent ($this->_TWording, $Translate, $workDescFields, $workInfos, 0 , (int)($iMax/2) );
$itemsWorkType .= "</div>";//eof col_left
// work Fields Description (col-right)
$itemsWorkType .="<div class='col-right'>
<h2>".$this->_helper->DecodeTranslation('Further information ', 1)."</h2>
<div class='hrsmallblock'></div>";
$itemsWorkType .= workColumnContent ($this->_TWording, $Translate, $workDescFields, $workInfos, (int)($iMax/2), $iMax );
$itemsWorkType .= "</div>";//eof col_right
} else {//only one column
// work Fields Description (col-left)
$itemsWorkType .="<div class='col-left'>
<h2>".$this->_helper->DecodeTranslation('Description', 1)."</h2>
<div class='hrsmallblock'></div>";
$itemsWorkType .= workColumnContent ($this->_TWording, $Translate, $workDescFields, $workInfos, 0 , (int)($iMax) );
$itemsWorkType .= "</div>";//eof col_left
}
//end of request
$itemsWorkType .= "</div>";
function workColumnContent ($Wording, $Translate, $workDescFields, $workInfos, $startIndex, $stopIndex ) {
$glassValueList = array('Tempered', 'Laminated');
$typeValueList = array('Fixe', 'Mobile');
$gabValueList = array('With', 'Without');
$columnContent = "<table class='tableFieldsWithBorders'>";
for ($i=$startIndex; $i< $stopIndex; $i++) {
$fieldLib = $Wording->getLibForField($workDescFields[$i]);
$fieldValue = $workInfos[$workDescFields[$i]];
//For the empty value we indicate a '-'
if ($fieldValue == '')
$fieldValue = '-';
switch ($workDescFields[$i]) {
case 'mtao_glass_nature':
$fieldValue = $glassValueList[$fieldValue];
break;
case 'mtao_glass_type':
$fieldValue = $typeValueList[$fieldValue];
break;
case 'mtao_gab_state':
$fieldValue = $gabValueList[$fieldValue];
break;
case 'mtao_begin_prod':
$fieldValue = preg_replace('#(\d{4})-(\d{2})-(\d{2})#', '$3/$2/$1', $fieldValue);
break;
}
$columnContent .= "<tr><td><div class='label'>".$this->_helper->DecodeTranslation($fieldLib)."</div></td>
<td><div class='value'>".$Translate->translate($fieldValue)."</div></td></tr>";
}
$columnContent .= "</table>";
return $columnContent ;
} |
Partager