forked from Wavyzz/dolibarr
FIX setup of default doc template for supplier proposal when none.
This commit is contained in:
@@ -169,6 +169,7 @@ if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Activate a model
|
// Activate a model
|
||||||
|
$reg = array();
|
||||||
if ($action == 'set') {
|
if ($action == 'set') {
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
} elseif ($action == 'del') {
|
} elseif ($action == 'del') {
|
||||||
@@ -179,9 +180,7 @@ if ($action == 'set') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'setdoc') {
|
} elseif ($action == 'setdoc') {
|
||||||
if (dolibarr_set_const($db, "SUPPLIER_PROPOSAL_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
|
dolibarr_set_const($db, "SUPPLIER_PROPOSAL_ADDON_PDF", empty($value) ? '' : $value, 'chaine', 0, '', $conf->entity);
|
||||||
$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On active le modele
|
// On active le modele
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
@@ -450,9 +449,10 @@ foreach ($dirmodels as $reldir) {
|
|||||||
// Default
|
// Default
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$name") {
|
if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$name") {
|
||||||
print img_picto($langs->trans("Default"), 'on');
|
//print img_picto($langs->trans("Default"), 'on');
|
||||||
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value=0&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Default"), 'on').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Disabled").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
|||||||
@@ -1961,11 +1961,13 @@ function version_webserver()
|
|||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param string $type Type of models (company, invoice, ...)
|
* @param string $type Type of models (company, invoice, ...)
|
||||||
* @param int $maxfilenamelength Max length of value to show
|
* @param int $maxfilenamelength Max length of value to show
|
||||||
|
* @param int $showempty Add an empty record if 1
|
||||||
* @return string[]|int<-1,0> 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename", -1 if error
|
* @return string[]|int<-1,0> 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename", -1 if error
|
||||||
*/
|
*/
|
||||||
function getListOfModels($db, $type, $maxfilenamelength = 0)
|
function getListOfModels($db, $type, $maxfilenamelength = 0, $showempty = 0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$liste = array();
|
$liste = array();
|
||||||
$found = 0;
|
$found = 0;
|
||||||
$dirtoscan = '';
|
$dirtoscan = '';
|
||||||
@@ -1973,19 +1975,30 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
|
|||||||
$sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description";
|
$sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||||
$sql .= " AND entity IN (0,".$conf->entity.")";
|
$sql .= " AND entity IN (0,".((int) $conf->entity).")";
|
||||||
$sql .= " ORDER BY description DESC";
|
$sql .= " ORDER BY description DESC";
|
||||||
|
|
||||||
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);
|
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);
|
||||||
|
|
||||||
$resql_models = $db->query($sql);
|
$resql_models = $db->query($sql);
|
||||||
if ($resql_models) {
|
if ($resql_models) {
|
||||||
$num = $db->num_rows($resql_models);
|
$num = $db->num_rows($resql_models);
|
||||||
|
|
||||||
|
if ($showempty) {
|
||||||
|
$liste[0] = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$found = 1;
|
$found = 1;
|
||||||
|
|
||||||
$obj = $db->fetch_object($resql_models);
|
$obj = $db->fetch_object($resql_models);
|
||||||
|
|
||||||
|
if ($obj->id == '0') { // We discard bad record (should not happen)
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// If this generation module needs to scan a directory, then description field is filled
|
// If this generation module needs to scan a directory, then description field is filled
|
||||||
// with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).
|
// with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).
|
||||||
if (!empty($obj->description)) { // A list of directories to scan is defined
|
if (!empty($obj->description)) { // A list of directories to scan is defined
|
||||||
@@ -2034,6 +2047,7 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
|
|||||||
$liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name;
|
$liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator
|
|||||||
$list = array();
|
$list = array();
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
$list = getListOfModels($db, $type, $maxfilenamelength);
|
$list = getListOfModels($db, $type, $maxfilenamelength, 1);
|
||||||
|
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2330,7 +2330,7 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then search ref, ref_ext or alias with a OR (+ restriction on is_client and is_supplier)
|
// Then search ref, ref_ext or alias with a OR (+ restriction on is_client and is_supplier)
|
||||||
dol_syslog("Thirdparty not found with profids search so we try ref, ref_ext or ref_alias search", LOG_DEBUG);
|
dol_syslog("Thirdparty not found with email search so we try ref, ref_ext or ref_alias search", LOG_DEBUG);
|
||||||
$sqlref = "";
|
$sqlref = "";
|
||||||
if ($ref) {
|
if ($ref) {
|
||||||
$sqlref .= " s.nom = '".$this->db->escape($ref)."'";
|
$sqlref .= " s.nom = '".$this->db->escape($ref)."'";
|
||||||
|
|||||||
@@ -295,6 +295,8 @@ if (empty($reshook)) {
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
$model_pdf = (GETPOST('model') != '0' && GETPOST('model') != '-1') ? GETPOST('model') : '';
|
||||||
|
|
||||||
// When a copy request was made, make the copy
|
// When a copy request was made, make the copy
|
||||||
if (GETPOST('createmode') == 'copy' && GETPOSTINT('copie_supplier_proposal') > 0) {
|
if (GETPOST('createmode') == 'copy' && GETPOSTINT('copie_supplier_proposal') > 0) {
|
||||||
if ($object->fetch(GETPOSTINT('copie_supplier_proposal')) > 0) {
|
if ($object->fetch(GETPOSTINT('copie_supplier_proposal')) > 0) {
|
||||||
@@ -306,7 +308,7 @@ if (empty($reshook)) {
|
|||||||
$object->fk_account = GETPOSTINT('fk_account');
|
$object->fk_account = GETPOSTINT('fk_account');
|
||||||
$object->socid = GETPOSTINT('socid');
|
$object->socid = GETPOSTINT('socid');
|
||||||
$object->fk_project = GETPOSTINT('projectid');
|
$object->fk_project = GETPOSTINT('projectid');
|
||||||
$object->model_pdf = GETPOST('model');
|
$object->model_pdf = $model_pdf;
|
||||||
$object->author = $user->id; // deprecated
|
$object->author = $user->id; // deprecated
|
||||||
$object->user_creation_id = $user->id;
|
$object->user_creation_id = $user->id;
|
||||||
$object->note = GETPOST('note', 'restricthtml');
|
$object->note = GETPOST('note', 'restricthtml');
|
||||||
@@ -325,7 +327,7 @@ if (empty($reshook)) {
|
|||||||
$object->mode_reglement_id = GETPOSTINT('mode_reglement_id');
|
$object->mode_reglement_id = GETPOSTINT('mode_reglement_id');
|
||||||
$object->fk_account = GETPOSTINT('fk_account');
|
$object->fk_account = GETPOSTINT('fk_account');
|
||||||
$object->fk_project = GETPOSTINT('projectid');
|
$object->fk_project = GETPOSTINT('projectid');
|
||||||
$object->model_pdf = GETPOST('model');
|
$object->model_pdf = $model_pdf;
|
||||||
$object->author = $user->id; // deprecated
|
$object->author = $user->id; // deprecated
|
||||||
$object->user_creation_id = $user->id;
|
$object->user_creation_id = $user->id;
|
||||||
$object->note = GETPOST('note', 'restricthtml');
|
$object->note = GETPOST('note', 'restricthtml');
|
||||||
@@ -351,6 +353,7 @@ if (empty($reshook)) {
|
|||||||
if ($origin && $originid) {
|
if ($origin && $originid) {
|
||||||
// Parse element/subelement (ex: project_task)
|
// Parse element/subelement (ex: project_task)
|
||||||
$element = $subelement = $origin;
|
$element = $subelement = $origin;
|
||||||
|
$regs = array();
|
||||||
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
|
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
|
||||||
$element = $regs[1];
|
$element = $regs[1];
|
||||||
$subelement = $regs[2];
|
$subelement = $regs[2];
|
||||||
@@ -375,10 +378,11 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$object->origin = $origin;
|
$object->origin = $origin;
|
||||||
|
$object->origin_type = $origin;
|
||||||
$object->origin_id = $originid;
|
$object->origin_id = $originid;
|
||||||
|
|
||||||
// Possibility to add external linked objects with hooks
|
// Possibility to add external linked objects with hooks
|
||||||
$object->linked_objects [$object->origin] = $object->origin_id;
|
$object->linked_objects [$object->origin_type] = $object->origin_id;
|
||||||
if (GETPOSTISARRAY('other_linked_objects')) {
|
if (GETPOSTISARRAY('other_linked_objects')) {
|
||||||
$object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int'));
|
$object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int'));
|
||||||
}
|
}
|
||||||
@@ -391,7 +395,7 @@ if (empty($reshook)) {
|
|||||||
$srcobject = new $classname($db);
|
$srcobject = new $classname($db);
|
||||||
'@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject'; // Maybe other class but CommonObject is too generic
|
'@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject'; // Maybe other class but CommonObject is too generic
|
||||||
|
|
||||||
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
|
dol_syslog("Try to find source object origin=".$object->origin_type." originid=".$object->origin_id." to add lines");
|
||||||
$result = $srcobject->fetch($object->origin_id);
|
$result = $srcobject->fetch($object->origin_id);
|
||||||
|
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
@@ -502,10 +506,12 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
$model = $object->model_pdf;
|
$model = $object->model_pdf;
|
||||||
|
|
||||||
$ret = $object->fetch($id); // Reload to get new records
|
if (!empty($model)) {
|
||||||
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$ret = $object->fetch($id); // Reload to get new records
|
||||||
if ($result < 0) {
|
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
dol_print_error($db, $object->error, $object->errors);
|
if ($result < 0) {
|
||||||
|
dol_print_error($db, $object->error, $object->errors);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1390,7 +1396,7 @@ if ($action == 'create') {
|
|||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
print img_picto('', 'pdf', 'class="pictofixedwidth"');
|
print img_picto('', 'pdf', 'class="pictofixedwidth"');
|
||||||
$list = ModelePDFSupplierProposal::liste_modeles($db);
|
$list = ModelePDFSupplierProposal::liste_modeles($db);
|
||||||
$preselected = (getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT') ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF);
|
$preselected = getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT', getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF'));
|
||||||
print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
|
print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
@@ -1705,7 +1711,7 @@ if ($action == 'create') {
|
|||||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||||
print $langs->trans('PaymentConditionsShort');
|
print $langs->trans('PaymentConditionsShort');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if ($action != 'editconditions' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) {
|
if ($action != 'editconditions' && $object->status != SupplierProposal::STATUS_NOTSIGNED) {
|
||||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'</a></td>';
|
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'</a></td>';
|
||||||
}
|
}
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
@@ -1724,7 +1730,7 @@ if ($action == 'create') {
|
|||||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||||
print $langs->trans('DeliveryDate');
|
print $langs->trans('DeliveryDate');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if ($action != 'editdate_livraison' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) {
|
if ($action != 'editdate_livraison' && $object->status != SupplierProposal::STATUS_NOTSIGNED) {
|
||||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'), 1).'</a></td>';
|
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'), 1).'</a></td>';
|
||||||
}
|
}
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
@@ -1749,7 +1755,7 @@ if ($action == 'create') {
|
|||||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||||
print $langs->trans('PaymentMode');
|
print $langs->trans('PaymentMode');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if ($action != 'editmode' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) {
|
if ($action != 'editmode' && $object->status != SupplierProposal::STATUS_NOTSIGNED) {
|
||||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'</a></td>';
|
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'</a></td>';
|
||||||
}
|
}
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
|
|||||||
Reference in New Issue
Block a user