diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 1c63189db0e..4b51a519223 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1121,7 +1121,8 @@ if ($object->id > 0) { * Latest contracts */ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity"; + $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity,"; + $sql .= " c.last_main_doc, c.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " AND s.rowid = ".((int) $object->id); @@ -1154,6 +1155,8 @@ if ($object->id > 0) { $contrat->ref_customer = $objp->refcus; $contrat->ref_supplier = $objp->refsup; $contrat->statut = $objp->contract_status; + $contrat->last_main_doc = $objp->last_main_doc; + $contrat->model_pdf = $objp->model_pdf; $contrat->fetch_lines(); $late = ''; @@ -1168,30 +1171,32 @@ if ($object->id > 0) { print ''; print ''; print $contrat->getNomUrl(1, 12); - // Preview - $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); - $file_list = null; - if (!empty($filedir)) { - $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); - } - if (is_array($file_list)) { - // Defined relative dir to DOL_DATA_ROOT - $relativedir = ''; - if ($filedir) { - $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir); - $relativedir = preg_replace('/^[\\/]/', '', $relativedir); + if (!empty($contrat->model_pdf)) { + // Preview + $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); + $file_list = null; + if (!empty($filedir)) { + $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); } - // Get list of files stored into database for same relative directory - if ($relativedir) { - completeFileArrayWithDatabaseInfo($file_list, $relativedir); - - //var_dump($sortfield.' - '.$sortorder); - if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) - $file_list = dol_sort_array($file_list, $sortfield, $sortorder); + if (is_array($file_list)) { + // Defined relative dir to DOL_DATA_ROOT + $relativedir = ''; + if ($filedir) { + $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir); + $relativedir = preg_replace('/^[\\/]/', '', $relativedir); } + // Get list of files stored into database for same relative directory + if ($relativedir) { + completeFileArrayWithDatabaseInfo($file_list, $relativedir); + + //var_dump($sortfield.' - '.$sortorder); + if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) + $file_list = dol_sort_array($file_list, $sortfield, $sortorder); + } + } + $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; + print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0); } - $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; - print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0); } // $filename = dol_sanitizeFileName($objp->ref); // $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5243a76c9fb..a66c9b895b7 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -669,6 +669,7 @@ if (!$error && $massaction == 'confirm_presend') { } } + if (!$error && $massaction == 'cancelorders') { $db->begin(); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0beb68c080c..097d670e8ea 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -806,7 +806,7 @@ if ($action == 'create' && $user->rights->projet->creer) { if ($action == 'clone') { $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200 maxwidth250')), array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), @@ -815,7 +815,7 @@ if ($action == 'create' && $user->rights->projet->creer) { array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) ); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 400, 590); } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 2fb9285379f..c57f1ac00da 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -51,19 +51,15 @@ $formcompany = new FormCompany($db); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setcodeclient') { - if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } if ($action == 'setcodecompta') { - if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -273,10 +269,8 @@ if ($action == 'setprofid') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_UNIQUE"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -286,10 +280,8 @@ if ($action == 'setprofidmandatory') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_MANDATORY"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -299,10 +291,8 @@ if ($action == 'setprofidinvoicemandatory') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -311,10 +301,8 @@ if ($action == 'setprofidinvoicemandatory') { if ($action == 'sethideinactivethirdparty') { $status = GETPOST('status', 'alpha'); - if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -331,6 +319,7 @@ if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { } } + /* * View */ @@ -575,7 +564,7 @@ foreach ($dirsociete as $dirroot) { if ($modulequalified) { print ''; - print $module->name; + print dol_escape_htmltag($module->name); print "\n"; if (method_exists($module, 'info')) { print $module->info($langs); @@ -589,7 +578,7 @@ foreach ($dirsociete as $dirroot) { print "\n"; //if ($conf->global->COMPANY_ADDON_PDF != "$name") //{ - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; //} @@ -605,7 +594,7 @@ foreach ($dirsociete as $dirroot) { print ""; } else { print ''."\n"; - print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print ""; } } @@ -626,7 +615,7 @@ foreach ($dirsociete as $dirroot) { // Preview print ''; if ($module->type == 'pdf') { - $linkspec = ''.img_object($langs->trans("Preview"), 'pdf').''; + $linkspec = ''.img_object($langs->trans("Preview"), 'pdf').''; } else { $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic'); }