/** * Function: show_custom_field * * If a custom field has been defined then show it in the add,edit, or view invoice screen. This is used for the Invoice Custom Fields - may be used for the others as wll based on the situation * * Parameters: * custom_field - the db name of the custom field ie invoice_cf1 * custom_field_value - the value of this custom field for a given invoice * permission - the permission level - ie. in a print view its gets a read level, in an edit or add screen its write leve * css_class_tr - the css class the the table row (tr) * css_class1 - the css class of the first td * css_class2 - the css class of the second td * td_col_span - the column span of the right td * seperator - used in the print view ie. adding a : between the 2 values * * Returns: * Depending on the permission passed, either a formatted input box and the label of the custom field or a table row and data **/ function show_custom_field($custom_field, $custom_field_value, $permission, $css_class_tr, $css_class1, $css_class2, $td_col_span, $seperator) { $domain_id = domain_id::get(); # get the last character of the $custom field - used to set the name of the field $custom_field_number = substr($custom_field, -1, 1); #get the label for the custom field $display_block = ""; $get_custom_label = "SELECT cf_custom_label FROM " . TB_PREFIX . "custom_fields WHERE cf_custom_field = :field AND domain_id = :domain_id"; $sth = dbQuery($get_custom_label, ':field', $custom_field, ':domain_id', $domain_id); while ($Array_cl = $sth->fetch()) { $has_custom_label_value = $Array_cl['cf_custom_label']; } /*if permision is write then coming from a new invoice screen show show only the custom field and have a label * if custom_field_value !null coming from existing invoice so show only the cf that they actually have */ if ($has_custom_label_value != null and $permission == "write" or $custom_field_value != null) { $custom_label_value = htmlsafe(get_custom_field_label($custom_field)); if ($permission == "read") { $display_block = <<<EOD \t\t\t<tr class="{$css_class_tr}" > \t\t\t\t<th class="{$css_class1}"> \t\t\t\t\t{$custom_label_value}{$seperator} \t\t\t\t</th> \t\t\t\t<td class="{$css_class2}" colspan="{$td_col_span}" > \t\t\t\t\t{$custom_field_value} \t\t\t\t</td> \t\t\t</tr> EOD; } else { if ($permission == "write") { $display_block = <<<EOD \t\t\t<tr> \t\t\t\t<th class="{$css_class1}">{$custom_label_value} \t\t\t\t\t<a class="cluetip" href="#"\trel="index.php?module=documentation&view=view&page=help_custom_fields" title="Custom Fields"><img src="./images/common/help-small.png" alt="" /></a> \t\t\t\t</th> \t\t\t\t<td> \t\t\t\t\t<input type="text" name="customField{$custom_field_number}" value="{$custom_field_value}" size="25" /> \t\t\t\t</td> \t\t\t</tr> EOD; } } } return $display_block; }
/** * Function: show_custom_field * * If a custom field has been defined then show it in the add,edit, or view invoice screen. This is used for the Invoice Custom Fields - may be used for the others as wll based on the situation * * Parameters: * custom_field - the db name of the custom field ie invoice_cf1 * custom_field_value - the value of this custom field for a given invoice * permission - the permission level - ie. in a print view its gets a read level, in an edit or add screen its write leve * css_class_tr - the css class the the table row (tr) * css_class1 - the css class of the first td * css_class2 - the css class of the second td * td_col_span - the column span of the right td * seperator - used in the print view ie. adding a : between the 2 values * * Returns: * Depending on the permission passed, either a formatted input box and the label of the custom field or a table row and data **/ function show_custom_field($custom_field,$custom_field_value,$permission,$css_class_tr,$css_class1,$css_class2,$td_col_span,$seperator) { global $dbh; /* *get the last character of the $custom field - used to set the name of the field */ $custom_field_number = substr($custom_field, -1, 1); #get the label for the custom field $display_block = ""; $get_custom_label ="SELECT cf_custom_label FROM ".TB_PREFIX."custom_fields WHERE cf_custom_field = :field"; $sth = dbQuery($get_custom_label, ':field', $custom_field) or die(end($dbh->errorInfo())); while ($Array_cl = $sth->fetch()) { $has_custom_label_value = $Array_cl['cf_custom_label']; } /*if permision is write then coming from a new invoice screen show show only the custom field and have a label * if custom_field_value !null coming from existing invoice so show only the cf that they actually have */ if ( (($has_custom_label_value != null) AND ( $permission == "write")) OR ($custom_field_value != null)) { $custom_label_value = htmlsafe(get_custom_field_label($custom_field)); if ($permission == "read") { $display_block = <<<EOD <tr class="$css_class_tr" > <td class="$css_class1"> $custom_label_value$seperator </td> <td class="$css_class2" colspan="$td_col_span" > $custom_field_value </td> </tr> EOD; } else if ($permission == "write") { $display_block = <<<EOD <tr> <td class="$css_class1">$custom_label_value <a class="cluetip" href="#" rel="index.php?module=documentation&view=view&page=help_custom_fields" title="Custom Fields"><img src="./images/common/help-small.png" alt="" /></a> </td> <td> <input type="text" name="customField$custom_field_number" value="$custom_field_value" size="25" /> </td> </tr> EOD; } } return $display_block; }