Rename field documentpdf into printable (this field already exists due

to a very old PR nofinished for same goal).
This commit is contained in:
Laurent Destailleur 2020-02-23 23:03:17 +01:00
parent 90565e4637
commit ca39c680c7
8 changed files with 30 additions and 27 deletions

View File

@ -184,7 +184,7 @@ if ($action == 'add')
GETPOST('langfile', 'alpha'),
1,
(GETPOST('totalizable', 'alpha')?1:0),
(GETPOST('documentpdf', 'alpha')?1:0)
(GETPOST('printable', 'alpha')?1:0)
);
if ($result > 0)
{
@ -354,7 +354,7 @@ if ($action == 'update')
GETPOST('langfile'),
1,
(GETPOST('totalizable', 'alpha')?1:0),
(GETPOST('documentpdf', 'alpha')?1:0)
(GETPOST('printable', 'alpha')?1:0)
);
if ($result > 0)
{

View File

@ -1213,7 +1213,7 @@ abstract class CommonDocGenerator
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
{
// Enable extrafield ?
$enabled = !empty($extrafields->attributes[$object->table_element]['documentpdf'][$key]);
$enabled = !empty($extrafields->attributes[$object->table_element]['printable'][$key]);
if(empty($enabled)){
continue;
@ -1425,7 +1425,7 @@ abstract class CommonDocGenerator
}
// Enable extrafield ?
$enabled = !empty($extrafields->attributes[$object->table_element]['documentpdf'][$key]);
$enabled = !empty($extrafields->attributes[$object->table_element]['printable'][$key]);
// Load language if required

View File

@ -225,10 +225,10 @@ class ExtraFields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
* @param int $totalizable Is a measure. Must show a total on lists
* @param int $documentpdf Is extrafield displayed on PDF
* @param int $printable Is extrafield displayed on PDF
* @return int <=0 if KO, >0 if OK
*/
public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $documentpdf = 0)
public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
{
if (empty($attrname)) return -1;
if (empty($label)) return -1;
@ -246,7 +246,7 @@ class ExtraFields
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate')
{
// Add declaration of field into table
$result2 = $this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled, $totalizable, $documentpdf);
$result2 = $this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled, $totalizable, $printable);
$err2 = $this->errno;
if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS'))
{
@ -375,11 +375,11 @@ class ExtraFields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
* @param int $totalizable Is a measure. Must show a total on lists
* @param int $documentpdf Is extrafield displayed on PDF
* @param int $printable Is extrafield displayed on PDF
* @return int <=0 if KO, >0 if OK
* @throws Exception
*/
private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $documentpdf = 0)
private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
{
// phpcs:enable
global $conf, $user;
@ -424,7 +424,7 @@ class ExtraFields
$sql .= " perms,";
$sql .= " langs,";
$sql .= " list,";
$sql .= " documentpdf,";
$sql .= " printable,";
$sql .= " fielddefault,";
$sql .= " fieldcomputed,";
$sql .= " fk_user_author,";
@ -448,7 +448,7 @@ class ExtraFields
$sql .= " ".($perms ? "'".$this->db->escape($perms)."'" : "null").",";
$sql .= " ".($langfile ? "'".$this->db->escape($langfile)."'" : "null").",";
$sql .= " '".$this->db->escape($list)."',";
$sql .= " '".$this->db->escape($documentpdf)."',";
$sql .= " '".$this->db->escape($printable)."',";
$sql .= " ".($default ? "'".$this->db->escape($default)."'" : "null").",";
$sql .= " ".($computed ? "'".$this->db->escape($computed)."'" : "null").",";
$sql .= " ".(is_object($user) ? $user->id : 0).",";
@ -595,11 +595,11 @@ class ExtraFields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
* @param int $totalizable Is extrafield totalizable on list
* @param int $documentpdf Is extrafield displayed on PDF
* @param int $printable Is extrafield displayed on PDF
* @return int >0 if OK, <=0 if KO
* @throws Exception
*/
public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $documentpdf = 0)
public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
{
if ($elementtype == 'thirdparty') $elementtype = 'societe';
if ($elementtype == 'contact') $elementtype = 'socpeople';
@ -649,7 +649,7 @@ class ExtraFields
{
if ($label)
{
$result = $this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable, $documentpdf);
$result = $this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable, $printable);
}
if ($result > 0)
{
@ -707,15 +707,15 @@ class ExtraFields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
* @param int $totalizable Is extrafield totalizable on list
* @param int $documentpdf Is extrafield displayed on PDF
* @param int $printable Is extrafield displayed on PDF
* @return int <=0 if KO, >0 if OK
* @throws Exception
*/
private function update_label($attrname, $label, $type, $size, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '0', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $documentpdf = 0)
private function update_label($attrname, $label, $type, $size, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '0', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
{
// phpcs:enable
global $conf, $user;
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled.", ".$totalizable.", ".$documentpdf);
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled.", ".$totalizable.", ".$printable);
// Clean parameters
if ($elementtype == 'thirdparty') $elementtype = 'societe';
@ -780,7 +780,7 @@ class ExtraFields
$sql .= " alwayseditable,";
$sql .= " param,";
$sql .= " list,";
$sql .= " documentpdf,";
$sql .= " printable,";
$sql .= " totalizable,";
$sql .= " fielddefault,";
$sql .= " fieldcomputed,";
@ -804,7 +804,7 @@ class ExtraFields
$sql .= " '".$this->db->escape($alwayseditable)."',";
$sql .= " '".$this->db->escape($params)."',";
$sql .= " '".$this->db->escape($list)."', ";
$sql .= " '".$this->db->escape($documentpdf)."', ";
$sql .= " '".$this->db->escape($printable)."', ";
$sql .= " ".$totalizable.",";
$sql .= " ".(($default != '') ? "'".$this->db->escape($default)."'" : "null").",";
$sql .= " ".($computed ? "'".$this->db->escape($computed)."'" : "null").",";
@ -882,7 +882,7 @@ class ExtraFields
}*/
// We should not have several time this request. If we have, there is some optimization to do by calling a simple $extrafields->fetch_optionals() in top of code and not into subcode
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,documentpdf,totalizable,fielddefault,fieldcomputed,entity,enabled,help";
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,printable,totalizable,fielddefault,fieldcomputed,entity,enabled,help";
$sql .= " FROM ".MAIN_DB_PREFIX."extrafields";
//$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later
if ($elementtype) $sql .= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element
@ -944,7 +944,7 @@ class ExtraFields
$this->attributes[$tab->elementtype]['perms'][$tab->name] = (strlen($tab->perms) == 0 ? 1 : $tab->perms);
$this->attributes[$tab->elementtype]['langfile'][$tab->name] = $tab->langs;
$this->attributes[$tab->elementtype]['list'][$tab->name] = $tab->list;
$this->attributes[$tab->elementtype]['documentpdf'][$tab->name] = $tab->documentpdf;
$this->attributes[$tab->elementtype]['printable'][$tab->name] = $tab->printable;
$this->attributes[$tab->elementtype]['totalizable'][$tab->name] = $tab->totalizable;
$this->attributes[$tab->elementtype]['entityid'][$tab->name] = $tab->entity;
$this->attributes[$tab->elementtype]['enabled'][$tab->name] = $tab->enabled;

View File

@ -198,7 +198,7 @@ $langs->load("modulebuilder");
</td><td class="valeur"><input id="list" class="minwidth100" type="text" name="list" value="<?php echo GETPOST('list', 'int')!='' ? GETPOST('list', 'int') : '1'; ?>"></td></tr>
<!-- Visibility for PDF-->
<tr><td class="extra_pdf"><?php echo $form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
</td><td class="valeur"><input id="documentpdf" type="checkbox" name="documentpdf"<?php echo GETPOST('documentpdf', 'alpha')?' checked':''; ?>></td></tr>
</td><td class="valeur"><input id="printable" type="checkbox" name="printable"<?php echo GETPOST('printable', 'alpha')?' checked':''; ?>></td></tr>
<!-- Totalizable -->
<tr class="extra_totalizable"><td><?php echo $langs->trans("Totalizable"); ?></td><td class="valeur"><input id="totalizable" type="checkbox" name="totalizable"<?php echo ((GETPOST('totalizable', 'alpha') || GETPOST('button', 'alpha'))?' checked':''); ?>></td></tr>
<!-- Help tooltip -->

View File

@ -165,7 +165,7 @@ $list=$extrafields->attributes[$elementtype]['list'][$attrname];
$totalizable = $extrafields->attributes[$elementtype]['totalizable'][$attrname];
$help=$extrafields->attributes[$elementtype]['help'][$attrname];
$entitycurrentorall=$extrafields->attributes[$elementtype]['entityid'][$attrname];
$documentpdf=$extrafields->attributes[$elementtype]['documentpdf'][$attrname];
$printable=$extrafields->attributes[$elementtype]['printable'][$attrname];
if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param))
{
@ -267,7 +267,7 @@ else
</td><td class="valeur"><input id="list" class="minwidth100" type="text" name="list" value="<?php echo ($list!=''?$list:'1'); ?>"></td></tr>
<!-- Visibility for PDF-->
<tr><td class="extra_pdf"><?php echo $form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
</td><td class="valeur"><input id="documentpdf" type="checkbox" name="documentpdf"<?php echo !empty($documentpdf)?' checked':''; ?>></td></tr>
</td><td class="valeur"><input id="printable" type="checkbox" name="printable"<?php echo !empty($printable)?' checked':''; ?>></td></tr>
<tr class="extra_totalizable"><td><?php echo $form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?></td><td class="valeur"><input id="totalizable" type="checkbox" name="totalizable"<?php echo ($totalizable?' checked':''); ?>></td></tr>
<!-- Help tooltip -->
<tr class="help"><td><?php echo $form->textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?></td><td class="valeur"><input id="help" class="quatrevingtpercent" type="text" name="help" value="<?php echo dol_escape_htmltag($help); ?>"></td></tr>

View File

@ -93,7 +93,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
print '<td class="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n";
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['documentpdf'][$key])."</td>\n";
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['printable'][$key])."</td>\n";
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
if (! empty($conf->multicompany->enabled)) {
print '<td class="center">';

View File

@ -181,4 +181,7 @@ INSERT INTO llx_c_ticket_resolution (code, pos, label, active, use_default, desc
DELETE FROM llx_const WHERE name = __ENCRYPT('DONATION_ART885')__;
ALTER TABLE llx_extrafields ADD COLUMN documentpdf integer DEFAULT 0;
ALTER TABLE llx_extrafields MODIFY COLUMN printable integer DEFAULT 0;
ALTER TABLE llx_extrafields ADD COLUMN printable integer DEFAULT 0;

View File

@ -36,7 +36,7 @@ create table llx_extrafields
alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status
param text, -- extra parameters to define possible values of field
list varchar(255) DEFAULT '1', -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing
printable boolean DEFAULT FALSE, -- is the extrafield output on documents
printable integer DEFAULT 0, -- is the extrafield output on documents
totalizable boolean DEFAULT FALSE, -- is extrafield totalizable on list
langs varchar(64), -- example: fileofmymodule@mymodule
help text, -- to store help tooltip