Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into generateDocInMB

This commit is contained in:
Lamrani Abdel 2023-03-18 14:56:34 +01:00
commit 85916bfb64
27 changed files with 524 additions and 317 deletions

View File

@ -2400,6 +2400,20 @@ if ($id > 0) {
print '</td></tr>';
}
//mail information
if (!empty($object->email_msgid)) {
print '<tr><td>'.$langs->trans('MailTopic').'</td>';
print '<td>'.dol_escape_htmltag($object->email_subject).'</td></tr>';
print '<tr><td>'.$langs->trans('MailFrom').'</td>';
print '<td>'.dol_escape_htmltag($object->email_from).'</td></tr>';
print '<tr><td>'.$langs->trans('MailTo').'</td>';
print '<td>'.dol_escape_htmltag($object->email_to).'</td></tr>';
if (!empty($object->email_tocc)) {
print '<tr><td>'.$langs->trans('MailCC').'</td>';
print '<td>'.dol_escape_htmltag($object->email_tocc).'</td></tr>';
}
}
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td class="wordbreak">';
print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));

View File

@ -79,6 +79,7 @@ $cancel = GETPOST('cancel', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int');
@ -1774,6 +1775,7 @@ if ($action == 'create') {
print '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($origin != 'project' && $originid) {
print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">';
@ -2449,6 +2451,7 @@ if ($action == 'create') {
print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->date, 're', '', '', 0, "editdate");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
@ -2476,6 +2479,7 @@ if ($action == 'create') {
print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setecheance">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
@ -2836,6 +2840,7 @@ if ($action == 'create') {
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="page_y" value="">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
<input type="hidden" name="id" value="' . $object->id.'">
';

View File

@ -3708,6 +3708,7 @@ class Propal extends CommonObject
global $conf, $langs, $user;
$datas = [];
$nofetch = !empty($params['nofetch']);
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
return ['optimize' => $langs->trans("Proposal")];
@ -3720,9 +3721,25 @@ class Propal extends CommonObject
if (!empty($this->ref)) {
$datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
}
if (!$nofetch) {
$langs->load('companies');
if (empty($this->thirdparty)) {
$this->fetch_thirdparty();
}
$datas['customer'] = '<br><b>'.$langs->trans('Customer').':</b> '.$this->thirdparty->getNomUrl(1, '', 0, 1);
}
if (!empty($this->ref_client)) {
$datas['refcustomer'] = '<br><b>'.$langs->trans('RefCustomer').':</b> '.$this->ref_client;
}
if (!$nofetch) {
$langs->load('project');
if (empty($this->project)) {
$res = $this->fetch_project();
if ($res > 0) {
$datas['project'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}
}
if (!empty($this->total_ht)) {
$datas['amountht'] = '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
}
@ -3767,6 +3784,7 @@ class Propal extends CommonObject
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';

View File

@ -84,6 +84,8 @@ $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int');
@ -1755,6 +1757,7 @@ if ($action == 'create' && $usercancreate) {
print '<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.'">';
print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if (!empty($currency_tx)) {
print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">';
}
@ -2449,6 +2452,7 @@ if ($action == 'create' && $usercancreate) {
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->date, 'order_', '', '', '', "setdate");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
@ -2470,6 +2474,7 @@ if ($action == 'create' && $usercancreate) {
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate_livraison">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->delivery_date ? $object->delivery_date : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0);
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
@ -2763,7 +2768,9 @@ if ($action == 'create' && $usercancreate) {
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="page_y" value="">
<input type="hidden" name="id" value="' . $object->id.'">';
<input type="hidden" name="id" value="' . $object->id.'">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
';
if (!empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
@ -2991,7 +2998,7 @@ if ($action == 'create' && $usercancreate) {
// Presend form
$modelmail = 'order_send';
$defaulttopic = 'SendOrderRef';
$diroutput = $conf->commande->multidir_output[$object->entity];
$diroutput = getMultidirOutput($object);
$trackid = 'ord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';

View File

@ -3728,6 +3728,7 @@ class Commande extends CommonOrder
global $conf, $langs, $user;
$datas = [];
$nofetch = !empty($params['nofetch']);
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
return ['optimize' => $langs->trans("Order")];
@ -3739,7 +3740,23 @@ class Commande extends CommonOrder
$datas[] = ' '.$this->getLibStatut(5);
}
$datas['Ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (!$nofetch) {
$langs->load('companies');
if (empty($this->thirdparty)) {
$this->fetch_thirdparty();
}
$datas['customer'] = '<br><b>'.$langs->trans('Customer').':</b> '.$this->thirdparty->getNomUrl(1, '', 0, 1);
}
$datas['RefCustomer'] = '<br><b>'.$langs->trans('RefCustomer').':</b> '.(empty($this->ref_customer) ? (empty($this->ref_client) ? '' : $this->ref_client) : $this->ref_customer);
if (!$nofetch) {
$langs->load('project');
if (empty($this->project)) {
$res = $this->fetch_project();
if ($res > 0) {
$datas['project'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}
}
if (!empty($this->total_ht)) {
$datas['AmountHT'] = '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
}
@ -3811,6 +3828,7 @@ class Commande extends CommonOrder
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
@ -3960,6 +3978,7 @@ class Commande extends CommonOrder
$this->id = 0;
$this->ref = 'SPECIMEN';
$this->specimen = 1;
$this->entity = $conf->entity;
$this->socid = 1;
$this->date = time();
$this->date_lim_reglement = $this->date + 3600 * 24 * 30;

View File

@ -86,6 +86,8 @@ $socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$lineid = GETPOST('lineid', 'int');
$userid = GETPOST('userid', 'int');
$search_ref = GETPOST('sf_ref', 'alpha') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
@ -3153,6 +3155,8 @@ if ($action == 'create') {
if ($soc->id > 0) {
print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
}
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input name="ref" type="hidden" value="provisoire">';
print '<input name="ref_client" type="hidden" value="'.$ref_client.'">';
print '<input name="force_cond_reglement_id" type="hidden" value="0">';
@ -4688,6 +4692,7 @@ if ($action == 'create') {
print '<form id="retained-warranty-form" method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarranty">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input name="retained_warranty" type="number" step="0.01" min="0" max="100" value="'.$object->retained_warranty.'" >';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>';
@ -4717,6 +4722,7 @@ if ($action == 'create') {
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarrantyconditions">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
$retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement;
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID;
@ -4752,6 +4758,7 @@ if ($action == 'create') {
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'">';
print '<input type="hidden" name="action" value="setretainedwarrantydatelimit">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input name="retained_warranty_date_limit" type="date" step="1" min="'.dol_print_date($object->date, '%Y-%m-%d').'" value="'.dol_print_date($defaultDate, '%Y-%m-%d').'" >';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>';
@ -4832,6 +4839,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setrevenuestamp">';
print '<input type="hidden" name="revenuestamp" id="revenuestamp_val" value="'.price2num($object->revenuestamp).'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $formother->select_revenue_stamp('', 'revenuestamp_type', $mysoc->country_code);
print ' &rarr; <span id="revenuestamp_span"></span>';
print ' <input type="submit" class="button buttongen button-save" value="'.$langs->trans('Modify').'">';
@ -5371,6 +5379,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'" />';
print '<input type="hidden" name="action" value="updatealllines" />';
print '<input type="hidden" name="id" value="'.$object->id.'" />';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<table id="tablelines_all_progress" class="noborder noshadow" width="100%">';
@ -5409,6 +5418,7 @@ if ($action == 'create') {
<input type="hidden" name="mode" value="">
<input type="hidden" name="page_y" value="">
<input type="hidden" name="id" value="' . $object->id.'">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
';
if (!empty($conf->use_javascript_ajax) && $object->statut == 0) {

View File

@ -56,6 +56,7 @@ $langs->loadLangs(array("contracts", "orders", "companies", "bills", "products",
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$socid = GETPOST('socid', 'int');
$id = GETPOST('id', 'int');
@ -1135,10 +1136,10 @@ if ($action == 'create') {
print '<form name="form_contract" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
print '<input type="hidden" name="remise_percent" value="0">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head();
@ -1350,6 +1351,7 @@ if ($action == 'create') {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setremise">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
}
// Contract card
@ -1490,6 +1492,7 @@ if ($action == 'create') {
print '<form name="update" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updateline">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="elrowid" value="'.$object->lines[$cursorline - 1]->id.'">';
print '<input type="hidden" name="fournprice" value="'.(!empty($object->lines[$cursorline - 1]->fk_fournprice) ? $object->lines[$cursorline - 1]->fk_fournprice : 0).'">';
@ -1914,6 +1917,7 @@ if ($action == 'create') {
print '<form name="active" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="confirm_active">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="ligne" value="'.GETPOST('ligne', 'int').'">';
print '<input type="hidden" name="confirm" value="yes">';
@ -1973,6 +1977,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="confirm" value="yes">';
print '<input type="hidden" name="action" value="confirm_closeline">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ? ' boxtablenobottom' : '').'" width="100%">';
@ -2038,6 +2043,7 @@ if ($action == 'create') {
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="'.$object->id.'">
<input type="hidden" name="page_y" value="">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
';
print '<div class="div-table-responsive-no-min">';

View File

@ -1995,6 +1995,7 @@ class Contrat extends CommonObject
$langs->load('contracts');
$datas = [];
$nofetch = !empty($params['nofetch']);
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
return ['optimize' => $langs->trans("ShowContract")];
@ -2006,7 +2007,23 @@ class Contrat extends CommonObject
$label .= ' '.$this->getLibStatut(5);
}*/
$datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.($this->ref ? $this->ref : $this->id);
if (!$nofetch) {
$langs->load('companies');
if (empty($this->thirdparty)) {
$this->fetch_thirdparty();
}
$datas['customer'] = '<br><b>'.$langs->trans('Customer').':</b> '.$this->thirdparty->getNomUrl(1, '', 0, 1);
}
$datas['refcustomer'] = '<br><b>'.$langs->trans('RefCustomer').':</b> '. $this->ref_customer;
if (!$nofetch) {
$langs->load('project');
if (empty($this->project)) {
$res = $this->fetch_project();
if ($res > 0) {
$datas['project'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}
}
$datas['refsupplier'] = '<br><b>'.$langs->trans('RefSupplier').':</b> '.$this->ref_supplier;
if (!empty($this->total_ht)) {
$datas['amountht'] = '<br><b>'.$langs->trans('AmountHT').':</b> '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
@ -2052,6 +2069,7 @@ class Contrat extends CommonObject
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'nofetch' => 1,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';

View File

@ -5496,171 +5496,165 @@ abstract class CommonObject
$parameters = array('modelspath'=>$modelspath, 'modele'=>$modele, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'hidedesc'=>$hidedesc, 'hideref'=>$hideref, 'moreparams'=>$moreparams);
$reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
if (!empty($reshook)) {
return $reshook;
}
if (empty($modele)) {
$this->error = 'BadValueForParameterModele';
return -1;
}
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
// Increase limit for PDF build
$err = error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
if (empty($modele)) {
$this->error = 'BadValueForParameterModele';
return -1;
}
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// Increase limit for PDF build
$err = error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
// Search template files
$file = '';
$classname = '';
$filefound = '';
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('doc', 'pdf') as $prefix) {
if (in_array(get_class($this), array('Adherent'))) {
// Member module use prefix_modele.class.php
$file = $prefix."_".$modele.".class.php";
} else {
// Other module use prefix_modele.modules.php
$file = $prefix."_".$modele.".modules.php";
}
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
$tmp = explode(':', $modele, 2);
if (!empty($tmp[1])) {
$modele = $tmp[0];
$srctemplatepath = $tmp[1];
}
// On verifie l'emplacement du modele
$file = dol_buildpath($reldir.$modelspath.$file, 0);
if (file_exists($file)) {
$filefound = $file;
$classname = $prefix.'_'.$modele;
break;
}
// Search template files
$file = '';
$classname = '';
$filefound = '';
$dirmodels = array('/');
if (is_array($conf->modules_parts['models'])) {
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
}
foreach ($dirmodels as $reldir) {
foreach (array('doc', 'pdf') as $prefix) {
if (in_array(get_class($this), array('Adherent'))) {
// Member module use prefix_modele.class.php
$file = $prefix."_".$modele.".class.php";
} else {
// Other module use prefix_modele.modules.php
$file = $prefix."_".$modele.".modules.php";
}
if ($filefound) {
// On verifie l'emplacement du modele
$file = dol_buildpath($reldir.$modelspath.$file, 0);
if (file_exists($file)) {
$filefound = $file;
$classname = $prefix.'_'.$modele;
break;
}
}
// If generator was found
if ($filefound) {
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
break;
}
}
require_once $file;
if (!$filefound) {
$this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele;
$this->errors[] = $this->error;
dol_syslog($this->error, LOG_ERR);
return -1;
}
$obj = new $classname($this->db);
// If generator was found
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
if ($obj->type == 'odt' && empty($srctemplatepath)) {
$varfortemplatedir = $obj->scandir;
if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) {
$dirtoscan = $conf->global->$varfortemplatedir;
require_once $file;
$listoffiles = array();
$obj = new $classname($this->db);
// Now we add first model found in directories scanned
$listofdir = explode(',', $dirtoscan);
foreach ($listofdir as $key => $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]);
continue;
}
if (is_dir($tmpdir)) {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
if (count($tmpfiles)) {
$listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
}
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
if ($obj->type == 'odt' && empty($srctemplatepath)) {
$varfortemplatedir = $obj->scandir;
if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) {
$dirtoscan = $conf->global->$varfortemplatedir;
if (count($listoffiles)) {
foreach ($listoffiles as $record) {
$srctemplatepath = $record['fullname'];
break;
}
$listoffiles = array();
// Now we add first model found in directories scanned
$listofdir = explode(',', $dirtoscan);
foreach ($listofdir as $key => $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]);
continue;
}
if (is_dir($tmpdir)) {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
if (count($tmpfiles)) {
$listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
}
if (empty($srctemplatepath)) {
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
return -1;
if (count($listoffiles)) {
foreach ($listoffiles as $record) {
$srctemplatepath = $record['fullname'];
break;
}
}
}
if ($obj->type == 'odt' && !empty($srctemplatepath)) {
if (!dol_is_file($srctemplatepath)) {
dol_syslog("Failed to locate template file ".$srctemplatepath, LOG_WARNING);
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
return -1;
}
}
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = empty($outputlangs->charset_output) ? '' : $outputlangs->charset_output;
if (in_array(get_class($this), array('Adherent'))) {
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards', $moreparams);
} else {
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
}
// After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
if ($resultwritefile > 0) {
$outputlangs->charset_output = $sav_charset_output;
// We delete old preview
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_delete_preview($this);
// Index file in database
if (!empty($obj->result['fullpath'])) {
$destfull = $obj->result['fullpath'];
// Update the last_main_doc field into main object (if document generator has property ->update_main_doc_field set)
$update_main_doc_field = 0;
if (!empty($obj->update_main_doc_field)) {
$update_main_doc_field = 1;
}
$this->indexFile($destfull, $update_main_doc_field);
} else {
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
}
// Success in building document. We build meta file.
dol_meta_create($this);
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
$this->error = $obj->error;
$this->errors = $obj->errors;
dol_syslog("Error generating document for ".__CLASS__.". Error: ".$obj->error, LOG_ERR);
return -1;
}
} else {
if (!$filefound) {
$this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele;
$this->errors[] = $this->error;
dol_syslog($this->error, LOG_ERR);
} else {
$this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound);
$this->errors[] = $this->error;
dol_syslog($this->error, LOG_ERR);
}
if (empty($srctemplatepath)) {
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
return -1;
}
}
if ($obj->type == 'odt' && !empty($srctemplatepath)) {
if (!dol_is_file($srctemplatepath)) {
dol_syslog("Failed to locate template file ".$srctemplatepath, LOG_WARNING);
$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
return -1;
}
}
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = empty($outputlangs->charset_output) ? '' : $outputlangs->charset_output;
if (in_array(get_class($this), array('Adherent'))) {
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards', $moreparams);
} else {
return $reshook;
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
}
// After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
if ($resultwritefile > 0) {
$outputlangs->charset_output = $sav_charset_output;
// We delete old preview
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_delete_preview($this);
// Index file in database
if (!empty($obj->result['fullpath'])) {
$destfull = $obj->result['fullpath'];
// Update the last_main_doc field into main object (if document generator has property ->update_main_doc_field set)
$update_main_doc_field = 0;
if (!empty($obj->update_main_doc_field)) {
$update_main_doc_field = 1;
}
$this->indexFile($destfull, $update_main_doc_field);
} else {
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
}
// Success in building document. We build meta file.
dol_meta_create($this);
return 1;
} else {
$outputlangs->charset_output = $sav_charset_output;
$this->error = $obj->error;
$this->errors = $obj->errors;
dol_syslog("Error generating document for ".__CLASS__.". Error: ".$obj->error, LOG_ERR);
return -1;
}
}

View File

@ -71,6 +71,25 @@ if (!function_exists('utf8_decode')) {
}
}
/**
* Return the full path of the directory where a module (or an object of a module) stores its files. Path may depends on the entity if a multicompany module is enabled.
*
* @param CommonObject $object Dolibarr common object
* @param string $module Override object element, for example to use 'mycompany' instead of 'societe'
* @return string|void The path of the relative directory of the module
* @since Dolibarr V18
*/
function getMultidirOutput($object, $module = '')
{
global $conf;
if (!is_object($object) && empty($module)) {
return null;
}
if (empty($module) && !empty($object->element)) {
$module = $object->element;
}
return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)];
}
/**
* Return dolibarr global constant string value
@ -10869,8 +10888,8 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
*
* @param string $label Label or tooltip of button. Also used as tooltip in title attribute. Can be escaped HTML content or full simple text.
* @param string $text Optional : short label on button. Can be escaped HTML content or full simple text.
* @param string $actionType 'default', 'delete', 'danger'
* @param string $url Url for link
* @param string $actionType 'default', 'delete', 'danger', 'email', ...
* @param string|array $url Url for link or array of subbutton description
* @param string $id Attribute id of button
* @param int|boolean $userRight User action right
* // phpcs:disable
@ -10897,7 +10916,26 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
{
global $hookmanager, $action, $object, $langs;
//var_dump($params);
// If $url is an array, we must build a dropdown button
if (is_array($url)) {
$out = '<div class="dropdown inline-block dropdown-holder">';
$out .= '<a style="margin-right: auto;" class="dropdown-toggle butAction" data-toggle="dropdown">'.$label.'</a>';
$out .= '<div class="dropdown-content">';
foreach ($url as $subbutton) {
if ($subbutton['enabled'] && $subbutton['perm']) {
if (!empty($subbutton['lang'])) {
$langs->load($subbutton['lang']);
}
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&amp;backtopage='.urlencode($params['backtopage'])), '', 1, array('isDropDown' => true));
}
}
$out .= "</div>";
$out .= "</div>";
return $out;
}
// If $url is a simple link
if (!empty($params['isDropdown']))
$class = "dropdown-item";
else {

View File

@ -418,7 +418,40 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
}
/**
* delete all permissions
* Get list of existing objects from directory
*
* @param string $destdir Directory
* @return array|int <=0 if KO, array if OK
*/
function dolGetListOfObjectClasses($destdir)
{
$objects = array();
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
foreach ($listofobject as $fileobj) {
if (preg_match('/^api_/', $fileobj['name'])) {
continue;
}
if (preg_match('/^actions_/', $fileobj['name'])) {
continue;
}
$tmpcontent = file_get_contents($fileobj['fullname']);
$reg = array();
if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
$objectnameloop = $reg[1];
$objects[$fileobj['fullname']] = $objectnameloop;
}
}
if (count($objects)>0) {
return $objects;
}
return -1;
}
/**
* Delete all permissions
*
* @param string $file file with path
* @return void
*/
@ -494,8 +527,6 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $action)
// rewrite all permission again
dolReplaceInFile($file, array('/* BEGIN MODULEBUILDER PERMISSIONS */' => '/* BEGIN MODULEBUILDER PERMISSIONS */'."\n\t\t".$rights_str));
return 1;
} else {
return -1;
}
}

View File

@ -1069,6 +1069,18 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if (count($arrayfields) > 0 && !empty($arrayfields['c.assigned']['checked'])) {
print '<td></td>';
}
//Check if Extrafields is totalizable
foreach ($extrafields->attributes['projet_task']['totalizable'] as $key=>$value) {
if ($arrayfields['ef.'.$key]['checked'] == 1) {
print '<td align="right">';
if ($value == 1) {
print $totalarray['totalizable'][$key]['total'];
}
print '</td>';
}
}
print '<td class=""></td>';
print '</tr>';
}

View File

@ -296,18 +296,18 @@ class pdf_eratosthene extends ModelePDFCommandes
if ($conf->commande->multidir_output[$conf->entity]) {
if (getMultidirOutput($object)) {
$object->fetch_thirdparty();
$deja_regle = 0;
// Definition of $dir and $file
if ($object->specimen) {
$dir = $conf->commande->multidir_output[$conf->entity];
$dir = getMultidirOutput($object);
$file = $dir."/SPECIMEN.pdf";
} else {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->commande->multidir_output[$object->entity]."/".$objectref;
$dir = getMultidirOutput($object)."/".$objectref;
$file = $dir."/".$objectref.".pdf";
}
@ -1447,7 +1447,7 @@ class pdf_eratosthene extends ModelePDFCommandes
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle")
{
// phpcs:enable
global $conf, $langs, $hookmanager;
global $conf, $langs, $hookmanager, $mysoc;
$ltrdirection = 'L';
if ($outputlangs->trans("DIRECTION") == 'rtl') $ltrdirection = 'R';
@ -1473,8 +1473,8 @@ class pdf_eratosthene extends ModelePDFCommandes
if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) {
$logodir = $conf->mycompany->multidir_output[$object->entity];
if (!empty(getMultidirOutput($mysoc, 'mycompany'))) {
$logodir = getMultidirOutput($mysoc, 'mycompany');
}
if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;

View File

@ -52,6 +52,7 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$socid = GETPOST('socid', 'int');
$amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT');
$donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
@ -405,6 +406,7 @@ if ($action == 'create') {
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head('');
@ -579,7 +581,7 @@ if (!empty($id) && $action == 'edit') {
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="rowid" value="'.$object->id.'">';
print '<input type="hidden" name="amount" value="'.$object->amount.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'donation');
@ -732,6 +734,7 @@ if (!empty($id) && $action != 'edit') {
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';

View File

@ -55,6 +55,7 @@ $langs->loadLangs(array("trips", "bills", "mails"));
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$id = GETPOST('id', 'int');
$date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int'));
@ -1407,6 +1408,7 @@ if ($action == 'create') {
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="create">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head('');
@ -1545,6 +1547,7 @@ if ($action == 'create') {
print "<form name='update' action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip');
@ -2027,6 +2030,7 @@ if ($action == 'create') {
print '<input type="hidden" name="action" value="'.$actiontouse.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="fk_expensereport" value="'.$object->id.'" />';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder centpercent">';

View File

@ -62,6 +62,8 @@ $contratid = (int) GETPOST('contratid', 'int');
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$mesg = GETPOST('msg', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ?GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
@ -890,6 +892,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="socid" value='.$soc->id.'>';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head('');
@ -1043,6 +1046,7 @@ if ($action == 'create') {
print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="create">'; // We go back to create action
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head('');
@ -1308,6 +1312,7 @@ if ($action == 'create') {
} else {
print '<input type="hidden" name="action" value="addline">';
}
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
// Intervention lines
$sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';

View File

@ -74,6 +74,8 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST("confirm");
$ref = GETPOST('ref', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$lineid = GETPOST('lineid', 'int');
$projectid = GETPOST('projectid', 'int');
$origin = GETPOST('origin', 'alpha');
@ -2156,6 +2158,7 @@ if ($action == 'create') {
if (!empty($currency_tx)) {
print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.'">';
}
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head();
@ -3721,6 +3724,7 @@ if ($action == 'create') {
print '<input type="hidden" name="page_y" value="">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="socid" value="'.$societe->id.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if (!empty($conf->use_javascript_ajax) && $object->statut == FactureFournisseur::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';

View File

@ -37,7 +37,7 @@
-- VMYSQL4.3 ALTER TABLE llx_hrm_skillrank CHANGE COLUMN `rank` rankorder integer;
-- VPGSQL8.2 ALTER TABLE llx_hrm_skillrank CHANGE COLUMN rank rankorder integer;
ALTER TABLE llx_accounting_system CHANGE COLUMN fk_pays fk_country integer;
ALTER TABLE llx_accounting_system CHANGE COLUMN fk_pays fk_country integer;
ALTER TABLE llx_commande_fournisseurdet MODIFY COLUMN ref varchar(128);
ALTER TABLE llx_facture_fourn_det MODIFY COLUMN ref varchar(128);
@ -376,4 +376,3 @@ UPDATE llx_c_country SET numeric_code = '716' WHERE code_iso = 'ZWE';
-- Generate documents on product batch
ALTER TABLE llx_product_lot ADD COLUMN model_pdf varchar(255) AFTER scrapping_date;
ALTER TABLE llx_product_lot ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;

View File

@ -2454,27 +2454,39 @@ function top_menu_user($hideloginname = 0, $urllogout = '')
}
jQuery(document).ready(function() {
jQuery(document).on("click", function(event) {
// console.log("Click somewhere on screen");
if (!$(event.target).closest("#topmenu-login-dropdown").length) {
closeTopMenuLoginDropdown();
}
});
';
jQuery(".butAction.dropdown-toggle").on("click", function(event) {
console.log("Click on .butAction.dropdown-toggle");
var parentholder = jQuery(".butAction.dropdown-toggle").closest(".dropdown");
var offset = parentholder.offset();
var left = offset.left;
var right = $(document).width() - offset.left - parentholder.width();
parentholder.toggleClass("open");
parentholder.children(".dropdown-content").css({"right": right+"px", "left": "auto"});
});
';
if ($conf->theme != 'md') {
$btnUser .= '
jQuery("#topmenu-login-dropdown .dropdown-toggle").on("click", function(event) {
console.log("toggle login dropdown");
console.log("Click on #topmenu-login-dropdown .dropdown-toggle");
event.preventDefault();
jQuery("#topmenu-login-dropdown").toggleClass("open");
});
jQuery("#topmenulogincompanyinfo-btn").on("click", function() {
console.log("Clik on topmenulogincompanyinfo-btn");
console.log("Clik on #topmenulogincompanyinfo-btn");
jQuery("#topmenulogincompanyinfo").slideToggle();
});
jQuery("#topmenuloginmoreinfo-btn").on("click", function() {
console.log("Clik on topmenuloginmoreinfo-btn");
console.log("Clik on #topmenuloginmoreinfo-btn");
jQuery("#topmenuloginmoreinfo").slideToggle();
});';
}
@ -2515,6 +2527,7 @@ function top_menu_quickadd()
}
});
$("#topmenu-quickadd-dropdown .dropdown-toggle").on("click", function(event) {
console.log("Click on #topmenu-quickadd-dropdown .dropdown-toggle");
openQuickAddDropDown();
});
// Key map shortcut
@ -2762,7 +2775,7 @@ function top_menu_bookmark()
});
jQuery("#topmenu-bookmark-dropdown .dropdown-toggle").on("click", function(event) {
console.log("toggle bookmark dropdown");
console.log("Click on #topmenu-bookmark-dropdown .dropdown-toggle");
openBookMarkDropDown();
});
@ -2904,7 +2917,7 @@ function top_menu_search()
// Open drop down
jQuery("#topmenu-global-search-dropdown .dropdown-toggle").on("click", function(event) {
console.log("toggle search dropdown");
console.log("click on toggle #topmenu-global-search-dropdown .dropdown-toggle");
openGlobalSearchDropDown();
});

View File

@ -405,23 +405,8 @@ if ($dirins && in_array($action, array('initapi', 'initphpunit', 'initpagecontac
$destdir = $dirins.'/'.strtolower($module);
// Get list of existing objects
$objects = array();
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
foreach ($listofobject as $fileobj) {
if (preg_match('/^api_/', $fileobj['name'])) {
continue;
}
if (preg_match('/^actions_/', $fileobj['name'])) {
continue;
}
$objects = dolGetListOfObjectClasses($destdir);
$tmpcontent = file_get_contents($fileobj['fullname']);
$reg = array();
if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
$objectnameloop = $reg[1];
$objects[$fileobj['fullname']] = $objectnameloop;
}
}
if ($action == 'initapi') {
if (file_exists($dirins.'/'.strtolower($module).'/class/api_'.strtolower($module).'.class.php')) {
@ -953,24 +938,8 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
$relativefilename = dol_sanitizePathName(GETPOST('file', 'restricthtml'));
// Get list of existing objects
// TODO ALI This part of code is common at several places and is autonomous. So replace it with $objects = dolGetListOfObjectclasses($destdir);
$objects = array();
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
foreach ($listofobject as $fileobj) {
if (preg_match('/^api_/', $fileobj['name'])) {
continue;
}
if (preg_match('/^actions_/', $fileobj['name'])) {
continue;
}
$objects = dolGetListOfObjectClasses($destdir);
$tmpcontent = file_get_contents($fileobj['fullname']);
$reg = array();
if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
$objectnameloop = $reg[1];
$objects[$fileobj['fullname']] = $objectnameloop;
}
}
// Now we delete the file
if ($relativefilename) {
@ -1030,20 +999,6 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
// Init an object
if ($dirins && $action == 'initobject' && $module && $objectname) {
// check if module is enabled
if (isModEnabled(strtolower($module))) {
$result = unActivateModule(strtolower($module));
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
if ($result) {
setEventMessages($result, null, 'errors');
} else {
/* FIX ALI header must be after action. Always add an exit after a header.
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
*/
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
}
}
$objectname = ucfirst($objectname);
$dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
@ -1651,6 +1606,18 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
} else {
$tabobj = 'newobject';
}
// check if module is enabled
if (isModEnabled(strtolower($module))) {
$result = unActivateModule(strtolower($module));
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
if ($result) {
setEventMessages($result, null, 'errors');
}
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module);
exit;
}
}
// Add a dictionary
@ -1913,20 +1880,6 @@ if ($dirins && $action == 'confirm_deletemodule') {
}
if ($dirins && $action == 'confirm_deleteobject' && $objectname) {
// check if module is enabled (if it's disabled and send msg event)
if (isModEnabled(strtolower($module))) {
$result = unActivateModule(strtolower($module));
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
if ($result) {
setEventMessages($result, null, 'errors');
$error++;
} else {
/* TODO ALI Header redirect must be at end after actions. Also tab=pemrissions looks strange
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module);
*/
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
}
}
if (preg_match('/[^a-z0-9_]/i', $objectname)) {
$error++;
setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors');
@ -2023,16 +1976,7 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) {
";
$deleteright = dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($objectname).'*/' => '', $rights => '', "/*END ".strtoupper($objectname).'*/'."\n\t\t" => "\n\t\t"));
if ($deleteright > 0) {
if (isModEnabled(strtolower($module))) {
$result = unActivateModule(strtolower($module));
if ($result) {
setEventMessages($result, null, 'errors');
}
setEventMessages($langs->trans("WarningModuleNeedRefrech", $langs->transnoentities($module)), null, 'warnings');
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?index.php?tab=description&module='.$module);
}
}
$resultko = 0;
foreach ($filetodelete as $tmpfiletodelete) {
$resulttmp = dol_delete_file($dir.'/'.$tmpfiletodelete, 0, 0, 1);
@ -2051,6 +1995,18 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) {
$action = '';
$tabobj = 'deleteobject';
// check if module is enabled
if (isModEnabled(strtolower($module))) {
$result = unActivateModule(strtolower($module));
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
if ($result) {
setEventMessages($result, null, 'errors');
}
setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings');
header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module);
exit;
}
}
if ($dirins && $action == 'generatedoc') {
@ -2602,25 +2558,10 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) {
$error = 0;
$dirins = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
$destdir = $dirins.'/'.strtolower($module);
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
// Get list of existing objets
$objects = array();
foreach ($listofobject as $fileobj) {
if (preg_match('/^api_/', $fileobj['name'])) {
continue;
}
if (preg_match('/^actions_/', $fileobj['name'])) {
continue;
}
$objects = dolGetListOfObjectClasses($destdir);
$tmpcontent = file_get_contents($fileobj['fullname']);
$reg = array();
if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
$objectnameloop = $reg[1];
$objects[$fileobj['fullname']] = $objectnameloop;
}
}
// load class and check if right exist
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
@ -4564,27 +4505,24 @@ if ($module == 'initmodule') {
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
$dirins = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
$destdir = $dirins.'/'.strtolower($module);
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
// Get list of existing objects
$objects = array();
foreach ($listofobject as $fileobj) {
if (preg_match('/^api_/', $fileobj['name'])) {
continue;
}
if (preg_match('/^actions_/', $fileobj['name'])) {
continue;
}
$objects = dolGetListOfObjectClasses($destdir);
$tmpcontent = file_get_contents($fileobj['fullname']);
$reg = array();
if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
$objectnameloop = $reg[1];
$objects[$fileobj['fullname']] = $objectnameloop;
}
}
$menus = $moduleobj->menu;
if ($action == 'deletemenu') {
$formconfirms = $form->formconfirm(
$_SERVER["PHP_SELF"].'?menukey='.urlencode(GETPOST('menukey', 'int')).'&tab='.urlencode($tab).'&module='.urlencode($module),
$langs->trans('Delete'),
$langs->trans('Confirm Delete Menu', GETPOST('menukey', 'int')),
'confirm_deletemenu',
'',
0,
1
);
print $formconfirms;
}
if ($action != 'editfile' || empty($file)) {
print '<span class="opacitymedium">';
$htmlhelp = $langs->trans("MenusDefDescTooltip", '{s1}');

View File

@ -95,6 +95,7 @@ $search_accountancy_code_buy = GETPOST("search_accountancy_code_buy", 'alpha');
$search_accountancy_code_buy_intra = GETPOST("search_accountancy_code_buy_intra", 'alpha');
$search_accountancy_code_buy_export = GETPOST("search_accountancy_code_buy_export", 'alpha');
$search_finished = GETPOST("search_finished", 'int');
$search_units = GETPOST('search_units', 'int');
$optioncss = GETPOST('optioncss', 'alpha');
$type = GETPOST("type", "int");
$mode = GETPOST('mode', 'alpha');
@ -353,6 +354,7 @@ if (empty($reshook)) {
$search_accountancy_code_buy_intra = '';
$search_accountancy_code_buy_export = '';
$search_array_options = array();
$search_units = '';
}
// Mass actions
@ -571,6 +573,9 @@ if ($search_accountancy_code_buy_intra) {
if ($search_accountancy_code_buy_export) {
$sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', $search_accountancy_code_buy_export);
}
if (!empty($conf->global->PRODUCT_USE_UNITS) && $search_units) {
$sql .= natural_search('cu.rowid', $search_units);
}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
@ -1021,6 +1026,7 @@ if (!empty($arrayfields['p.volume_units']['checked'])) {
// Unit
if (!empty($arrayfields['cu.label']['checked'])) {
print '<td class="liste_titre">';
print $form->selectUnits($search_units, 'search_units', 1);
print '</td>';
}

View File

@ -1551,56 +1551,26 @@ if ($action == 'create' && $user->rights->projet->creer) {
}
}
// Buttons Create
if (empty($conf->global->PROJECT_HIDE_CREATE_OBJECT_BUTTON)) {
$arrayforbutaction = array(
10 => array('lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
20 => array('lang'=>'orders', 'enabled'=>isModEnabled("commande"), 'perm'=>$user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url'=>'/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
30 => array('lang'=>'bills', 'enabled'=>isModEnabled("facture"), 'perm'=>$user->hasRight('facture', 'creer'), 'label' => 'CreateBill', 'url'=>'/compta/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
40 => array('lang'=>'supplier_proposal', 'enabled'=>isModEnabled("supplier_proposal"), 'perm'=>$user->hasRight('supplier_proposal', 'creer'), 'label' => 'AddSupplierProposal', 'url'=>'/supplier_proposal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
50 => array('lang'=>'suppliers', 'enabled'=>isModEnabled("supplier_order"), 'perm'=>$user->hasRight('fournisseur', 'commande', 'creer'), 'label' => 'AddSupplierOrder', 'url'=>'/fourn/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
60 => array('lang'=>'suppliers', 'enabled'=>isModEnabled("supplier_invoice"), 'perm'=>$user->hasRight('fournisseur', 'facture', 'creer'), 'label' => 'AddSupplierInvoice', 'url'=>'/fourn/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
70 => array('lang'=>'interventions', 'enabled'=>isModEnabled("ficheinter"), 'perm'=>$user->hasRight('fichinter', 'creer'), 'label' => 'AddIntervention', 'url'=>'/fichinter/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
80 => array('lang'=>'contrats', 'enabled'=>isModEnabled("contrat"), 'perm'=>$user->hasRight('contrat', 'creer'), 'label' => 'AddContract', 'url'=>'/contrat/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
90 => array('lang'=>'trips', 'enabled'=>isModEnabled("expensereport"), 'perm'=>$user->hasRight('expensereport', 'creer'), 'label' => 'AddTrip', 'url'=>'/expensereport/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
100 => array('lang'=>'donations', 'enabled'=>isModEnabled("don"), 'perm'=>$user->hasRight('don', 'creer'), 'label' => 'AddDonation', 'url'=>'/don/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
);
if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) {
print'<div class="dropdown inline-block">';
print'<a style="margin-right: auto;"class="dropdown-toggle butAction" data-toggle="dropdown">'.$langs->trans("Create").'</a>';
print '<div class="dropdown-menu">';
print '<div class="dropdown-global-search-button-list" >';
if (isModEnabled("propal") && $user->hasRight('propal', 'creer')) {
$langs->load("propal");
print dolGetButtonAction('', $langs->trans('AddProp'), 'default', DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled('commande') && $user->hasRight('commande', 'creer')) {
$langs->load("orders");
print dolGetButtonAction('', $langs->trans('CreateOrder'), 'default', DOL_URL_ROOT.'/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled('facture') && $user->hasRight('facture', 'creer')) {
$langs->load("bills");
print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled('supplier_proposal') && $user->rights->supplier_proposal->creer) {
$langs->load("supplier_proposal");
print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled("supplier_order") && ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)) {
$langs->load("suppliers");
print dolGetButtonAction('', $langs->trans('AddSupplierOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled("supplier_invoice") && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
$langs->load("suppliers");
print dolGetButtonAction('', $langs->trans('AddSupplierInvoice'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer')) {
$langs->load("interventions");
print dolGetButtonAction('', $langs->trans('AddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled('contrat') && $user->hasRight('contrat', 'creer')) {
$langs->load("contracts");
print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled('expensereport') && $user->rights->expensereport->creer) {
$langs->load("trips");
print dolGetButtonAction('', $langs->trans('AddTrip'), 'default', DOL_URL_ROOT.'/expensereport/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled('don') && $user->rights->don->creer) {
$langs->load("donations");
print dolGetButtonAction('', $langs->trans('AddDonation'), 'default', DOL_URL_ROOT.'/don/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
print "</div>";
print "</div>";
print "</div>";
$params = array('backtopage' => $_SERVER["PHP_SELF"].'?id='.$object->id);
print dolGetButtonAction($langs->trans("Create"), '', 'default', $arrayforbutaction, '', 1, $params);
}
// Clone
if ($user->rights->projet->creer) {
if ($userWrite > 0) {

View File

@ -1503,6 +1503,13 @@ while ($i < $imaxinloop) {
}
// Show total line
if (!empty($totalarray['totalizable']) && is_array($totalarray['totalizable'])) {
foreach ($totalarray['totalizable'] as $keytotalizable => $valtotalizable) {
$totalarray['pos'][$valtotalizable['pos']] = $keytotalizable;
$totalarray['val'][$keytotalizable] = $valtotalizable['total'];
}
}
if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield']) || isset($totalarray['totalprogress_calculatedfield'])
|| isset($totalarray['totaltobill']) || isset($totalarray['totalbilled']) || isset($totalarray['totalbudget'])) {
print '<tr class="liste_total">';
@ -1529,6 +1536,14 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota
print '<td class="center">'.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).'</td>';
} elseif ($totalarray['totalbudget_amountfield'] == $i) {
print '<td class="center">'.price($totalarray['totalbudgetamount'], 0, $langs, 1, 0, 0, $conf->currency).'</td>';
} elseif (!empty($totalarray['pos'][$i])) {
print '<td class="right">';
if (isset($totalarray['type']) && $totalarray['type'][$i] == 'duration') {
print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0);
} else {
print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0);
}
print '</td>';
} else {
print '<td></td>';
}

View File

@ -4358,7 +4358,9 @@ class Societe extends CommonObject
global $langs;
$this->id = 0;
$this->entity = $conf->entity;
$this->name = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
$this->nom = $this->name; // deprecated
$this->address = getDolGlobalString('MAIN_INFO_SOCIETE_ADDRESS');
$this->zip = getDolGlobalString('MAIN_INFO_SOCIETE_ZIP');
$this->town = getDolGlobalString('MAIN_INFO_SOCIETE_TOWN');
@ -4368,8 +4370,6 @@ class Societe extends CommonObject
$this->note_private = getDolGlobalString('MAIN_INFO_SOCIETE_NOTE');
$this->nom = $this->name; // deprecated
// We define country_id, country_code and country
$country_id = $country_code = $country_label = '';
if (!empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {

View File

@ -63,6 +63,9 @@ $ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int');
$confirm = GETPOST('confirm', 'alpha');
@ -1251,6 +1254,7 @@ if ($action == 'create') {
print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">';
}
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print dol_get_fiche_head();
@ -1688,6 +1692,7 @@ if ($action == 'create') {
print '<form name="editdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" class="formconsumeproduce">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate_livraison">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print $form->selectDate($object->delivery_date, 'liv_', '', '', '', "editdate_livraison");
print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
print '</form>';
@ -1889,6 +1894,7 @@ if ($action == 'create') {
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'">
<input type="hidden" name="backtopage" value="'.$backtopage.'">
';
if (!empty($conf->use_javascript_ajax) && $object->statut == SupplierProposal::STATUS_DRAFT) {

View File

@ -501,6 +501,43 @@ div.quickaddblock:focus {
background: <?php print $colorbacklinepair1; ?>;
}
/* for the dropdown on action buttons */
dropdown-holder {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
z-index: 1;
width: 300px;
right:10px; /* will be set with js */
background: #fff;
border: 1px solid #bbb;
text-align: <?php echo $left; ?>
}
.dropdown-content a {
margin-right: auto !important;
margin-left: auto !important;
}
.dropdown-content .butAction {
background: none;
color: #000 !important;
}
.dropdown-content .butAction:hover {
box-shadow: none;
text-decoration: underline;
}
.dropdown-holder.open .dropdown-content {
display: block;
}
/* smartphone */
@media only screen and (max-width: 767px)
{

View File

@ -435,6 +435,41 @@ a.dropdown-item {
}
/* for the dropdown on action buttons */
dropdown-holder {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
z-index: 1;
width: 300px;
right:10px; /* will be set with js */
background: #fff;
border: 1px solid #bbb;
text-align: <?php echo $left; ?>
}
.dropdown-content a {
margin-right: auto !important;
margin-left: auto !important;
}
.dropdown-content .butAction {
background: none;
color: #000 !important;
}
.dropdown-content .butAction:hover {
box-shadow: none;
text-decoration: underline;
}
.dropdown-holder.open .dropdown-content {
display: block;
}
/* smartphone */
@media only screen and (max-width: 767px)
{