Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2019-12-03 10:17:29 +00:00
parent b317530b39
commit 36a74cd160
50 changed files with 4036 additions and 4036 deletions

View File

@ -50,10 +50,10 @@ $objectline = new BOMLine($this->db);
print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
$nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines);
$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
if ($nolinesbefore) {
print '<tr class="liste_titre nodrag nodrop">';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td class="linecolnum center"></td>';
}
print '<td class="linecoldescription minwidth500imp">';
@ -74,11 +74,11 @@ if ($nolinesbefore) {
print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>';
print '</tr>';
}
print '<tr class="pair nodrag nodrop nohoverpair'.($nolinesbefore || $object->element=='contrat')?'':' liste_titre_create'.'">';
$coldisplay=0;
print '<tr class="pair nodrag nodrop nohoverpair'.($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create'.'">';
$coldisplay = 0;
// Adds a line numbering column
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay++;
echo '<td class="bordertop nobottom linecolnum center"></td>';
}
@ -87,15 +87,15 @@ $coldisplay++;
print '<td class="bordertop nobottom linecoldescription minwidth500imp">';
// Predefined product/service
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
{
if ($forceall >= 0 && $freelines) echo '<br>';
echo '<span class="prod_entry_mode_predef">';
$filtertype='';
if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
$filtertype = '';
if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype = '1';
$statustoshow = -1;
if (! empty($conf->global->ENTREPOT_EXTRA_STATUS))
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS))
{
// hide products in closed warehouse, but show products for internal transfer
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
@ -109,10 +109,10 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
}
$coldisplay++;
print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(isset($_POST["qty"])?GETPOST("qty", 'alpha', 2):1).'">';
print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(isset($_POST["qty"]) ?GETPOST("qty", 'alpha', 2) : 1).'">';
print '</td>';
if($conf->global->PRODUCT_USE_UNITS)
if ($conf->global->PRODUCT_USE_UNITS)
{
$coldisplay++;
print '<td class="nobottom linecoluseunit left">';
@ -121,11 +121,11 @@ if($conf->global->PRODUCT_USE_UNITS)
}
$coldisplay++;
print '<td class="bordertop nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"'.(GETPOST("qty_frozen", 'alpha')?' checked="checked"':'').'>';
print '<td class="bordertop nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"'.(GETPOST("qty_frozen", 'alpha') ? ' checked="checked"' : '').'>';
print '</td>';
$coldisplay++;
print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha')?' checked="checked"':'').'">';
print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha') ? ' checked="checked"' : '').'">';
print '</td>';
//$coldisplay++;

View File

@ -63,7 +63,7 @@ class AgendaEvents extends DolibarrApi
*/
public function get($id)
{
if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) {
if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) {
throw new RestException(401, "Insufficient rights to read an event");
}
if ($id == 0) {
@ -75,15 +75,15 @@ class AgendaEvents extends DolibarrApi
$this->actioncomm->fetchObjectLinked();
}
}
if ( ! $result ) {
if (!$result) {
throw new RestException(404, 'Agenda Events not found');
}
if (! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) {
if (!DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) {
throw new RestException(401, "Insufficient rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
if ( ! DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) {
if (!DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
return $this->_cleanObjectDatas($this->actioncomm);
@ -108,30 +108,30 @@ class AgendaEvents extends DolibarrApi
$obj_ret = array();
if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) {
if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) {
throw new RestException(401, "Insufficient rights to read events");
}
// case of external user
$socid = 0;
if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid;
if (!empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists
$sql = "SELECT t.id as rowid";
if (! empty($conf->societe->enabled))
if (!empty($conf->societe->enabled))
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
if (! empty($conf->societe->enabled))
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('agenda').')';
if (! empty($conf->societe->enabled))
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")";
if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid;
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
if (!empty($conf->societe->enabled))
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql .= ' WHERE t.entity IN ('.getEntity('agenda').')';
if (!empty($conf->societe->enabled))
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
if ($user_ids) $sql .= " AND t.fk_user_action IN (".$user_ids.")";
if ($socid > 0) $sql .= " AND t.fk_soc = ".$socid;
// Insert sale filter
if ($search_sale > 0)
{
@ -140,30 +140,30 @@ class AgendaEvents extends DolibarrApi
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
if ($result)
{
$i=0;
$i = 0;
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
@ -179,7 +179,7 @@ class AgendaEvents extends DolibarrApi
else {
throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror());
}
if ( ! count($obj_ret)) {
if (!count($obj_ret)) {
throw new RestException(404, 'No Agenda Event found');
}
return $obj_ret;
@ -193,17 +193,17 @@ class AgendaEvents extends DolibarrApi
*/
public function post($request_data = null)
{
if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) {
if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) {
throw new RestException(401, "Insufficient rights to create your Agenda Event");
}
if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach($request_data as $field => $value) {
foreach ($request_data as $field => $value) {
$this->actioncomm->$field = $value;
}
/*if (isset($request_data["lines"])) {
@ -273,7 +273,7 @@ class AgendaEvents extends DolibarrApi
*/
public function delete($id)
{
if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) {
if (!DolibarrApiAccess::$user->rights->agenda->myactions->delete) {
throw new RestException(401, "Insufficient rights to delete your Agenda Event");
}
@ -284,19 +284,19 @@ class AgendaEvents extends DolibarrApi
$this->actioncomm->oldcopy = clone $this->actioncomm;
}
if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) {
if (!DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) {
throw new RestException(401, "Insufficient rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Agenda Event not found');
}
if( ! DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) {
if (!DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) {
if (!$this->actioncomm->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error);
}
@ -338,7 +338,7 @@ class AgendaEvents extends DolibarrApi
// phpcs:enable
$object = parent::_cleanObjectDatas($object);
unset($object->note); // alreaydy into note_private
unset($object->note); // alreaydy into note_private
unset($object->usermod);
unset($object->libelle);
unset($object->context);

View File

@ -39,7 +39,7 @@ $confirm = GETPOST('confirm', 'alpha');
// Security check
$socid = GETPOST("socid", "int");
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'banque', '', '', '');
// Get parameters
@ -74,50 +74,50 @@ include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
$form = new Form($db);
$title = $langs->trans("VariousPayment") . ' - ' . $langs->trans("Documents");
$title = $langs->trans("VariousPayment").' - '.$langs->trans("Documents");
$help_url = '';
llxHeader("", $title, $help_url);
if ($object->id)
{
$head=various_payment_prepare_head($object);
$head = various_payment_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), -1, $object->picto);
$morehtmlref='<div class="refidno">';
$morehtmlref = '<div class="refidno">';
// Project
if (! empty($conf->projet->enabled))
if (!empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.=$langs->trans('Project') . ' : ';
$morehtmlref .= $langs->trans('Project').' : ';
if ($user->rights->banque->modifier && 0)
{
if ($action != 'classify') {
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$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.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
$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 .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.=$proj->getNomUrl(1);
$morehtmlref .= $proj->getNomUrl(1);
} else {
$morehtmlref.='';
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref .= '</div>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);

View File

@ -52,44 +52,44 @@ $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicetemplatelist'; // To manage different context of search
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search
// Security check
$id=(GETPOST('facid', 'int')?GETPOST('facid', 'int'):GETPOST('id', 'int'));
$lineid=GETPOST('lineid', 'int');
$ref=GETPOST('ref', 'alpha');
if ($user->socid) $socid=$user->socid;
$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
$lineid = GETPOST('lineid', 'int');
$ref = GETPOST('ref', 'alpha');
if ($user->socid) $socid = $user->socid;
$objecttype = 'facture_rec';
if ($action == "create" || $action == "add") $objecttype = '';
$result = restrictedArea($user, 'facture', $id, $objecttype);
$projectid = GETPOST('projectid', 'int');
$search_ref=GETPOST('search_ref');
$search_societe=GETPOST('search_societe');
$search_montant_ht=GETPOST('search_montant_ht');
$search_montant_vat=GETPOST('search_montant_vat');
$search_montant_ttc=GETPOST('search_montant_ttc');
$search_payment_mode=GETPOST('search_payment_mode');
$search_payment_term=GETPOST('search_payment_term');
$search_day=GETPOST('search_day', 'int');
$search_year=GETPOST('search_year', 'int');
$search_month=GETPOST('search_month', 'int');
$search_day_date_when=GETPOST('search_day_date_when', 'int');
$search_year_date_when=GETPOST('search_year_date_when', 'int');
$search_month_date_when=GETPOST('search_month_date_when', 'int');
$search_recurring=GETPOST('search_recurring', 'int');
$search_frequency=GETPOST('search_frequency', 'alpha');
$search_unit_frequency=GETPOST('search_unit_frequency', 'alpha');
$search_status=GETPOST('search_status', 'int');
$search_ref = GETPOST('search_ref');
$search_societe = GETPOST('search_societe');
$search_montant_ht = GETPOST('search_montant_ht');
$search_montant_vat = GETPOST('search_montant_vat');
$search_montant_ttc = GETPOST('search_montant_ttc');
$search_payment_mode = GETPOST('search_payment_mode');
$search_payment_term = GETPOST('search_payment_term');
$search_day = GETPOST('search_day', 'int');
$search_year = GETPOST('search_year', 'int');
$search_month = GETPOST('search_month', 'int');
$search_day_date_when = GETPOST('search_day_date_when', 'int');
$search_year_date_when = GETPOST('search_year_date_when', 'int');
$search_month_date_when = GETPOST('search_month_date_when', 'int');
$search_recurring = GETPOST('search_recurring', 'int');
$search_frequency = GETPOST('search_frequency', 'alpha');
$search_unit_frequency = GETPOST('search_unit_frequency', 'alpha');
$search_status = GETPOST('search_status', 'int');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='f.titre';
if (!$sortorder) $sortorder = 'DESC';
if (!$sortfield) $sortfield = 'f.titre';
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -206,40 +206,40 @@ llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-factur
$form = new Form($db);
$formother = new FormOther($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
$companystatic = new Societe($db);
$invoicerectmp = new FactureRec($db);
$now = dol_now();
$tmparray=dol_getdate($now);
$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
$tmparray = dol_getdate($now);
$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day
/*
* List mode
*/
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
$sql.= " f.datec, f.tms,";
$sql.= " f.fk_cond_reglement, f.fk_mode_reglement";
$sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
$sql .= " f.datec, f.tms,";
$sql .= " f.fk_cond_reglement, f.fk_mode_reglement";
// Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
}
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql.=preg_replace('/^,/', '', $hookmanager->resPrint);
$sql =preg_replace('/,\s*$/', '', $sql);
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
@ -333,126 +333,126 @@ if ($resql)
$i = 0;
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Filters lines
print '<tr class="liste_titre_filter">';
// Ref
if (! empty($arrayfields['f.titre']['checked']))
if (!empty($arrayfields['f.titre']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
// Thirpdarty
if (! empty($arrayfields['s.nom']['checked']))
if (!empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
}
if (! empty($arrayfields['f.total']['checked']))
if (!empty($arrayfields['f.total']['checked']))
{
// Amount net
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
print '</td>';
}
if (! empty($arrayfields['f.tva']['checked']))
if (!empty($arrayfields['f.tva']['checked']))
{
// Amount Vat
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
print '</td>';
}
if (! empty($arrayfields['f.total_ttc']['checked']))
if (!empty($arrayfields['f.total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre right">';
print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
print '</td>';
}
if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
if (!empty($arrayfields['f.fk_cond_reglement']['checked']))
{
// Payment term
print '<td class="liste_titre right">';
$form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
print "</td>";
}
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
if (!empty($arrayfields['f.fk_mode_reglement']['checked']))
{
// Payment mode
print '<td class="liste_titre right">';
$form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100');
print '</td>';
}
if (! empty($arrayfields['recurring']['checked']))
if (!empty($arrayfields['recurring']['checked']))
{
// Recurring or not
print '<td class="liste_titre" align="center">';
print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
print '</td>';
}
if (! empty($arrayfields['f.frequency']['checked']))
if (!empty($arrayfields['f.frequency']['checked']))
{
// Recurring or not
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
print '</td>';
}
if (! empty($arrayfields['f.unit_frequency']['checked']))
if (!empty($arrayfields['f.unit_frequency']['checked']))
{
// Frequency unit
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
print '</td>';
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
if (!empty($arrayfields['f.nb_gen_done']['checked']))
{
// Nb generation
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Date invoice
if (! empty($arrayfields['f.date_last_gen']['checked']))
if (!empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td class="liste_titre nowraponall" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year?$search_year:-1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
$formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
print '</td>';
}
// Date next generation
if (! empty($arrayfields['f.date_when']['checked']))
if (!empty($arrayfields['f.date_when']['checked']))
{
print '<td class="liste_titre nowraponall" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">';
print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">';
$formother->select_year($search_year_date_when?$search_year_date_when:-1, 'search_year_date_when', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
$formother->select_year($search_year_date_when ? $search_year_date_when : -1, 'search_year_date_when', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
print '</td>';
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['f.datec']['checked']))
if (!empty($arrayfields['f.datec']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (! empty($arrayfields['f.tms']['checked']))
if (!empty($arrayfields['f.tms']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status
if (! empty($arrayfields['status']['checked']))
if (!empty($arrayfields['status']['checked']))
{
print '<td class="liste_titre" align="center">';
$liststatus=array(
$liststatus = array(
0=>$langs->trans("Draft"),
1=>$langs->trans("Active"),
-1=>$langs->trans("Disabled"),
@ -462,145 +462,145 @@ if ($resql)
}
// Action column
print '<td class="liste_titre" align="middle">';
$searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
$searchpicto = $form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder);
if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder);
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'nomaxwidthsearch ');
print "</tr>\n";
if ($num > 0)
{
$i=0;
$totalarray=array();
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$objp = $db->fetch_object($resql);
if (empty($objp)) break;
$companystatic->id=$objp->socid;
$companystatic->name=$objp->name;
$companystatic->id = $objp->socid;
$companystatic->name = $objp->name;
$invoicerectmp->id=$objp->id?$objp->id:$objp->facid;
$invoicerectmp->frequency=$objp->frequency;
$invoicerectmp->suspended=$objp->suspended;
$invoicerectmp->unit_frequency=$objp->unit_frequency;
$invoicerectmp->nb_gen_max=$objp->nb_gen_max;
$invoicerectmp->nb_gen_done=$objp->nb_gen_done;
$invoicerectmp->ref=$objp->title;
$invoicerectmp->id = $objp->id ? $objp->id : $objp->facid;
$invoicerectmp->frequency = $objp->frequency;
$invoicerectmp->suspended = $objp->suspended;
$invoicerectmp->unit_frequency = $objp->unit_frequency;
$invoicerectmp->nb_gen_max = $objp->nb_gen_max;
$invoicerectmp->nb_gen_done = $objp->nb_gen_done;
$invoicerectmp->ref = $objp->title;
print '<tr class="oddeven">';
if (! empty($arrayfields['f.titre']['checked']))
if (!empty($arrayfields['f.titre']['checked']))
{
print '<td>';
print $invoicerectmp->getNomUrl(1);
print "</a>";
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.nom']['checked']))
if (!empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1, 'customer').'</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.total']['checked']))
if (!empty($arrayfields['f.total']['checked']))
{
print '<td class="right">'.price($objp->total).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total';
$totalarray['val']['f.total'] += $objp->total;
}
if (! empty($arrayfields['f.tva']['checked']))
if (!empty($arrayfields['f.tva']['checked']))
{
print '<td class="right">'.price($objp->total_vat).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva';
$totalarray['val']['f.tva'] += $objp->total_vat;
}
if (! empty($arrayfields['f.total_ttc']['checked']))
if (!empty($arrayfields['f.total_ttc']['checked']))
{
print '<td class="right">'.price($objp->total_ttc).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc';
$totalarray['val']['f.total_ttc'] += $objp->total_ttc;
}
// Payment term
if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
if (!empty($arrayfields['f.fk_cond_reglement']['checked']))
{
print '<td class="right">';
$form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
print '</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Payment mode
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
if (!empty($arrayfields['f.fk_mode_reglement']['checked']))
{
print '<td class="right">';
$form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
print '</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['recurring']['checked']))
if (!empty($arrayfields['recurring']['checked']))
{
print '<td align="center">'.yn($objp->frequency?1:0).'</td>';
if (! $i) $totalarray['nbfield']++;
print '<td align="center">'.yn($objp->frequency ? 1 : 0).'</td>';
if (!$i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.frequency']['checked']))
if (!empty($arrayfields['f.frequency']['checked']))
{
print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.unit_frequency']['checked']))
if (!empty($arrayfields['f.unit_frequency']['checked']))
{
print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
if (!empty($arrayfields['f.nb_gen_done']['checked']))
{
print '<td align="center">';
print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Date last generation
if (! empty($arrayfields['f.date_last_gen']['checked']))
if (!empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td align="center">';
print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Date next generation
if (! empty($arrayfields['f.date_when']['checked']))
if (!empty($arrayfields['f.date_when']['checked']))
{
print '<td align="center">';
print '<div class="nowraponall">';
print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
if (! $invoicerectmp->isMaxNbGenReached())
print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached() ? '<strike>' : '').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached() ? '</strike>' : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
if (!$invoicerectmp->isMaxNbGenReached())
{
if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
}
else
{
@ -608,36 +608,36 @@ if ($resql)
}
print '</div>';
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.datec']['checked']))
if (!empty($arrayfields['f.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->datec), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.tms']['checked']))
if (!empty($arrayfields['f.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->tms), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
$obj = $objp;
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Status
if (! empty($arrayfields['status']['checked'])) {
if (!empty($arrayfields['status']['checked'])) {
print '<td align="center">';
print $invoicerectmp->getLibStatut(3, 0);
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Action column
print '<td align="center">';

View File

@ -64,23 +64,23 @@ class Contact extends CommonObject
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields=array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60),
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60),
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510),
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510),
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000),
);
public $civility_id; // In fact we store civility_code
public $civility_id; // In fact we store civility_code
public $civility_code;
public $civility;
@ -92,14 +92,14 @@ class Contact extends CommonObject
public $zip;
public $town;
public $state_id; // Id of department
public $state_code; // Code of department
public $state; // Label of department
public $state_id; // Id of department
public $state_code; // Code of department
public $state; // Label of department
public $poste; // Position
public $poste; // Position
public $socid; // fk_soc
public $statut; // 0=inactif, 1=actif
public $socid; // fk_soc
public $statut; // 0=inactif, 1=actif
public $code;
@ -181,9 +181,9 @@ class Contact extends CommonObject
* Old copy
* @var Contact
*/
public $oldcopy; // To contains a clone of this when we need to save old properties of object
public $oldcopy; // To contains a clone of this when we need to save old properties of object
public $roles=array();
public $roles = array();
/**
@ -208,28 +208,28 @@ class Contact extends CommonObject
// phpcs:enable
global $user;
$this->nb=array();
$this->nb = array();
$clause = "WHERE";
$sql = "SELECT count(sp.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
if (!$user->rights->societe->client->voir && !$user->socid)
{
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$clause = "AND";
}
$sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')';
$sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))";
if ($user->socid > 0) $sql.=" AND sp.fk_soc = ".$user->socid;
$sql .= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')';
$sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))";
if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid;
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
while ($obj = $this->db->fetch_object($resql))
{
$this->nb["contacts"]=$obj->nb;
$this->nb["contacts"] = $obj->nb;
}
$this->db->free($resql);
return 1;
@ -386,7 +386,7 @@ class Contact extends CommonObject
$this->town = (empty($this->town) ? '' : $this->town);
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
if (empty($this->statut)) $this->statut = 0;
if (empty($this->civility_code) && ! is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility
if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET ";
@ -406,16 +406,16 @@ class Contact extends CommonObject
$sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'";
$sql .= ", photo='".$this->db->escape($this->photo)."'";
$sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null");
$sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql .= ", note_public = ".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
$sql .= ", phone = ".(isset($this->phone_pro)?"'".$this->db->escape($this->phone_pro)."'":"null");
$sql .= ", phone_perso = ".(isset($this->phone_perso)?"'".$this->db->escape($this->phone_perso)."'":"null");
$sql .= ", phone_mobile = ".(isset($this->phone_mobile)?"'".$this->db->escape($this->phone_mobile)."'":"null");
$sql .= ", note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null");
$sql .= ", note_public = ".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null");
$sql .= ", phone = ".(isset($this->phone_pro) ? "'".$this->db->escape($this->phone_pro)."'" : "null");
$sql .= ", phone_perso = ".(isset($this->phone_perso) ? "'".$this->db->escape($this->phone_perso)."'" : "null");
$sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "null");
$sql .= ", priv = '".$this->db->escape($this->priv)."'";
$sql .= ", statut = ".$this->db->escape($this->statut);
$sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL");
$sql .= ", default_lang=".($this->default_lang?"'".$this->db->escape($this->default_lang)."'":"NULL");
$sql .= ", entity = " . $this->db->escape($this->entity);
$sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "NULL");
$sql .= ", default_lang=".($this->default_lang ? "'".$this->db->escape($this->default_lang)."'" : "NULL");
$sql .= ", entity = ".$this->db->escape($this->entity);
$sql .= " WHERE rowid=".$this->db->escape($id);
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -525,15 +525,15 @@ class Contact extends CommonObject
}
}
if (! $error && ! $notrigger)
if (!$error && !$notrigger)
{
// Call trigger
$result=$this->call_trigger('CONTACT_MODIFY', $user);
$result = $this->call_trigger('CONTACT_MODIFY', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return 1;
@ -757,37 +757,37 @@ class Contact extends CommonObject
$langs->load("dict");
dol_syslog(get_class($this) . "::fetch id=" . $id . " ref_ext=" . $ref_ext . " email=" . $email, LOG_DEBUG);
dol_syslog(get_class($this)."::fetch id=".$id." ref_ext=".$ref_ext." email=".$email, LOG_DEBUG);
if (empty($id) && empty($ref_ext) && empty($email))
{
$this->error='BadParameter';
$this->error = 'BadParameter';
return -1;
}
$langs->load("companies");
$sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,";
$sql.= " c.address, c.statut, c.zip, c.town,";
$sql.= " c.fk_pays as country_id,";
$sql.= " c.fk_departement as state_id,";
$sql.= " c.birthday,";
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,";
$sql.= " c.socialnetworks,";
$sql.= " c.photo,";
$sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
$sql.= " c.import_key,";
$sql.= " c.datec as date_creation, c.tms as date_modification,";
$sql.= " co.label as country, co.code as country_code,";
$sql.= " d.nom as state, d.code_departement as state_code,";
$sql.= " u.rowid as user_id, u.login as user_login,";
$sql.= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
if ($id) $sql.= " WHERE c.rowid = ". $id;
$sql .= " c.address, c.statut, c.zip, c.town,";
$sql .= " c.fk_pays as country_id,";
$sql .= " c.fk_departement as state_id,";
$sql .= " c.birthday,";
$sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,";
$sql .= " c.socialnetworks,";
$sql .= " c.photo,";
$sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
$sql .= " c.import_key,";
$sql .= " c.datec as date_creation, c.tms as date_modification,";
$sql .= " co.label as country, co.code as country_code,";
$sql .= " d.nom as state, d.code_departement as state_code,";
$sql .= " u.rowid as user_id, u.login as user_login,";
$sql .= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
if ($id) $sql .= " WHERE c.rowid = ".$id;
else
{
$sql .= " WHERE c.entity IN (".getEntity($this->element).")";
@ -799,47 +799,47 @@ class Contact extends CommonObject
}
}
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->entity = $obj->entity;
$this->ref = $obj->rowid;
$this->ref_ext = $obj->ref_ext;
$this->id = $obj->rowid;
$this->entity = $obj->entity;
$this->ref = $obj->rowid;
$this->ref_ext = $obj->ref_ext;
$this->civility_code = $obj->civility_code;
$this->civility = $obj->civility_code?($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code):'';
$this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : '';
$this->lastname = $obj->lastname;
$this->firstname = $obj->firstname;
$this->address = $obj->address;
$this->zip = $obj->zip;
$this->town = $obj->town;
$this->lastname = $obj->lastname;
$this->firstname = $obj->firstname;
$this->address = $obj->address;
$this->zip = $obj->zip;
$this->town = $obj->town;
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_modification = $this->db->jdate($obj->date_modification);
$this->state_id = $obj->state_id;
$this->state_code = $obj->state_code;
$this->state = $obj->state;
$this->state_id = $obj->state_id;
$this->state_code = $obj->state_code;
$this->state = $obj->state;
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_id?$obj->country_code:'';
$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):'';
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_id ? $obj->country_code : '';
$this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : '';
$this->socid = $obj->fk_soc;
$this->socname = $obj->socname;
$this->poste = $obj->poste;
$this->statut = $obj->statut;
$this->statut = $obj->statut;
$this->phone_pro = trim($obj->phone);
$this->fax = trim($obj->fax);
$this->phone_perso = trim($obj->phone_perso);
$this->phone_mobile = trim($obj->phone_mobile);
$this->phone_pro = trim($obj->phone);
$this->fax = trim($obj->fax);
$this->phone_perso = trim($obj->phone_perso);
$this->phone_mobile = trim($obj->phone_mobile);
$this->email = $obj->email;
$this->socialnetworks = (array) json_decode($obj->socialnetworks, true);
@ -847,14 +847,14 @@ class Contact extends CommonObject
$this->priv = $obj->priv;
$this->mail = $obj->email;
$this->birthday = $this->db->jdate($obj->birthday);
$this->note = $obj->note_private; // deprecated
$this->birthday = $this->db->jdate($obj->birthday);
$this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->note_public = $obj->note_public;
$this->default_lang = $obj->default_lang;
$this->user_id = $obj->user_id;
$this->user_id = $obj->user_id;
$this->user_login = $obj->user_login;
$this->canvas = $obj->canvas;
$this->canvas = $obj->canvas;
$this->import_key = $obj->import_key;
@ -1617,7 +1617,7 @@ class Contact extends CommonObject
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid." AND fk_socpeople=".$this->id;;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid." AND fk_socpeople=".$this->id; ;
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
$result = $this->db->query($sql);

View File

@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/
class box_graph_invoices_permonth extends ModeleBoxes
{
public $boxcode="invoicespermonth";
public $boximg="object_bill";
public $boxlabel="BoxCustomersInvoicesPerMonth";
public $boxcode = "invoicespermonth";
public $boximg = "object_bill";
public $boxlabel = "BoxCustomersInvoicesPerMonth";
public $depends = array("facture");
/**
@ -52,9 +52,9 @@ class box_graph_invoices_permonth extends ModeleBoxes
{
global $user;
$this->db=$db;
$this->db = $db;
$this->hidden = ! ($user->rights->facture->lire);
$this->hidden = !($user->rights->facture->lire);
}
/**
@ -67,14 +67,14 @@ class box_graph_invoices_permonth extends ModeleBoxes
{
global $conf, $user, $langs;
$this->max=$max;
$this->max = $max;
$refreshaction='refresh_'.$this->boxcode;
$refreshaction = 'refresh_'.$this->boxcode;
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
//$facturestatic=new Facture($this->db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxCustomersInvoicesPerMonth", $max);
@ -89,50 +89,50 @@ class box_graph_invoices_permonth extends ModeleBoxes
'target'=>'none' // Set '' to get target="_blank"
);
$dir=''; // We don't need a path because image file will not be saved into disk
$prefix='';
$socid=0;
if ($user->socid) $socid=$user->socid;
if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->rights->facture->lire)
{
$mesg = '';
$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
$autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
$endyear=GETPOST($param_year, 'int');
$shownb=GETPOST($param_shownb, 'alpha');
$showtot=GETPOST($param_showtot, 'alpha');
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
}
else
{
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear=$tmparray['year'];
$shownb=$tmparray['shownb'];
$showtot=$tmparray['showtot'];
$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear = $tmparray['year'];
$shownb = $tmparray['shownb'];
$showtot = $tmparray['showtot'];
}
if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; }
$nowarray=dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear=$nowarray['year'];
$startyear=$endyear-1;
$mode='customer';
$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
$HEIGHT='192';
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
$startyear = $endyear - 1;
$mode = 'customer';
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
$HEIGHT = '192';
$stats = new FactureStats($this->db, $socid, $mode, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png";
// default value for customer mode
@ -141,22 +141,22 @@ class box_graph_invoices_permonth extends ModeleBoxes
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$langs->load("bills");
$px1->SetData($data1);
unset($data1);
$i=$startyear;$legend=array();
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -168,7 +168,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->mode = 'depth';
$px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
$px1->draw($filenamenb, $fileurlnb);
@ -178,7 +178,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png";
// default value for customer mode
@ -187,22 +187,22 @@ class box_graph_invoices_permonth extends ModeleBoxes
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$langs->load("bills");
$px2->SetData($data2);
unset($data2);
$i=$startyear;$legend=array();
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -214,7 +214,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->mode = 'depth';
$px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
$px2->draw($filenamenb, $fileurlnb);
@ -224,51 +224,51 @@ class box_graph_invoices_permonth extends ModeleBoxes
if (empty($conf->use_javascript_ajax))
{
$langs->load("errors");
$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (! $mesg)
if (!$mesg)
{
$stringtoshow='';
$stringtoshow.='<script type="text/javascript" language="javascript">
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery("#idfilter'.$this->boxcode.'").toggle();
});
});
</script>';
$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow.='<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow.='<input type="hidden" name="page_y" value="">';
$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow.='<input type="checkbox" name="'.$param_shownb.'"'.($shownb?' checked':'').'> '.$langs->trans("NumberOfBillsByMonth");
$stringtoshow.=' &nbsp; ';
$stringtoshow.='<input type="checkbox" name="'.$param_showtot.'"'.($showtot?' checked':'').'> '.$langs->trans("AmountOfBillsByMonthHT");
$stringtoshow.='<br>';
$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow.='<input class="reposition inline-block valigntextbottom" type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow.='</form>';
$stringtoshow.='</div>';
$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow .= '<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow .= '<input type="hidden" name="page_y" value="">';
$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow .= '<input type="checkbox" name="'.$param_shownb.'"'.($shownb ? ' checked' : '').'> '.$langs->trans("NumberOfBillsByMonth");
$stringtoshow .= ' &nbsp; ';
$stringtoshow .= '<input type="checkbox" name="'.$param_showtot.'"'.($showtot ? ' checked' : '').'> '.$langs->trans("AmountOfBillsByMonthHT");
$stringtoshow .= '<br>';
$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow .= '<input class="reposition inline-block valigntextbottom" type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
$stringtoshow.='<div class="fichecenter">';
$stringtoshow.='<div class="fichehalfleft">';
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow.=$px1->show();
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='<div class="fichehalfright">';
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow.=$px2->show();
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='</div>';
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}
$this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"','textnoformat'=>$stringtoshow);
$this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow);
}
else
{

View File

@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/
class box_graph_invoices_supplier_permonth extends ModeleBoxes
{
public $boxcode="invoicessupplierpermonth";
public $boximg="object_bill";
public $boxlabel="BoxSuppliersInvoicesPerMonth";
public $boxcode = "invoicessupplierpermonth";
public $boximg = "object_bill";
public $boxlabel = "BoxSuppliersInvoicesPerMonth";
public $depends = array("fournisseur");
/**
@ -52,9 +52,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
{
global $user;
$this->db=$db;
$this->db = $db;
$this->hidden = ! ($user->rights->fournisseur->facture->lire);
$this->hidden = !($user->rights->fournisseur->facture->lire);
}
/**
@ -67,13 +67,13 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
{
global $conf, $user, $langs;
$this->max=$max;
$this->max = $max;
$refreshaction='refresh_'.$this->boxcode;
$refreshaction = 'refresh_'.$this->boxcode;
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max);
@ -88,48 +88,48 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
'target'=>'none' // Set '' to get target="_blank"
);
$dir=''; // We don't need a path because image file will not be saved into disk
$prefix='';
$socid=0;
if ($user->socid) $socid=$user->socid;
if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->rights->fournisseur->facture->lire)
{
$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
$autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
$endyear=GETPOST($param_year, 'int');
$shownb=GETPOST($param_shownb, 'alpha');
$showtot=GETPOST($param_showtot, 'alpha');
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
}
else
{
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear=$tmparray['year'];
$shownb=$tmparray['shownb'];
$showtot=$tmparray['showtot'];
$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear = $tmparray['year'];
$shownb = $tmparray['shownb'];
$showtot = $tmparray['showtot'];
}
if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; }
$nowarray=dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear=$nowarray['year'];
$startyear=$endyear-1;
$mode='supplier';
$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
$HEIGHT='192';
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
$startyear = $endyear - 1;
$mode = 'supplier';
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
$HEIGHT = '192';
$stats = new FactureStats($this->db, $socid, $mode, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png";
// default value for customer mode
@ -138,23 +138,23 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$langs->load("bills");
$px1->SetData($data1);
unset($data1);
$i=$startyear;
$legend=array();
$i = $startyear;
$legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -166,7 +166,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->mode = 'depth';
$px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
$px1->draw($filenamenb, $fileurlnb);
@ -176,7 +176,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png";
// default value for customer mode
@ -185,22 +185,22 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$langs->load("bills");
$px2->SetData($data2);
unset($data2);
$i=$startyear;$legend=array();
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -212,7 +212,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->mode = 'depth';
$px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
$px2->draw($filenamenb, $fileurlnb);
@ -222,51 +222,51 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
if (empty($conf->use_javascript_ajax))
{
$langs->load("errors");
$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (! $mesg)
if (!$mesg)
{
$stringtoshow='';
$stringtoshow.='<script type="text/javascript" language="javascript">
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery("#idfilter'.$this->boxcode.'").toggle();
});
});
</script>';
$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow.='<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow.='<input type="hidden" name="page_y" value="">';
$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow.='<input type="checkbox" name="'.$param_shownb.'"'.($shownb?' checked':'').'> '.$langs->trans("NumberOfBillsByMonth");
$stringtoshow.=' &nbsp; ';
$stringtoshow.='<input type="checkbox" name="'.$param_showtot.'"'.($showtot?' checked':'').'> '.$langs->trans("AmountOfBillsByMonthHT");
$stringtoshow.='<br>';
$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow.='<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow.='</form>';
$stringtoshow.='</div>';
$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow .= '<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow .= '<input type="hidden" name="page_y" value="">';
$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow .= '<input type="checkbox" name="'.$param_shownb.'"'.($shownb ? ' checked' : '').'> '.$langs->trans("NumberOfBillsByMonth");
$stringtoshow .= ' &nbsp; ';
$stringtoshow .= '<input type="checkbox" name="'.$param_showtot.'"'.($showtot ? ' checked' : '').'> '.$langs->trans("AmountOfBillsByMonthHT");
$stringtoshow .= '<br>';
$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
$stringtoshow.='<div class="fichecenter">';
$stringtoshow.='<div class="fichehalfleft">';
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow.=$px1->show();
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='<div class="fichehalfright">';
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow.=$px2->show();
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='</div>';
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}
$this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"','td' => 'class="nohover center"','textnoformat'=>$stringtoshow);
$this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow);
}
else
{

View File

@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/
class box_graph_orders_permonth extends ModeleBoxes
{
public $boxcode="orderspermonth";
public $boximg="object_order";
public $boxlabel="BoxCustomersOrdersPerMonth";
public $boxcode = "orderspermonth";
public $boximg = "object_order";
public $boxlabel = "BoxCustomersOrdersPerMonth";
public $depends = array("commande");
/**
@ -52,9 +52,9 @@ class box_graph_orders_permonth extends ModeleBoxes
{
global $user;
$this->db=$db;
$this->db = $db;
$this->hidden = ! ($user->rights->commande->lire);
$this->hidden = !($user->rights->commande->lire);
}
/**
@ -67,14 +67,14 @@ class box_graph_orders_permonth extends ModeleBoxes
{
global $conf, $user, $langs;
$this->max=$max;
$this->max = $max;
$refreshaction='refresh_'.$this->boxcode;
$refreshaction = 'refresh_'.$this->boxcode;
//include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
//$commandestatic=new Commande($this->db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxCustomersOrdersPerMonth", $max);
@ -89,50 +89,50 @@ class box_graph_orders_permonth extends ModeleBoxes
'target'=>'none' // Set '' to get target="_blank"
);
$dir=''; // We don't need a path because image file will not be saved into disk
$prefix='';
$socid=0;
if ($user->socid) $socid=$user->socid;
if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->rights->commande->lire)
{
$langs->load("orders");
$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
$autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
$endyear=GETPOST($param_year, 'int');
$shownb=GETPOST($param_shownb, 'alpha');
$showtot=GETPOST($param_showtot, 'alpha');
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
}
else
{
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear=$tmparray['year'];
$shownb=$tmparray['shownb'];
$showtot=$tmparray['showtot'];
$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear = $tmparray['year'];
$shownb = $tmparray['shownb'];
$showtot = $tmparray['showtot'];
}
if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; }
$nowarray=dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear=$nowarray['year'];
$startyear=$endyear-1;
$mode='customer';
$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
$HEIGHT='192';
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
$startyear = $endyear - 1;
$mode = 'customer';
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
$HEIGHT = '192';
$stats = new CommandeStats($this->db, $socid, $mode, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png";
// default value for customer mode
@ -141,21 +141,21 @@ class box_graph_orders_permonth extends ModeleBoxes
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$px1->SetData($data1);
unset($data1);
$i=$startyear;
$legend=array();
$i = $startyear;
$legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -167,7 +167,7 @@ class box_graph_orders_permonth extends ModeleBoxes
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->mode = 'depth';
$px1->SetTitle($langs->trans("NumberOfOrdersByMonth"));
$px1->draw($filenamenb, $fileurlnb);
@ -177,7 +177,7 @@ class box_graph_orders_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png";
// default value for customer mode
@ -186,20 +186,20 @@ class box_graph_orders_permonth extends ModeleBoxes
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$px2->SetData($data2);
unset($data2);
$i=$startyear;$legend=array();
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -211,7 +211,7 @@ class box_graph_orders_permonth extends ModeleBoxes
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->mode = 'depth';
$px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));
$px2->draw($filenamenb, $fileurlnb);
@ -221,49 +221,49 @@ class box_graph_orders_permonth extends ModeleBoxes
if (empty($conf->use_javascript_ajax))
{
$langs->load("errors");
$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (! $mesg)
if (!$mesg)
{
$stringtoshow='';
$stringtoshow.='<script type="text/javascript" language="javascript">
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery("#idfilter'.$this->boxcode.'").toggle();
});
});
</script>';
$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow.='<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow.='<input type="hidden" name="page_y" value="">';
$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow.='<input type="checkbox" name="'.$param_shownb.'"'.($shownb?' checked':'').'> '.$langs->trans("NumberOfOrdersByMonth");
$stringtoshow.=' &nbsp; ';
$stringtoshow.='<input type="checkbox" name="'.$param_showtot.'"'.($showtot?' checked':'').'> '.$langs->trans("AmountOfOrdersByMonthHT");
$stringtoshow.='<br>';
$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow.='<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow.='</form>';
$stringtoshow.='</div>';
$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow .= '<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow .= '<input type="hidden" name="page_y" value="">';
$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow .= '<input type="checkbox" name="'.$param_shownb.'"'.($shownb ? ' checked' : '').'> '.$langs->trans("NumberOfOrdersByMonth");
$stringtoshow .= ' &nbsp; ';
$stringtoshow .= '<input type="checkbox" name="'.$param_showtot.'"'.($showtot ? ' checked' : '').'> '.$langs->trans("AmountOfOrdersByMonthHT");
$stringtoshow .= '<br>';
$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
$stringtoshow.='<div class="fichecenter">';
$stringtoshow.='<div class="fichehalfleft">';
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow.=$px1->show();
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='<div class="fichehalfright">';
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow.=$px2->show();
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='</div>';
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}
$this->info_box_contents[0][0] = array(
'tr'=>'class="oddeven nohover"',

View File

@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/
class box_graph_orders_supplier_permonth extends ModeleBoxes
{
public $boxcode="orderssupplierpermonth";
public $boximg="object_order";
public $boxlabel="BoxSuppliersOrdersPerMonth";
public $boxcode = "orderssupplierpermonth";
public $boximg = "object_order";
public $boxlabel = "BoxSuppliersOrdersPerMonth";
public $depends = array("fournisseur");
/**
@ -52,9 +52,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
{
global $user;
$this->db=$db;
$this->db = $db;
$this->hidden = ! ($user->rights->fournisseur->commande->lire);
$this->hidden = !($user->rights->fournisseur->commande->lire);
}
/**
@ -67,13 +67,13 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
{
global $conf, $user, $langs;
$this->max=$max;
$this->max = $max;
$refreshaction='refresh_'.$this->boxcode;
$refreshaction = 'refresh_'.$this->boxcode;
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$text = $langs->trans("BoxSuppliersOrdersPerMonth", $max);
@ -88,50 +88,50 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
'target'=>'none' // Set '' to get target="_blank"
);
$dir=''; // We don't need a path because image file will not be saved into disk
$prefix='';
$socid=0;
if ($user->socid) $socid=$user->socid;
if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->rights->fournisseur->commande->lire)
{
$langs->load("orders");
$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
$autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
$endyear=GETPOST($param_year, 'int');
$shownb=GETPOST($param_shownb, 'alpha');
$showtot=GETPOST($param_showtot, 'alpha');
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
}
else
{
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear=$tmparray['year'];
$shownb=$tmparray['shownb'];
$showtot=$tmparray['showtot'];
$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear = $tmparray['year'];
$shownb = $tmparray['shownb'];
$showtot = $tmparray['showtot'];
}
if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; }
$nowarray=dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear=$nowarray['year'];
$startyear=$endyear-1;
$mode='supplier';
$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
$HEIGHT='192';
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
$startyear = $endyear - 1;
$mode = 'supplier';
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
$HEIGHT = '192';
$stats = new CommandeStats($this->db, $socid, $mode, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png";
// default value for customer mode
@ -140,21 +140,21 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$px1->SetData($data1);
unset($data1);
$i=$startyear;
$legend=array();
$i = $startyear;
$legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -166,7 +166,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->mode = 'depth';
$px1->SetTitle($langs->trans("NumberOfOrdersByMonth"));
$px1->draw($filenamenb, $fileurlnb);
@ -176,7 +176,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png";
// default value for customer mode
@ -185,20 +185,20 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$px2->SetData($data2);
unset($data2);
$i=$startyear;$legend=array();
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -210,7 +210,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->mode = 'depth';
$px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));
$px2->draw($filenamenb, $fileurlnb);
@ -220,49 +220,49 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
if (empty($conf->use_javascript_ajax))
{
$langs->load("errors");
$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (! $mesg)
if (!$mesg)
{
$stringtoshow='';
$stringtoshow.='<script type="text/javascript" language="javascript">
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery("#idfilter'.$this->boxcode.'").toggle();
});
});
</script>';
$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow.='<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow.='<input type="hidden" name="page_y" value="">';
$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow.='<input type="checkbox" name="'.$param_shownb.'"'.($shownb?' checked':'').'> '.$langs->trans("NumberOfOrdersByMonth");
$stringtoshow.=' &nbsp; ';
$stringtoshow.='<input type="checkbox" name="'.$param_showtot.'"'.($showtot?' checked':'').'> '.$langs->trans("AmountOfOrdersByMonthHT");
$stringtoshow.='<br>';
$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow.='<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow.='</form>';
$stringtoshow.='</div>';
$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow .= '<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow .= '<input type="hidden" name="page_y" value="">';
$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow .= '<input type="checkbox" name="'.$param_shownb.'"'.($shownb ? ' checked' : '').'> '.$langs->trans("NumberOfOrdersByMonth");
$stringtoshow .= ' &nbsp; ';
$stringtoshow .= '<input type="checkbox" name="'.$param_showtot.'"'.($showtot ? ' checked' : '').'> '.$langs->trans("AmountOfOrdersByMonthHT");
$stringtoshow .= '<br>';
$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
$stringtoshow.='<div class="fichecenter">';
$stringtoshow.='<div class="fichehalfleft">';
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow.=$px1->show();
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='<div class="fichehalfright">';
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow.=$px2->show();
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='</div>';
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}
$this->info_box_contents[0][0] = array(
'tr'=>'class="oddeven nohover"',

View File

@ -29,10 +29,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
*/
class box_graph_product_distribution extends ModeleBoxes
{
public $boxcode="productdistribution";
public $boximg="object_product";
public $boxlabel="BoxProductDistribution";
public $depends = array("product|service","facture|propal|commande");
public $boxcode = "productdistribution";
public $boximg = "object_product";
public $boxlabel = "BoxProductDistribution";
public $depends = array("product|service", "facture|propal|commande");
/**
* @var DoliDB Database handler.
@ -55,12 +55,12 @@ class box_graph_product_distribution extends ModeleBoxes
{
global $user, $conf;
$this->db=$db;
$this->db = $db;
$this->hidden = ! (
(! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
|| (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
|| (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
$this->hidden = !(
(!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
|| (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire))
|| (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire))
);
}
@ -74,43 +74,43 @@ class box_graph_product_distribution extends ModeleBoxes
{
global $conf, $user, $langs;
$this->max=$max;
$this->max = $max;
$refreshaction='refresh_'.$this->boxcode;
$refreshaction = 'refresh_'.$this->boxcode;
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb';
$param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
$param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
$autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_showinvoicenb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb';
$param_showpropalnb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
$param_showordernb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
$year=GETPOST($param_year, 'int');
$showinvoicenb=GETPOST($param_showinvoicenb, 'alpha');
$showpropalnb=GETPOST($param_showpropalnb, 'alpha');
$showordernb=GETPOST($param_showordernb, 'alpha');
$year = GETPOST($param_year, 'int');
$showinvoicenb = GETPOST($param_showinvoicenb, 'alpha');
$showpropalnb = GETPOST($param_showpropalnb, 'alpha');
$showordernb = GETPOST($param_showordernb, 'alpha');
}
else
{
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$year=$tmparray['year'];
$showinvoicenb=$tmparray['showinvoicenb'];
$showpropalnb=$tmparray['showpropalnb'];
$showordernb=$tmparray['showordernb'];
$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$year = $tmparray['year'];
$showinvoicenb = $tmparray['showinvoicenb'];
$showpropalnb = $tmparray['showpropalnb'];
$showordernb = $tmparray['showordernb'];
}
if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; }
if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0;
if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0;
if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0;
if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb = 1; $showinvoicenb = 1; $showordernb = 1; }
if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb = 0;
if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb = 0;
if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb = 0;
$nowarray=dol_getdate(dol_now(), true);
if (empty($year)) $year=$nowarray['year'];
$nowarray = dol_getdate(dol_now(), true);
if (empty($year)) $year = $nowarray['year'];
$nbofgraph=0;
$nbofgraph = 0;
if ($showinvoicenb) $nbofgraph++;
if ($showpropalnb) $nbofgraph++;
if ($showordernb) $nbofgraph++;
@ -128,13 +128,13 @@ class box_graph_product_distribution extends ModeleBoxes
);
$socid=empty($user->socid)?0:$user->socid;
$userid=0; // No filter on user creation
$socid = empty($user->socid) ? 0 : $user->socid;
$userid = 0; // No filter on user creation
$WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320';
$HEIGHT='192';
$WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320';
$HEIGHT = '192';
if (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire))
if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
{
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showinvoicenb)
@ -143,34 +143,34 @@ class box_graph_product_distribution extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
$showpointvalue = 1; $nocolor = 0;
$mode='customer';
$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid>0?$userid:0));
$data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)));
$mode = 'customer';
$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
$data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
if (empty($data1))
{
$showpointvalue=0;
$nocolor=1;
$data1=array(array(0=>$langs->trans("None"),1=>1));
$showpointvalue = 0;
$nocolor = 1;
$data1 = array(array(0=>$langs->trans("None"), 1=>1));
}
$filenamenb = $dir."/prodserforinvoice-".$year.".png";
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&amp;file=prodserforinvoice-'.$year.'.png';
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$i=0;$tot=count($data1);$legend=array();
$i = 0; $tot = count($data1); $legend = array();
while ($i <= $tot)
{
$data1[$i][0]=dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
$legend[]=$data1[$i][0];
$data1[$i][0] = dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
$legend[] = $data1[$i][0];
$i++;
}
$px1->SetData($data1);
unset($data1);
if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220)));
$px1->SetLegend($legend);
$px1->setShowLegend(0);
$px1->setShowPointValue($showpointvalue);
@ -192,7 +192,7 @@ class box_graph_product_distribution extends ModeleBoxes
}
}
if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire))
if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire))
{
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showpropalnb)
@ -201,13 +201,13 @@ class box_graph_product_distribution extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
$showpointvalue = 1; $nocolor = 0;
$stats_proposal = new PropaleStats($this->db, $socid, ($userid>0?$userid:0));
$data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)));
$stats_proposal = new PropaleStats($this->db, $socid, ($userid > 0 ? $userid : 0));
$data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
if (empty($data2))
{
$showpointvalue = 0;
$nocolor = 1;
$data2=array(array(0=>$langs->trans("None"),1=>1));
$data2 = array(array(0=>$langs->trans("None"), 1=>1));
}
$filenamenb = $dir."/prodserforpropal-".$year.".png";
@ -215,20 +215,20 @@ class box_graph_product_distribution extends ModeleBoxes
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$i=0;$tot=count($data2);$legend=array();
$i = 0; $tot = count($data2); $legend = array();
while ($i <= $tot)
{
$data2[$i][0]=dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
$legend[]=$data2[$i][0];
$data2[$i][0] = dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
$legend[] = $data2[$i][0];
$i++;
}
$px2->SetData($data2);
unset($data2);
if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
if ($nocolor) $px2->SetDataColor(array(array(220, 220, 220)));
$px2->SetLegend($legend);
$px2->setShowLegend(0);
$px2->setShowPointValue($showpointvalue);
@ -250,7 +250,7 @@ class box_graph_product_distribution extends ModeleBoxes
}
}
if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire))
if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire))
{
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showordernb)
@ -259,14 +259,14 @@ class box_graph_product_distribution extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
$showpointvalue = 1; $nocolor = 0;
$mode='customer';
$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid>0?$userid:0));
$data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)));
$mode = 'customer';
$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
$data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)));
if (empty($data3))
{
$showpointvalue = 0;
$nocolor = 1;
$data3=array(array(0=>$langs->trans("None"),1=>1));
$data3 = array(array(0=>$langs->trans("None"), 1=>1));
}
$filenamenb = $dir."/prodserfororder-".$year.".png";
@ -274,20 +274,20 @@ class box_graph_product_distribution extends ModeleBoxes
$px3 = new DolGraph();
$mesg = $px3->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$i=0;$tot=count($data3);$legend=array();
$i = 0; $tot = count($data3); $legend = array();
while ($i <= $tot)
{
$data3[$i][0]=dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
$legend[]=$data3[$i][0];
$data3[$i][0] = dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas"
$legend[] = $data3[$i][0];
$i++;
}
$px3->SetData($data3);
unset($data3);
if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
if ($nocolor) $px3->SetDataColor(array(array(220, 220, 220)));
$px3->SetLegend($legend);
$px3->setShowLegend(0);
$px3->setShowPointValue($showpointvalue);
@ -312,76 +312,76 @@ class box_graph_product_distribution extends ModeleBoxes
if (empty($nbofgraph))
{
$langs->load("errors");
$mesg=$langs->trans("ReadPermissionNotAllowed");
$mesg = $langs->trans("ReadPermissionNotAllowed");
}
if (empty($conf->use_javascript_ajax))
{
$langs->load("errors");
$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (! $mesg)
if (!$mesg)
{
$stringtoshow='';
$stringtoshow.='<script type="text/javascript" language="javascript">
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery("#idfilter'.$this->boxcode.'").toggle();
});
});
</script>';
$stringtoshow.='<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow.='<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow.='<input type="hidden" name="page_y" value="">';
$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire))
$stringtoshow .= '<div class="center hideobject" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow .= '<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow .= '<input type="hidden" name="page_y" value="">';
$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire))
{
$stringtoshow.='<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb?' checked':'').'> '.$langs->trans("ForCustomersInvoices");
$stringtoshow.=' &nbsp; ';
$stringtoshow .= '<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb ? ' checked' : '').'> '.$langs->trans("ForCustomersInvoices");
$stringtoshow .= ' &nbsp; ';
}
if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire))
if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire))
{
$stringtoshow.='<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb?' checked':'').'> '.$langs->trans("ForProposals");
$stringtoshow.='&nbsp;';
$stringtoshow .= '<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb ? ' checked' : '').'> '.$langs->trans("ForProposals");
$stringtoshow .= '&nbsp;';
}
if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire))
if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire))
{
$stringtoshow.='<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb?' checked':'').'> '.$langs->trans("ForCustomersOrders");
$stringtoshow .= '<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb ? ' checked' : '').'> '.$langs->trans("ForCustomersOrders");
}
$stringtoshow.='<br>';
$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
$stringtoshow.='<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto('', 'refresh.png', '', '', 1).'">';
$stringtoshow.='</form>';
$stringtoshow.='</div>';
$stringtoshow .= '<br>';
$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$year.'">';
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto('', 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($nbofgraph == 1)
{
if ($showinvoicenb) $stringtoshow.=$px1->show();
elseif ($showpropalnb) $stringtoshow.=$px2->show();
else $stringtoshow.=$px3->show();
if ($showinvoicenb) $stringtoshow .= $px1->show();
elseif ($showpropalnb) $stringtoshow .= $px2->show();
else $stringtoshow .= $px3->show();
}
if ($nbofgraph == 2)
{
$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
if ($showinvoicenb) $stringtoshow.=$px1->show();
elseif ($showpropalnb) $stringtoshow.=$px2->show();
$stringtoshow.='</div><div class="fichehalfright">';
if ($showordernb) $stringtoshow.=$px3->show();
elseif ($showpropalnb) $stringtoshow.=$px2->show();
$stringtoshow.='</div></div></div>';
$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
if ($showinvoicenb) $stringtoshow .= $px1->show();
elseif ($showpropalnb) $stringtoshow .= $px2->show();
$stringtoshow .= '</div><div class="fichehalfright">';
if ($showordernb) $stringtoshow .= $px3->show();
elseif ($showpropalnb) $stringtoshow .= $px2->show();
$stringtoshow .= '</div></div></div>';
}
if ($nbofgraph == 3)
{
$stringtoshow.='<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
$stringtoshow.=$px1->show();
$stringtoshow.='</div><div class="fichehalfright">';
$stringtoshow.=$px2->show();
$stringtoshow.='</div></div></div>';
$stringtoshow.='<div class="fichecenter"><div class="containercenter">';
$stringtoshow.=$px3->show();
$stringtoshow.='</div></div>';
$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
$stringtoshow .= $px1->show();
$stringtoshow .= '</div><div class="fichehalfright">';
$stringtoshow .= $px2->show();
$stringtoshow .= '</div></div></div>';
$stringtoshow .= '<div class="fichecenter"><div class="containercenter">';
$stringtoshow .= $px3->show();
$stringtoshow .= '</div></div>';
}
$this->info_box_contents[0][0] = array(
'tr'=>'class="oddeven nohover"',

View File

@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/
class box_graph_propales_permonth extends ModeleBoxes
{
public $boxcode="propalpermonth";
public $boximg="object_propal";
public $boxlabel="BoxProposalsPerMonth";
public $boxcode = "propalpermonth";
public $boximg = "object_propal";
public $boxlabel = "BoxProposalsPerMonth";
public $depends = array("propal");
/**
@ -54,7 +54,7 @@ class box_graph_propales_permonth extends ModeleBoxes
$this->db = $db;
$this->hidden = ! ($user->rights->propale->lire);
$this->hidden = !($user->rights->propale->lire);
}
/**
@ -67,14 +67,14 @@ class box_graph_propales_permonth extends ModeleBoxes
{
global $conf, $user, $langs;
$this->max=$max;
$this->max = $max;
$refreshaction='refresh_'.$this->boxcode;
$refreshaction = 'refresh_'.$this->boxcode;
//include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
//$propalstatic=new Propal($this->db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
$langs->load("propal");
@ -83,7 +83,7 @@ class box_graph_propales_permonth extends ModeleBoxes
$this->info_box_head = array(
'text' => $text,
'limit'=> dol_strlen($text),
'graph'=> 1, // Set to 1 if it's a box graph
'graph'=> 1, // Set to 1 if it's a box graph
'sublink'=>'',
'subtext'=>$langs->trans("Filter"),
'subpicto'=>'filter.png',
@ -91,69 +91,69 @@ class box_graph_propales_permonth extends ModeleBoxes
'target'=>'none' // Set '' to get target="_blank"
);
$dir=''; // We don't need a path because image file will not be saved into disk
$prefix='';
$socid=0;
if ($user->socid) $socid=$user->socid;
if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->rights->propale->lire)
{
$param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
$autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
$endyear=GETPOST($param_year, 'int');
$shownb=GETPOST($param_shownb, 'alpha');
$showtot=GETPOST($param_showtot, 'alpha');
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
}
else
{
$tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear=$tmparray['year'];
$shownb=$tmparray['shownb'];
$showtot=$tmparray['showtot'];
$tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true);
$endyear = $tmparray['year'];
$shownb = $tmparray['shownb'];
$showtot = $tmparray['showtot'];
}
if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; }
$nowarray=dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear=$nowarray['year'];
$startyear=$endyear-1;
$WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320';
$HEIGHT='192';
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
$startyear = $endyear - 1;
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
$HEIGHT = '192';
$stats = new PropaleStats($this->db, $socid, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars');
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$datatype1 = array_pad(array(), ($endyear - $startyear + 1), 'bars');
$filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png";
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&amp;file=propalsnbinyear-'.$endyear.'.png';
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$px1->SetType($datatype1);
$px1->SetData($data1);
unset($data1);
$i=$startyear;$legend=array();
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -165,7 +165,7 @@ class box_graph_propales_permonth extends ModeleBoxes
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->mode = 'depth';
$px1->SetTitle($langs->trans("NumberOfProposalsByMonth"));
$px1->draw($filenamenb, $fileurlnb);
@ -175,8 +175,8 @@ class box_graph_propales_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars');
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$datatype2 = array_pad(array(), ($endyear - $startyear + 1), 'bars');
//$datatype2 = array('lines','bars');
$filenamenb = $dir."/".$prefix."propalsamountinyear-".$endyear.".png";
@ -185,21 +185,21 @@ class box_graph_propales_permonth extends ModeleBoxes
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (! $mesg)
if (!$mesg)
{
$px2->SetType($datatype2);
$px2->SetData($data2);
unset($data2);
$i=$startyear;$legend=array();
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
$legend[]=sprintf("%d/%d", $i-2001, $i-2000);
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
}
else
{
$legend[]=$i;
$legend[] = $i;
}
$i++;
}
@ -211,7 +211,7 @@ class box_graph_propales_permonth extends ModeleBoxes
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->mode = 'depth';
$px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT"));
$px2->draw($filenamenb, $fileurlnb);
@ -221,49 +221,49 @@ class box_graph_propales_permonth extends ModeleBoxes
if (empty($conf->use_javascript_ajax))
{
$langs->load("errors");
$mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (! $mesg)
if (!$mesg)
{
$stringtoshow='';
$stringtoshow.='<script type="text/javascript" language="javascript">
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery("#idfilter'.$this->boxcode.'").toggle();
});
});
</script>';
$stringtoshow.='<div class="center hideobject divboxfilter" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow.='<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow.='<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow.='<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow.='<input type="hidden" name="page_y" value="">';
$stringtoshow.='<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow.='<input type="checkbox" name="'.$param_shownb.'"'.($shownb?' checked':'').'> '.$langs->trans("NumberOfProposalsByMonth");
$stringtoshow.=' &nbsp; ';
$stringtoshow.='<input type="checkbox" name="'.$param_showtot.'"'.($showtot?' checked':'').'> '.$langs->trans("AmountOfProposalsByMonthHT");
$stringtoshow.='<br>';
$stringtoshow.=$langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow.='<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow.='</form>';
$stringtoshow.='</div>';
$stringtoshow .= '<div class="center hideobject divboxfilter" id="idfilter'.$this->boxcode.'">'; // hideobject is to start hidden
$stringtoshow .= '<form class="flat formboxfilter" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
$stringtoshow .= '<input type="hidden" name="token" value="'.newToken().'">';
$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow .= '<input type="hidden" name="page_y" value="">';
$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,shownb,showtot">';
$stringtoshow .= '<input type="checkbox" name="'.$param_shownb.'"'.($shownb ? ' checked' : '').'> '.$langs->trans("NumberOfProposalsByMonth");
$stringtoshow .= ' &nbsp; ';
$stringtoshow .= '<input type="checkbox" name="'.$param_showtot.'"'.($showtot ? ' checked' : '').'> '.$langs->trans("AmountOfProposalsByMonthHT");
$stringtoshow .= '<br>';
$stringtoshow .= $langs->trans("Year").' <input class="flat" size="4" type="text" name="'.$param_year.'" value="'.$endyear.'">';
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
$stringtoshow.='<div class="fichecenter">';
$stringtoshow.='<div class="fichehalfleft">';
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow.=$px1->show();
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='<div class="fichehalfright">';
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow.=$px2->show();
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
$stringtoshow.='</div>';
$stringtoshow.='</div>';
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}
$this->info_box_contents[0][0] = array(
'tr'=>'class="oddeven nohover"',

View File

@ -118,16 +118,16 @@ class box_task extends ModeleBoxes
// list the summary of the orders
if ($user->rights->projet->lire) {
$boxcontent.= '<div id="ancor-idfilter'.$this->boxcode.'" style="display: block; position: absolute; margin-top: -100px"></div>'."\n";
$boxcontent.= '<div id="idfilter'.$this->boxcode.'" class="center" >'."\n";
$boxcontent.= '<form class="flat " method="POST" action="'.$_SERVER["PHP_SELF"].'#ancor-idfilter'.$this->boxcode.'">'."\n";
$boxcontent.= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
$boxcontent .= '<div id="ancor-idfilter'.$this->boxcode.'" style="display: block; position: absolute; margin-top: -100px"></div>'."\n";
$boxcontent .= '<div id="idfilter'.$this->boxcode.'" class="center" >'."\n";
$boxcontent .= '<form class="flat " method="POST" action="'.$_SERVER["PHP_SELF"].'#ancor-idfilter'.$this->boxcode.'">'."\n";
$boxcontent .= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
$selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject"));
$boxcontent.= $form->selectArray($cookie_name, $selectArray, $filterValue);
$boxcontent.= '<button type="submit" class="button">'.$langs->trans("Refresh").'</button>';
$boxcontent.= '</form>'."\n";
$boxcontent.= '</div>'."\n";
$boxcontent.= '<script type="text/javascript" language="javascript">
$boxcontent .= $form->selectArray($cookie_name, $selectArray, $filterValue);
$boxcontent .= '<button type="submit" class="button">'.$langs->trans("Refresh").'</button>';
$boxcontent .= '</form>'."\n";
$boxcontent .= '</div>'."\n";
$boxcontent .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#idsubimg'.$this->boxcode.'").click(function() {
jQuery(".showiffilter'.$this->boxcode.'").toggle();

View File

@ -37,7 +37,7 @@ class FormBarCode
/**
* @var string Error code (or message)
*/
public $error='';
public $error = '';
/**
@ -81,8 +81,8 @@ class FormBarCode
}
// We check if barcode is already selected by default
if (((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) ||
(! empty($conf->societe->enabled) && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id))
if (((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) ||
(!empty($conf->societe->enabled) && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id))
{
$disable = 'disabled';
}
@ -90,24 +90,24 @@ class FormBarCode
if (!empty($conf->use_javascript_ajax))
{
$select_encoder = '<form action="'.DOL_URL_ROOT.'/admin/barcode.php" method="POST" id="form'.$idForm.'">';
$select_encoder.= '<input type="hidden" name="token" value="'.newToken().'">';
$select_encoder.= '<input type="hidden" name="action" value="update">';
$select_encoder.= '<input type="hidden" name="code_id" value="'.$code_id.'">';
$select_encoder .= '<input type="hidden" name="token" value="'.newToken().'">';
$select_encoder .= '<input type="hidden" name="action" value="update">';
$select_encoder .= '<input type="hidden" name="code_id" value="'.$code_id.'">';
}
$selectname=(!empty($conf->use_javascript_ajax)?'coder':'coder'.$code_id);
$select_encoder.= '<select id="select'.$idForm.'" class="flat" name="'.$selectname.'">';
$select_encoder.= '<option value="0"'.($selected==0?' selected':'').' '.$disable.'>'.$langs->trans('Disable').'</option>';
$select_encoder.= '<option value="-1" disabled>--------------------</option>';
foreach($barcodelist as $key => $value)
$selectname = (!empty($conf->use_javascript_ajax) ? 'coder' : 'coder'.$code_id);
$select_encoder .= '<select id="select'.$idForm.'" class="flat" name="'.$selectname.'">';
$select_encoder .= '<option value="0"'.($selected == 0 ? ' selected' : '').' '.$disable.'>'.$langs->trans('Disable').'</option>';
$select_encoder .= '<option value="-1" disabled>--------------------</option>';
foreach ($barcodelist as $key => $value)
{
$select_encoder.= '<option value="'.$key.'"'.($selected==$key?' selected':'').'>'.$value.'</option>';
$select_encoder .= '<option value="'.$key.'"'.($selected == $key ? ' selected' : '').'>'.$value.'</option>';
}
$select_encoder.= '</select>';
$select_encoder .= '</select>';
if (!empty($conf->use_javascript_ajax))
{
$select_encoder.= '</form>';
$select_encoder .= '</form>';
}
return $select_encoder;
@ -144,10 +144,10 @@ class FormBarCode
$out = '';
$sql = "SELECT rowid, code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
$sql.= " WHERE coder <> '0'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " ORDER BY code";
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
$sql .= " WHERE coder <> '0'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " ORDER BY code";
$result = $this->db->query($sql);
if ($result) {
@ -155,20 +155,20 @@ class FormBarCode
$i = 0;
if ($useempty && $num > 0) {
$out .= '<select class="flat minwidth75imp" name="' . $htmlname . '" id="select_' . $htmlname . '">';
$out .= '<select class="flat minwidth75imp" name="'.$htmlname.'" id="select_'.$htmlname.'">';
$out .= '<option value="0">&nbsp;</option>';
} else {
$langs->load("errors");
$out .= '<select disabled class="flat minwidth75imp" name="' . $htmlname . '" id="select_' . $htmlname . '">';
$out .= '<option value="0" selected>' . $langs->trans('ErrorNoActivatedBarcode') . '</option>';
$out .= '<select disabled class="flat minwidth75imp" name="'.$htmlname.'" id="select_'.$htmlname.'">';
$out .= '<option value="0" selected>'.$langs->trans('ErrorNoActivatedBarcode').'</option>';
}
while ($i < $num) {
$obj = $this->db->fetch_object($result);
if ($selected == $obj->rowid) {
$out .= '<option value="' . $obj->rowid . '" selected>';
$out .= '<option value="'.$obj->rowid.'" selected>';
} else {
$out .= '<option value="' . $obj->rowid . '">';
$out .= '<option value="'.$obj->rowid.'">';
}
$out .= $obj->libelle;
$out .= '</option>';
@ -212,14 +212,14 @@ class FormBarCode
global $langs, $conf;
$out = '';
if ($htmlname != "none") {
$out .= '<form method="post" action="' . $page . '">';
$out .= '<input type="hidden" name="token" value="' . newToken() . '">';
$out .= '<form method="post" action="'.$page.'">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
$out .= '<input type="hidden" name="action" value="set'.$htmlname.'">';
$out .= '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
$out .= '<tr><td>';
$out .= $this->selectBarcodeType($selected, $htmlname, 1);
$out .= '</td>';
$out .= '<td class="left"><input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
$out .= '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
$out .= '</td></tr></table></form>';
}
return $out;

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
* \ingroup notification
* \brief File of class to manage notifications
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
/**
@ -44,7 +44,7 @@ class Notify
/**
* @var string Error code (or message)
*/
public $error='';
public $error = '';
/**
* @var string[] Error codes (or messages)
@ -110,27 +110,27 @@ class Notify
global $langs;
$langs->load("mails");
$listofnotiftodo=$this->getNotificationsArray($action, $socid, $object, 0);
$listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0);
$nb=-1;
if (is_array($listofnotiftodo)) $nb=count($listofnotiftodo);
if ($nb < 0) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend");
if ($nb == 0) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent");
if ($nb == 1) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent");
if ($nb >= 2) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb);
$nb = -1;
if (is_array($listofnotiftodo)) $nb = count($listofnotiftodo);
if ($nb < 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend");
if ($nb == 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent");
if ($nb == 1) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent");
if ($nb >= 2) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb);
if (is_array($listofnotiftodo))
{
$i=0;
$i = 0;
foreach ($listofnotiftodo as $key => $val)
{
if ($i) $texte.=', ';
else $texte.=' (';
if ($val['isemailvalid']) $texte.=$val['email'];
else $texte.=$val['emaildesc'];
if ($i) $texte .= ', ';
else $texte .= ' (';
if ($val['isemailvalid']) $texte .= $val['email'];
else $texte .= $val['emaildesc'];
$i++;
}
if ($i) $texte.=')';
if ($i) $texte .= ')';
}
return $texte;
@ -150,31 +150,31 @@ class Notify
{
global $conf, $user;
$error=0;
$resarray=array();
$error = 0;
$resarray = array();
$valueforthreshold = 0;
if (is_object($object)) $valueforthreshold = $object->total_ht;
if (! $error)
if (!$error)
{
if ($socid >= 0 && in_array('thirdparty', $scope))
{
$sql = "SELECT a.code, c.email, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."socpeople as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE n.fk_contact = c.rowid";
$sql.= " AND a.rowid = n.fk_action";
$sql.= " AND n.fk_soc = s.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql .= " ".MAIN_DB_PREFIX."socpeople as c,";
$sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE n.fk_contact = c.rowid";
$sql .= " AND a.rowid = n.fk_action";
$sql .= " AND n.fk_soc = s.rowid";
if ($notifcode)
{
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage
else $sql .= " AND a.code = '".$notifcode."'"; // New usage
}
$sql.= " AND s.entity IN (".getEntity('societe').")";
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
$sql .= " AND s.entity IN (".getEntity('societe').")";
if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
@ -182,14 +182,14 @@ class Notify
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$newval2=trim($obj->email);
$isvalid=isValidEmail($newval2);
$newval2 = trim($obj->email);
$isvalid = isValidEmail($newval2);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
}
$i++;
@ -198,28 +198,28 @@ class Notify
else
{
$error++;
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
}
}
}
if (! $error)
if (!$error)
{
if ($userid >= 0 && in_array('user', $scope))
{
$sql = "SELECT a.code, c.email, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."user as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql.= " WHERE n.fk_user = c.rowid";
$sql.= " AND a.rowid = n.fk_action";
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql .= " ".MAIN_DB_PREFIX."user as c,";
$sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql .= " WHERE n.fk_user = c.rowid";
$sql .= " AND a.rowid = n.fk_action";
if ($notifcode)
{
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage
else $sql .= " AND a.code = '".$notifcode."'"; // New usage
}
$sql.= " AND c.entity IN (".getEntity('user').")";
if ($userid > 0) $sql.= " AND c.rowid = ".$userid;
$sql .= " AND c.entity IN (".getEntity('user').")";
if ($userid > 0) $sql .= " AND c.rowid = ".$userid;
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
@ -227,14 +227,14 @@ class Notify
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$newval2=trim($obj->email);
$isvalid=isValidEmail($newval2);
$newval2 = trim($obj->email);
$isvalid = isValidEmail($newval2);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
}
$i++;
@ -243,49 +243,49 @@ class Notify
else
{
$error++;
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
}
}
}
if (! $error)
if (!$error)
{
if (in_array('global', $scope))
{
// List of notifications enabled for fixed email
foreach($conf->global as $key => $val)
foreach ($conf->global as $key => $val)
{
if ($notifcode)
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
}
else
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
}
$threshold = (float) $reg[1];
if ($valueforthreshold < $threshold) continue;
$tmpemail=explode(',', $val);
foreach($tmpemail as $key2 => $val2)
$tmpemail = explode(',', $val);
foreach ($tmpemail as $key2 => $val2)
{
$newval2=trim($val2);
$newval2 = trim($val2);
if ($newval2 == '__SUPERVISOREMAIL__')
{
if ($user->fk_user > 0)
{
$tmpuser=new User($this->db);
$tmpuser = new User($this->db);
$tmpuser->fetch($user->fk_user);
if ($tmpuser->email) $newval2=trim($tmpuser->email);
else $newval2='';
if ($tmpuser->email) $newval2 = trim($tmpuser->email);
else $newval2 = '';
}
else $newval2='';
else $newval2 = '';
}
if ($newval2)
{
$isvalid=isValidEmail($newval2, 0);
if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
$isvalid = isValidEmail($newval2, 0);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
}
}
}
@ -311,17 +311,17 @@ class Notify
*/
public function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
{
global $user,$conf,$langs,$mysoc;
global $user, $conf, $langs, $mysoc;
global $hookmanager;
global $dolibarr_main_url_root;
if (! in_array($notifcode, $this->arrayofnotifsupported)) return 0;
if (!in_array($notifcode, $this->arrayofnotifsupported)) return 0;
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (! is_object($hookmanager))
if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('notification'));
@ -409,77 +409,77 @@ class Notify
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($obj->default_lang);
$outputlangs->loadLangs(array("main","other"));
$outputlangs->loadLangs(array("main", "other"));
}
$subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:'');
$subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : '');
switch ($notifcode) {
case 'BILL_VALIDATE':
$link='/compta/facture/card.php?facid='.$object->id;
$link = '/compta/facture/card.php?facid='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref);
break;
case 'BILL_PAYED':
$link='/compta/facture/card.php?facid='.$object->id;
$link = '/compta/facture/card.php?facid='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed", $newref);
break;
case 'ORDER_VALIDATE':
$link='/commande/card.php?id='.$object->id;
$link = '/commande/card.php?id='.$object->id;
$dir_output = $conf->commande->dir_output;
$object_type = 'order';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $newref);
break;
case 'PROPAL_VALIDATE':
$link='/comm/propal/card.php?id='.$object->id;
$link = '/comm/propal/card.php?id='.$object->id;
$dir_output = $conf->propal->multidir_output[$object->entity];
$object_type = 'propal';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $newref);
break;
case 'PROPAL_CLOSE_SIGNED':
$link='/comm/propal/card.php?id='.$object->id;
$link = '/comm/propal/card.php?id='.$object->id;
$dir_output = $conf->propal->multidir_output[$object->entity];
$object_type = 'propal';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $newref);
break;
case 'FICHINTER_ADD_CONTACT':
$link='/fichinter/card.php?id='.$object->id;
$link = '/fichinter/card.php?id='.$object->id;
$dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $newref);
break;
case 'FICHINTER_VALIDATE':
$link='/fichinter/card.php?id='.$object->id;
$link = '/fichinter/card.php?id='.$object->id;
$dir_output = $conf->ficheinter->dir_output;
$object_type = 'ficheinter';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $newref);
break;
case 'ORDER_SUPPLIER_VALIDATE':
$link='/fourn/commande/card.php?id='.$object->id;
$link = '/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->commande->dir_output;
$object_type = 'order_supplier';
$mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($outputlangs));
$mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
$mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($outputlangs));
$mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_APPROVE':
$link='/fourn/commande/card.php?id='.$object->id;
$link = '/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->commande->dir_output;
$object_type = 'order_supplier';
$mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($outputlangs));
$mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
$mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($outputlangs));
$mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_REFUSE':
$link='/fourn/commande/card.php?id='.$object->id;
$link = '/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->commande->dir_output;
$object_type = 'order_supplier';
$mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($outputlangs));
$mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
$mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($outputlangs));
$mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'SHIPPING_VALIDATE':
$dir_output = $conf->expedition->dir_output.'/sending/';
@ -509,7 +509,7 @@ class Notify
}
$ref = dol_sanitizeFileName($newref);
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
if (! dol_is_file($pdf_path))
if (!dol_is_file($pdf_path))
{
// We can't add PDF as it is not generated yet.
$filepdf = '';
@ -520,17 +520,17 @@ class Notify
}
$message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n";
$message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
$message.= "\n";
$message.= $mesg;
if ($link) $message.= "\n" . $urlwithroot . $link;
$message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
$message .= "\n";
$message .= $mesg;
if ($link) $message .= "\n".$urlwithroot.$link;
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
$reshook=$hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
$reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message'];
if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject'];
if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message'];
}
$mailfile = new CMailFile(
@ -556,13 +556,13 @@ class Notify
{
if ($obj->type_target == 'touserid') {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
}
else {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
}
if (! $this->db->query($sql))
if (!$this->db->query($sql))
{
dol_print_error($this->db);
}
@ -570,7 +570,7 @@ class Notify
else
{
$error++;
$this->errors[]=$mailfile->error;
$this->errors[] = $mailfile->error;
}
}
else
@ -588,17 +588,17 @@ class Notify
else
{
$error++;
$this->errors[]=$this->db->lasterror();
$this->errors[] = $this->db->lasterror();
dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
return -1;
}
// Check notification using fixed email
if (! $error)
if (!$error)
{
foreach($conf->global as $key => $val)
foreach ($conf->global as $key => $val)
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
$threshold = (float) $reg[1];
if (!empty($object->total_ht) && $object->total_ht <= $threshold)
@ -607,7 +607,7 @@ class Notify
continue;
}
$param='NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1];
$param = 'NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1];
$sendto = $conf->global->$param;
$notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
@ -617,82 +617,82 @@ class Notify
$link = '';
$num++;
$subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:'');
$subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : '');
switch ($notifcode) {
case 'BILL_VALIDATE':
$link = '<a href="' . $urlwithroot . '/compta/facture/card.php?facid=' . $object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/compta/facture/card.php?facid='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link);
break;
case 'BILL_PAYED':
$link ='<a href="' . $urlwithroot . '/compta/facture/card.php?facid='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/compta/facture/card.php?facid='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoicePayed", $link);
break;
case 'ORDER_VALIDATE':
$link = '<a href="' . $urlwithroot . '/commande/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/commande/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->commande->dir_output;
$object_type = 'order';
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $link);
break;
case 'PROPAL_VALIDATE':
$link = '<a href="' . $urlwithroot . '/comm/propal/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->propal->multidir_output[$object->entity];
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $link);
break;
case 'PROPAL_CLOSE_SIGNED':
$link = '<a href="' . $urlwithroot . '/comm/propal/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/comm/propal/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->propal->multidir_output[$object->entity];
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link);
break;
case 'FICHINTER_ADD_CONTACT':
$link = '<a href="' . $urlwithroot . '/fichinter/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link);
break;
case 'FICHINTER_VALIDATE':
$link = '<a href="' . $urlwithroot . '/fichinter/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/fichinter/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $link);
break;
case 'ORDER_SUPPLIER_VALIDATE':
$link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->fournisseur->commande->dir_output;
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
$mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs));
$mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_APPROVE':
$link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->fournisseur->commande->dir_output;
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
$mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs));
$mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_APPROVE2':
$link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->fournisseur->commande->dir_output;
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
$mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs));
$mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_REFUSE':
$link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>';
$link = '<a href="'.$urlwithroot.'/fourn/commande/card.php?id='.$object->id.'">'.$newref.'</a>';
$dir_output = $conf->fournisseur->dir_output.'/commande/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
$mesg .= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($langs));
$mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'SHIPPING_VALIDATE':
$dir_output = $conf->expedition->dir_output.'/sending/';
@ -722,7 +722,7 @@ class Notify
}
$ref = dol_sanitizeFileName($newref);
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
if (! dol_is_file($pdf_path))
if (!dol_is_file($pdf_path))
{
// We can't add PDF as it is not generated yet.
$filepdf = '';
@ -733,9 +733,9 @@ class Notify
}
$message = $langs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n";
$message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
$message.= "\n";
$message.= $mesg;
$message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
$message .= "\n";
$message .= $mesg;
//if ($link) $message.= "\n" . $urlwithroot . $link; // link already added around the ref into the text
$message = nl2br($message);
@ -743,28 +743,28 @@ class Notify
// Replace keyword __SUPERVISOREMAIL__
if (preg_match('/__SUPERVISOREMAIL__/', $sendto))
{
$newval='';
$newval = '';
if ($user->fk_user > 0)
{
$supervisoruser=new User($this->db);
$supervisoruser = new User($this->db);
$supervisoruser->fetch($user->fk_user);
if ($supervisoruser->email) $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
if ($supervisoruser->email) $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
}
dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
$sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
$sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid
$sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string
$sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string
$sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid
$sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string
$sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string
}
if ($sendto)
{
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
$reshook=$hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
$reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message'];
if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject'];
if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message'];
}
$mailfile = new CMailFile(
$subject,
@ -788,8 +788,8 @@ class Notify
if ($mailfile->sendfile())
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')";
if (! $this->db->query($sql))
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')";
if (!$this->db->query($sql))
{
dol_print_error($this->db);
}
@ -797,13 +797,13 @@ class Notify
else
{
$error++;
$this->errors[]=$mailfile->error;
$this->errors[] = $mailfile->error;
}
}
}
}
if (! $error) return $num;
if (!$error) return $num;
else return -1 * $error;
}
}

View File

@ -1311,7 +1311,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
$sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source;
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref);
// Add date of deposit
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
}
elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except)
{

View File

@ -2099,8 +2099,8 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide
if ($diffval >= 0) {
// good
$out .= ' <div class="progress-bar '.$progressBarClass.'" style="width: '.doubleval($task->progress).'%" title="'.doubleval($task->progress).'%">';
if(!empty($task->progress)) {
$out .= ' <div class="progress-bar progress-bar-consumed" style="width: ' . doubleval($progressCalculated / $task->progress * 100) . '%" title="' . doubleval($progressCalculated) . '%"></div>';
if (!empty($task->progress)) {
$out .= ' <div class="progress-bar progress-bar-consumed" style="width: '.doubleval($progressCalculated / $task->progress * 100).'%" title="'.doubleval($progressCalculated).'%"></div>';
}
$out .= ' </div>';
}

View File

@ -68,37 +68,37 @@ class doc_generic_order_odt extends ModelePDFCommandes
global $conf, $langs, $mysoc;
// Load translation files required by the page
$langs->loadLangs(array("main","companies"));
$langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Page size for A4 format
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->format = array($this->page_largeur, $this->page_hauteur);
$this->marge_gauche = 0;
$this->marge_droite = 0;
$this->marge_haute = 0;
$this->marge_basse = 0;
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
}
@ -110,83 +110,83 @@ class doc_generic_order_odt extends ModelePDFCommandes
*/
public function info($langs)
{
global $conf,$langs;
global $conf, $langs;
// Load translation files required by the page
$langs->loadLangs(array("errors","companies"));
$langs->loadLangs(array("errors", "companies"));
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
$texte .= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
$texte .= '<tr><td>';
$texttitle = $langs->trans("ListOfDirectories");
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
$listoffiles = array();
foreach ($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (! $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
else
{
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte .= '<textarea class="flat" cols="60" name="value1">';
$texte .= $conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
$texte .= '</textarea>';
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte .= '<br></div></div>';
// Scan directories
$nbofiles=count($listoffiles);
if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
$nbofiles = count($listoffiles);
if (!empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
$texte.=count($listoffiles);
$texte .= count($listoffiles);
//$texte.=$nbofiles?'</a>':'';
$texte.='</b>';
$texte .= '</b>';
}
if ($nbofiles)
{
$texte.='<div id="div_'.get_class($this).'" class="hidden">';
foreach($listoffiles as $file)
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
foreach ($listoffiles as $file)
{
$texte.=$file['name'].'<br>';
$texte .= $file['name'].'<br>';
}
$texte.='<div id="div_'.get_class($this).'">';
$texte .= '<div id="div_'.get_class($this).'">';
}
$texte.= '</td>';
$texte .= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte .= '</td>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -206,7 +206,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
global $user,$langs,$conf,$mysoc,$hookmanager;
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
{
@ -215,28 +215,28 @@ class doc_generic_order_odt extends ModelePDFCommandes
}
// Add odtgeneration hook
if (! is_object($hookmanager))
if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
if (!is_object($outputlangs)) $outputlangs = $langs;
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
if ($conf->commande->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
if (!is_object($object))
{
$id = $object;
$object = new Commande($this->db);
$result=$object->fetch($id);
$result = $object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db, $object->error);
@ -246,14 +246,14 @@ class doc_generic_order_odt extends ModelePDFCommandes
$dir = $conf->commande->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
$file = $dir."/".$objectref.".odt";
if (! file_exists($dir))
if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
@ -261,25 +261,25 @@ class doc_generic_order_odt extends ModelePDFCommandes
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp=preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp=preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{
$format=$conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format='%Y%m%d%H%M%S';
$filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$format = $conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format = '%Y%m%d%H%M%S';
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
$file = $dir.'/'.$filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -289,20 +289,20 @@ class doc_generic_order_odt extends ModelePDFCommandes
// If CUSTOMER contact defined on order, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
$contactobject=null;
if (! empty($usecontact))
$contactobject = null;
if (!empty($usecontact))
{
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
else {
$socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
@ -311,11 +311,11 @@ class doc_generic_order_odt extends ModelePDFCommandes
}
else
{
$socobject=$object->thirdparty;
$socobject = $object->thirdparty;
}
// Make substitution
$substitutionarray=array(
$substitutionarray = array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
@ -324,15 +324,15 @@ class doc_generic_order_odt extends ModelePDFCommandes
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Line of free text
$newfreetext='';
$paramfreetext='ORDER_FREE_TEXT';
if (! empty($conf->global->$paramfreetext))
$newfreetext = '';
$paramfreetext = 'ORDER_FREE_TEXT';
if (!empty($conf->global->$paramfreetext))
{
$newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray);
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
}
// Open and load template
@ -342,15 +342,15 @@ class doc_generic_order_odt extends ModelePDFCommandes
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->commande->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
catch (Exception $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -365,31 +365,31 @@ class doc_generic_order_odt extends ModelePDFCommandes
try {
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
// Define substitution array
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
$array_objet=$this->get_substitutionarray_object($object, $outputlangs);
$array_user=$this->get_substitutionarray_user($user, $outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other = $this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in object as contact_xxx tags
$array_thirdparty_contact = array();
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key=>$value)
foreach ($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/', $key)) // Image
@ -402,7 +402,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -414,7 +414,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
try {
$listlines = $odfHandler->setSegment('lines');
}
catch(OdfException $e)
catch (OdfException $e)
{
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
@ -424,22 +424,22 @@ class doc_generic_order_odt extends ModelePDFCommandes
{
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_lines($line, $outputlangs);
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key => $val)
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
catch(SegmentException $e)
catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -449,21 +449,21 @@ class doc_generic_order_odt extends ModelePDFCommandes
$odfHandler->mergeSegment($listlines);
}
}
catch(OdfException $e)
catch (OdfException $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
$tmparray = $outputlangs->get_translations_for_substitutions();
foreach ($tmparray as $key=>$value)
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -471,15 +471,15 @@ class doc_generic_order_odt extends ModelePDFCommandes
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Write new file
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
}catch (Exception $e){
$this->error=$e->getMessage();
} catch (Exception $e) {
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -488,27 +488,27 @@ class doc_generic_order_odt extends ModelePDFCommandes
try {
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
}
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
$odfHandler = null; // Destroy object
$this->result = array('fullpath'=>$file);
return 1; // Success
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}

View File

@ -26,7 +26,7 @@
* \brief Fichier contenant la classe du modele de numerotation de reference de commande Saphir
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
/**
@ -38,7 +38,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
* @var string Error message
@ -48,7 +48,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
/**
* @var string name
*/
public $name='Saphir';
public $name = 'Saphir';
/**
@ -65,28 +65,28 @@ class mod_commande_saphir extends ModeleNumRefCommandes
$form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="updateMask">';
$texte .= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
$tooltip.=$langs->trans("GenericMaskCodes5");
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
$tooltip .= $langs->trans("GenericMaskCodes2");
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -98,17 +98,17 @@ class mod_commande_saphir extends ModeleNumRefCommandes
*/
public function getExample()
{
global $conf,$langs,$mysoc;
global $conf, $langs, $mysoc;
$old_code_client=$mysoc->code_client;
$old_code_type=$mysoc->typent_code;
$mysoc->code_client='CCCCCCCCCC';
$mysoc->typent_code='TTTTTTTTTT';
$old_code_client = $mysoc->code_client;
$old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';
$numExample = $this->getNextValue($mysoc, '');
$mysoc->code_client=$old_code_client;
$mysoc->typent_code=$old_code_type;
$mysoc->code_client = $old_code_client;
$mysoc->typent_code = $old_code_type;
if (! $numExample)
if (!$numExample)
{
$numExample = $langs->trans('NotConfigured');
}
@ -124,16 +124,16 @@ class mod_commande_saphir extends ModeleNumRefCommandes
*/
public function getNextValue($objsoc, $object)
{
global $db,$conf;
global $db, $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// We get cursor rule
$mask=$conf->global->COMMANDE_SAPHIR_MASK;
$mask = $conf->global->COMMANDE_SAPHIR_MASK;
if (! $mask)
if (!$mask)
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return 0;
}
@ -142,7 +142,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
$date = ($object->date_commande ? $object->date_commande : $object->date);
$numFinal=get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date, 'next', false, null, $entity);
$numFinal = get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date, 'next', false, null, $entity);
return $numFinal;
}

View File

@ -67,37 +67,37 @@ class doc_generic_contract_odt extends ModelePDFContract
global $conf, $langs, $mysoc;
// Load translation files required by the page
$langs->loadLangs(array("main","companies"));
$langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
$this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Page size for A4 format
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->format = array($this->page_largeur, $this->page_hauteur);
$this->marge_gauche = 0;
$this->marge_droite = 0;
$this->marge_haute = 0;
$this->marge_basse = 0;
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
}
@ -109,7 +109,7 @@ class doc_generic_contract_odt extends ModelePDFContract
*/
public function info($langs)
{
global $conf,$langs;
global $conf, $langs;
// Load translation files required by the page
$langs->loadLangs(array('companies', 'errors'));
@ -117,66 +117,66 @@ class doc_generic_contract_odt extends ModelePDFContract
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="CONTRACT_ADDON_PDF_ODT_PATH">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="CONTRACT_ADDON_PDF_ODT_PATH">';
$texte .= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
$texte .= '<tr><td>';
$texttitle = $langs->trans("ListOfDirectories");
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH)));
$listoffiles = array();
foreach ($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (! $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
else
{
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">';
$texte.= '<br></div></div>';
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte .= '<textarea class="flat" cols="60" name="value1">';
$texte .= $conf->global->CONTRACT_ADDON_PDF_ODT_PATH;
$texte .= '</textarea>';
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">';
$texte .= '<br></div></div>';
// Scan directories
if (count($listofdir))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
}
// Add select to upload a new template file. TODO Copy this feature on other admin pages.
$texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
$texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
$texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
$texte.= '</div>';
$texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
$texte .= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
$texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
$texte .= '</div>';
$texte.= '</td>';
$texte .= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte .= '</td>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -196,7 +196,7 @@ class doc_generic_contract_odt extends ModelePDFContract
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
global $user,$langs,$conf,$mysoc,$hookmanager;
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
{
@ -205,17 +205,17 @@ class doc_generic_contract_odt extends ModelePDFContract
}
// Add odtgeneration hook
if (! is_object($hookmanager))
if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
if (!is_object($outputlangs)) $outputlangs = $langs;
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
@ -223,11 +223,11 @@ class doc_generic_contract_odt extends ModelePDFContract
if ($conf->contrat->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
if (!is_object($object))
{
$id = $object;
$object = new Contrat($this->db);
$result=$object->fetch($id);
$result = $object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db, $object->error);
@ -237,14 +237,14 @@ class doc_generic_contract_odt extends ModelePDFContract
$dir = $conf->contrat->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
$file = $dir."/".$objectref.".odt";
if (! file_exists($dir))
if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
@ -252,26 +252,26 @@ class doc_generic_contract_odt extends ModelePDFContract
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp=preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp=preg_replace('/modele_/i', '', $newfiletmp);
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
$newfiletmp = $objectref.'_'.$newfiletmp;
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{
$format=$conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format='%Y%m%d%H%M%S';
$filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$format = $conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format = '%Y%m%d%H%M%S';
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
$file = $dir.'/'.$filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -281,19 +281,19 @@ class doc_generic_contract_odt extends ModelePDFContract
// If CUSTOMER contact defined on contract, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
$contactobject=null;
if (! empty($usecontact)) {
$contactobject = null;
if (!empty($usecontact)) {
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$socobject = $object->contact;
} else {
$socobject = $object->thirdparty;
@ -303,7 +303,7 @@ class doc_generic_contract_odt extends ModelePDFContract
}
else
{
$socobject=$object->thirdparty;
$socobject = $object->thirdparty;
}
$object->fetch_optionals();
@ -311,15 +311,15 @@ class doc_generic_contract_odt extends ModelePDFContract
// Define substitution array
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
$array_objet=$this->get_substitutionarray_object($object, $outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object
$array_user=$this->get_substitutionarray_user($user, $outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
$array_objet = $this->get_substitutionarray_object($object, $outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other = $this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in order as contact_xxx tags
$array_thirdparty_contact = array();
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
$substitutionarray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
@ -327,15 +327,15 @@ class doc_generic_contract_odt extends ModelePDFContract
$tmparray = $substitutionarray;
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Line of free text
$newfreetext='';
$paramfreetext='CONTRACT_FREE_TEXT';
if (! empty($conf->global->$paramfreetext))
$newfreetext = '';
$paramfreetext = 'CONTRACT_FREE_TEXT';
if (!empty($conf->global->$paramfreetext))
{
$newfreetext=make_substitutions($conf->global->$paramfreetext, $tmparray);
$newfreetext = make_substitutions($conf->global->$paramfreetext, $tmparray);
}
@ -346,15 +346,15 @@ class doc_generic_contract_odt extends ModelePDFContract
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->contrat->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
catch (Exception $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -374,7 +374,7 @@ class doc_generic_contract_odt extends ModelePDFContract
dol_syslog($e->getMessage(), LOG_INFO);
}
foreach($tmparray as $key=>$value)
foreach ($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/', $key)) // Image
@ -400,7 +400,7 @@ class doc_generic_contract_odt extends ModelePDFContract
try {
$listlines = $odfHandler->setSegment('lines');
}
catch(OdfException $e)
catch (OdfException $e)
{
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
@ -410,22 +410,22 @@ class doc_generic_contract_odt extends ModelePDFContract
{
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_lines($line, $outputlangs);
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key => $val)
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
catch(SegmentException $e)
catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -435,36 +435,36 @@ class doc_generic_contract_odt extends ModelePDFContract
$odfHandler->mergeSegment($listlines);
}
}
catch(OdfException $e)
catch (OdfException $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
$tmparray = $outputlangs->get_translations_for_substitutions();
foreach ($tmparray as $key=>$value)
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Write new file
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
return -1;
}
}
@ -472,25 +472,25 @@ class doc_generic_contract_odt extends ModelePDFContract
try {
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
return -1;
}
}
$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
$odfHandler = null; // Destroy object
$this->result = array('fullpath'=>$file);
return 1; // Success
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}

View File

@ -46,17 +46,17 @@ class mod_contract_magre extends ModelNumRefContracts
* @deprecated
* @see $name
*/
public $nom='Magre';
public $nom = 'Magre';
/**
* @var string name
*/
public $name='Magre';
public $name = 'Magre';
/**
* @var int Automatic numbering
*/
public $code_auto=1;
public $code_auto = 1;
/**
* Return default description of numbering model
@ -65,31 +65,31 @@ class mod_contract_magre extends ModelNumRefContracts
*/
public function info()
{
global $conf,$langs, $db;
global $conf, $langs, $db;
$langs->load("bills");
$form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="updateMask">';
$texte .= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract"));
$tooltip.=$langs->trans("GenericMaskCodes5");
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract"));
$tooltip .= $langs->trans("GenericMaskCodes2");
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract"));
$tooltip .= $langs->trans("GenericMaskCodes5");
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">', $tooltip, 1, 1).'</td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte .= '</tr>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}

File diff suppressed because it is too large Load Diff

View File

@ -66,37 +66,37 @@ class doc_generic_product_odt extends ModelePDFProduct
global $conf, $langs, $mysoc;
// Load translation files required by the page
$langs->loadLangs(array("main","companies"));
$langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
$this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Page size for A4 format
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->format = array($this->page_largeur, $this->page_hauteur);
$this->marge_gauche = 0;
$this->marge_droite = 0;
$this->marge_haute = 0;
$this->marge_basse = 0;
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva PRODUCT_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva PRODUCT_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
}
@ -111,60 +111,60 @@ class doc_generic_product_odt extends ModelePDFProduct
global $conf, $langs;
// Load translation files required by the page
$langs->loadLangs(array("errors","companies"));
$langs->loadLangs(array("errors", "companies"));
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="PRODUCT_ADDON_PDF_ODT_PATH">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="PRODUCT_ADDON_PDF_ODT_PATH">';
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
$texte.= '<input type="hidden" name="param2" value="PRODUCT_ADDON_PDF_ODT_DEFAULT">';
$texte.= '<input type="hidden" name="param3" value="PRODUCT_ADDON_PDF_ODT_TOBILL">';
$texte.= '<input type="hidden" name="param4" value="PRODUCT_ADDON_PDF_ODT_CLOSED">';
$texte .= '<input type="hidden" name="param2" value="PRODUCT_ADDON_PDF_ODT_DEFAULT">';
$texte .= '<input type="hidden" name="param3" value="PRODUCT_ADDON_PDF_ODT_TOBILL">';
$texte .= '<input type="hidden" name="param4" value="PRODUCT_ADDON_PDF_ODT_CLOSED">';
}
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
$texte .= '<tr><td>';
$texttitle = $langs->trans("ListOfDirectories");
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH)));
$listoffiles = array();
foreach ($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (! $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
else
{
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->PRODUCT_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte .= '<textarea class="flat" cols="60" name="value1">';
$texte .= $conf->global->PRODUCT_ADDON_PDF_ODT_PATH;
$texte .= '</textarea>';
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte .= '<br></div></div>';
// Scan directories
if (count($listofdir))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
/*if ($conf->global->MAIN_PRODUCT_CHOOSE_ODT_DOCUMENT > 0)
{
@ -192,15 +192,15 @@ class doc_generic_product_odt extends ModelePDFProduct
}*/
}
$texte.= '</td>';
$texte .= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte .= '</td>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -220,7 +220,7 @@ class doc_generic_product_odt extends ModelePDFProduct
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
global $product,$langs,$conf,$mysoc,$hookmanager,$user;
global $product, $langs, $conf, $mysoc, $hookmanager, $user;
if (empty($srctemplatepath))
{
@ -229,17 +229,17 @@ class doc_generic_product_odt extends ModelePDFProduct
}
// Add odtgeneration hook
if (! is_object($hookmanager))
if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
if (!is_object($outputlangs)) $outputlangs = $langs;
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
@ -247,11 +247,11 @@ class doc_generic_product_odt extends ModelePDFProduct
if ($conf->product->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
if (!is_object($object))
{
$id = $object;
$object = new Product($this->db);
$result=$object->fetch($id);
$result = $object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db, $object->error);
@ -264,14 +264,14 @@ class doc_generic_product_odt extends ModelePDFProduct
$dir = $conf->product->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
$file = $dir."/".$objectref.".odt";
if (! file_exists($dir))
if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
@ -279,26 +279,26 @@ class doc_generic_product_odt extends ModelePDFProduct
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp=preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp=preg_replace('/modele_/i', '', $newfiletmp);
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
$newfiletmp = $objectref.'_'.$newfiletmp;
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{
$format=$conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format='%Y%m%d%H%M%S';
$filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$format = $conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format = '%Y%m%d%H%M%S';
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
$file = $dir.'/'.$filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -308,20 +308,20 @@ class doc_generic_product_odt extends ModelePDFProduct
// If CUSTOMER contact defined on product, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
$contactobject=null;
if (! empty($usecontact))
$contactobject = null;
if (!empty($usecontact))
{
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$socobject = $object->contact;
} else {
$socobject = $object->thirdparty;
@ -331,10 +331,10 @@ class doc_generic_product_odt extends ModelePDFProduct
}
else
{
$socobject=$object->thirdparty;
$socobject = $object->thirdparty;
}
// Make substitution
$substitutionarray=array(
$substitutionarray = array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
@ -343,15 +343,15 @@ class doc_generic_product_odt extends ModelePDFProduct
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Line of free text
$newfreetext='';
$paramfreetext='product_FREE_TEXT';
if (! empty($conf->global->$paramfreetext))
$newfreetext = '';
$paramfreetext = 'product_FREE_TEXT';
if (!empty($conf->global->$paramfreetext))
{
$newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray);
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
}
// Open and load template
@ -361,7 +361,7 @@ class doc_generic_product_odt extends ModelePDFProduct
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->product->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
@ -369,7 +369,7 @@ class doc_generic_product_odt extends ModelePDFProduct
}
catch (Exception $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -394,22 +394,22 @@ class doc_generic_product_odt extends ModelePDFProduct
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
//$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_user=$this->get_substitutionarray_user($user, $outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other = $this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in object as contact_xxx tags
$array_thirdparty_contact = array();
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_other, $array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key=>$value)
foreach ($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/', $key)) // Image
@ -431,15 +431,15 @@ class doc_generic_product_odt extends ModelePDFProduct
try
{
$listlines = $odfHandler->setSegment('supplierprices');
if(!empty($object->supplierprices)){
if (!empty($object->supplierprices)) {
foreach ($object->supplierprices as $supplierprice)
{
$array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs);
complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach($array_lines as $key => $val)
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$array_lines, 'line'=>$supplierprice);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($array_lines as $key => $val)
{
try
{
@ -461,34 +461,34 @@ class doc_generic_product_odt extends ModelePDFProduct
}
catch (OdfException $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
$tmparray = $outputlangs->get_translations_for_substitutions();
foreach ($tmparray as $key=>$value)
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Write new file
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -497,26 +497,26 @@ class doc_generic_product_odt extends ModelePDFProduct
try {
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
}
$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
$odfHandler = null; // Destroy object
$this->result = array('fullpath'=>$file);
return 1; // Success
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}

View File

@ -39,26 +39,26 @@ class mod_codeproduct_elephant extends ModeleProductCode
* @deprecated
* @see $name
*/
public $nom='Elephant';
public $nom = 'Elephant';
/**
* @var string model name
*/
public $name='Elephant';
public $name = 'Elephant';
public $code_modifiable; // Code modifiable
public $code_modifiable; // Code modifiable
public $code_modifiable_invalide; // Code modifiable si il est invalide
public $code_modifiable_invalide; // Code modifiable si il est invalide
public $code_modifiable_null; // Code modifiables si il est null
public $code_modifiable_null; // Code modifiables si il est null
public $code_null; // Code facultatif
public $code_null; // Code facultatif
/**
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
* @var int Automatic numbering
@ -99,36 +99,36 @@ class mod_codeproduct_elephant extends ModeleProductCode
$langs->load("products");
$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
$disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="PRODUCT_ELEPHANT_MASK_PRODUCT">';
$texte.= '<input type="hidden" name="param2" value="PRODUCT_ELEPHANT_MASK_SERVICE">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="PRODUCT_ELEPHANT_MASK_PRODUCT">';
$texte .= '<input type="hidden" name="param2" value="PRODUCT_ELEPHANT_MASK_SERVICE">';
$texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Product"), $langs->transnoentities("Product"));
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4c");
$tooltip.=$langs->trans("GenericMaskCodes5");
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Product"), $langs->transnoentities("Product"));
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= $langs->trans("GenericMaskCodes4c");
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix customers
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT:'').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.(!empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
$texte.= '</tr>';
$texte .= '</tr>';
// Parametrage du prefix suppliers
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.(! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE:'').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte.= '</tr>';
$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.(!empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ? $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE : '').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -147,27 +147,27 @@ class mod_codeproduct_elephant extends ModeleProductCode
if ($type == 0 || $type == -1)
{
$exampleproduct = $this->getNextValue($objproduct, 0);
if (! $exampleproduct)
if (!$exampleproduct)
{
$exampleproduct = $langs->trans('NotConfigured');
}
if($exampleproduct=="ErrorBadMask")
if ($exampleproduct == "ErrorBadMask")
{
$langs->load("errors");
$exampleproduct=$langs->trans($exampleproduct);
$exampleproduct = $langs->trans($exampleproduct);
}
}
if ($type == 1 || $type == -1)
{
$exampleservice = $this->getNextValue($objproduct, 1);
if (! $exampleservice)
if (!$exampleservice)
{
$exampleservice = $langs->trans('NotConfigured');
}
if($exampleservice=="ErrorBadMask")
if ($exampleservice == "ErrorBadMask")
{
$langs->load("errors");
$exampleservice=$langs->trans($exampleservice);
$exampleservice = $langs->trans($exampleservice);
}
}
@ -185,24 +185,24 @@ class mod_codeproduct_elephant extends ModeleProductCode
*/
public function getNextValue($objproduct = 0, $type = -1)
{
global $db,$conf;
global $db, $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Get Mask value
$mask = '';
if ($type == 0 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT))
if ($type == 0 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT))
$mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
elseif ($type == 1 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE))
elseif ($type == 1 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE))
$mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
if (empty($mask))
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return '';
}
$field='';$where='';
$field = ''; $where = '';
if ($type == 0)
{
$field = 'ref';
@ -215,14 +215,14 @@ class mod_codeproduct_elephant extends ModeleProductCode
}
else return -1;
$now=dol_now();
$now = dol_now();
if (! empty($conf->global->PRODUCT_ELEPHANT_ADD_WHERE))
if (!empty($conf->global->PRODUCT_ELEPHANT_ADD_WHERE))
{
$where = ' AND ('.dol_string_nospecial(dol_string_unaccent($conf->global->PRODUCT_ELEPHANT_ADD_WHERE), '_', array(',', '@', '"', "|", ";", ":")).')';
}
$numFinal=get_next_value($db, $mask, 'product', $field, $where, '', $now);
$numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now);
return $numFinal;
}
@ -267,32 +267,32 @@ class mod_codeproduct_elephant extends ModeleProductCode
{
global $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$result=0;
$result = 0;
$code = strtoupper(trim($code));
if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
{
$result=0;
$result = 0;
}
elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
{
$result=-2;
$result = -2;
}
else
{
// Get Mask value
$mask = '';
if ($type==0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?'':$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
if ($type==1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?'':$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
if (! $mask)
if ($type == 0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
if ($type == 1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
if (!$mask)
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return -5;
}
$result=check_value($mask, $code);
$result = check_value($mask, $code);
if (is_string($result))
{
$this->error = $result;
@ -318,10 +318,10 @@ class mod_codeproduct_elephant extends ModeleProductCode
{
// phpcs:enable
$sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product";
$sql.= " WHERE ref = '".$code."'";
if ($product->id > 0) $sql.= " AND rowid <> ".$product->id;
$sql .= " WHERE ref = '".$code."'";
if ($product->id > 0) $sql .= " AND rowid <> ".$product->id;
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
if ($db->num_rows($resql) == 0)

View File

@ -22,7 +22,7 @@
* \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
/**
@ -34,7 +34,7 @@ class mod_project_universal extends ModeleNumRefProjects
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
* @var string Error code (or message)
@ -46,12 +46,12 @@ class mod_project_universal extends ModeleNumRefProjects
* @deprecated
* @see name
*/
public $nom='Universal';
public $nom = 'Universal';
/**
* @var string model name
*/
public $name='Universal';
public $name = 'Universal';
/**
@ -64,33 +64,33 @@ class mod_project_universal extends ModeleNumRefProjects
global $conf, $langs;
// Load translation files required by the page
$langs->loadLangs(array("projects","admin"));
$langs->loadLangs(array("projects", "admin"));
$form = new Form($this->db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="updateMask">';
$texte .= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
$tooltip.=$langs->trans("GenericMaskCodes5");
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
$tooltip .= $langs->trans("GenericMaskCodes2");
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -102,14 +102,14 @@ class mod_project_universal extends ModeleNumRefProjects
*/
public function getExample()
{
global $conf,$langs,$mysoc;
global $conf, $langs, $mysoc;
$old_code_client=$mysoc->code_client;
$mysoc->code_client='CCCCCCCCCC';
$old_code_client = $mysoc->code_client;
$mysoc->code_client = 'CCCCCCCCCC';
$numExample = $this->getNextValue($mysoc, '');
$mysoc->code_client=$old_code_client;
$mysoc->code_client = $old_code_client;
if (! $numExample)
if (!$numExample)
{
$numExample = $langs->trans('NotConfigured');
}
@ -125,21 +125,21 @@ class mod_project_universal extends ModeleNumRefProjects
*/
public function getNextValue($objsoc, $project)
{
global $db,$conf;
global $db, $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// On defini critere recherche compteur
$mask=$conf->global->PROJECT_UNIVERSAL_MASK;
$mask = $conf->global->PROJECT_UNIVERSAL_MASK;
if (! $mask)
if (!$mask)
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return 0;
}
$date=empty($project->date_c)?dol_now():$project->date_c;
$numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
$date = empty($project->date_c) ?dol_now() : $project->date_c;
$numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
return $numFinal;
}

View File

@ -38,16 +38,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
/**
@ -84,37 +84,37 @@ class doc_generic_task_odt extends ModelePDFTask
global $conf, $langs, $mysoc;
// Load translation files required by the page
$langs->loadLangs(array("main","companies"));
$langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Page size for A4 format
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->format = array($this->page_largeur, $this->page_hauteur);
$this->marge_gauche = 0;
$this->marge_droite = 0;
$this->marge_haute = 0;
$this->marge_basse = 0;
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 0; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 0; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
$this->emetteur = $mysoc;
if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
}
@ -132,7 +132,7 @@ class doc_generic_task_odt extends ModelePDFTask
// phpcs:enable
global $conf;
$resarray=array(
$resarray = array(
$array_key.'_id'=>$object->id,
$array_key.'_ref'=>$object->ref,
$array_key.'_title'=>$object->title,
@ -150,7 +150,7 @@ class doc_generic_task_odt extends ModelePDFTask
// Retrieve extrafields
if (is_array($object->array_options) && count($object->array_options))
{
$extrafieldkey=$object->element;
$extrafieldkey = $object->element;
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
@ -341,83 +341,83 @@ class doc_generic_task_odt extends ModelePDFTask
*/
public function info($langs)
{
global $conf,$langs;
global $conf, $langs;
// Load translation files required by the page
$langs->loadLangs(array("errors","companies"));
$langs->loadLangs(array("errors", "companies"));
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
$texte .= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
$texte .= '<tr><td>';
$texttitle = $langs->trans("ListOfDirectories");
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
$listoffiles = array();
foreach ($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (! $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
else
{
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte .= '<textarea class="flat" cols="60" name="value1">';
$texte .= $conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
$texte .= '</textarea>';
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte .= '<br></div></div>';
// Scan directories
$nbofiles=count($listoffiles);
if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
$nbofiles = count($listoffiles);
if (!empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
$texte.=$nbofiles;
$texte .= $nbofiles;
//$texte.=$nbofiles?'</a>':'';
$texte.='</b>';
$texte .= '</b>';
}
if ($nbofiles)
{
$texte.='<div id="div_'.get_class($this).'" class="hidden">';
foreach($listoffiles as $file)
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
foreach ($listoffiles as $file)
{
$texte.=$file['name'].'<br>';
$texte .= $file['name'].'<br>';
}
$texte.='<div id="div_'.get_class($this).'">';
$texte .= '<div id="div_'.get_class($this).'">';
}
$texte.= '</td>';
$texte .= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte .= '</td>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -434,7 +434,7 @@ class doc_generic_task_odt extends ModelePDFTask
public function write_file($object, $outputlangs, $srctemplatepath)
{
// phpcs:enable
global $user,$langs,$conf,$mysoc,$hookmanager;
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
{
@ -442,9 +442,9 @@ class doc_generic_task_odt extends ModelePDFTask
return -1;
}
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
if (!is_object($outputlangs)) $outputlangs = $langs;
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@ -452,32 +452,32 @@ class doc_generic_task_odt extends ModelePDFTask
if ($conf->projet->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
if (!is_object($object))
{
$id = $object;
$object = new Task($this->db);
$result=$object->fetch($id);
$result = $object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db, $object->error);
return -1;
}
}
$project= new Project($this->db);
$project = new Project($this->db);
$project->fetch($object->fk_project);
$project->fetch_thirdparty();
$dir = $conf->projet->dir_output. "/" . $project->ref. "/";
$dir = $conf->projet->dir_output."/".$project->ref."/";
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
$file = $dir."/".$objectref.".odt";
if (! file_exists($dir))
if (!file_exists($dir))
{
print '$dir'.$dir;
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
@ -486,13 +486,13 @@ class doc_generic_task_odt extends ModelePDFTask
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.(ods|odt)/i', '', $newfile);
$newfiletmp=preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp=preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\.(ods|odt)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref.'_'.$newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
$file=$dir.'/'.$newfiletmp.'.odt';
$file = $dir.'/'.$newfiletmp.'.odt';
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -500,17 +500,17 @@ class doc_generic_task_odt extends ModelePDFTask
dol_mkdir($conf->projet->dir_temp);
$socobject=$project->thirdparty;
$socobject = $project->thirdparty;
// Make substitution
$substitutionarray=array(
$substitutionarray = array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Open and load template
require_once ODTPHP_PATH.'odf.php';
@ -519,15 +519,15 @@ class doc_generic_task_odt extends ModelePDFTask
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->projet->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
catch (Exception $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
@ -540,16 +540,16 @@ class doc_generic_task_odt extends ModelePDFTask
// Define substitution array
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
$array_objet=$this->get_substitutionarray_object($project, $outputlangs);
$array_user=$this->get_substitutionarray_user($user, $outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$array_objet = $this->get_substitutionarray_object($project, $outputlangs);
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other = $this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other);
complete_substitutions_array($tmparray, $outputlangs, $object);
foreach($tmparray as $key=>$value)
foreach ($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/', $key)) // Image
@ -570,30 +570,30 @@ class doc_generic_task_odt extends ModelePDFTask
try
{
// Security check
$socid=0;
$socid = 0;
if (!empty($project->fk_soc)) $socid = $project->fk_soc;
$tmparray=$this->get_substitutionarray_tasks($object, $outputlangs);
$tmparray = $this->get_substitutionarray_tasks($object, $outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object);
foreach($tmparray as $key => $val)
foreach ($tmparray as $key => $val)
{
try {
$odfHandler->setVars($key, $val, true, 'UTF-8');
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
} catch(SegmentException $e) {
} catch (SegmentException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Replace tags of lines for contacts task
$sourcearray=array('internal','external');
$contact_arrray=array();
$sourcearray = array('internal', 'external');
$contact_arrray = array();
foreach ($sourcearray as $source) {
$contact_temp=$object->liste_contact(-1, $source);
$contact_temp = $object->liste_contact(-1, $source);
if ((is_array($contact_temp) && count($contact_temp) > 0))
{
$contact_arrray=array_merge($contact_arrray, $contact_temp);
$contact_arrray = array_merge($contact_arrray, $contact_temp);
}
}
if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@ -602,23 +602,23 @@ class doc_generic_task_odt extends ModelePDFTask
foreach ($contact_arrray as $contact)
{
if ($contact['source']=='internal') {
$objectdetail=new User($this->db);
if ($contact['source'] == 'internal') {
$objectdetail = new User($this->db);
$objectdetail->fetch($contact['id']);
$contact['socname']=$mysoc->name;
} elseif ($contact['source']=='external') {
$objectdetail=new Contact($this->db);
$contact['socname'] = $mysoc->name;
} elseif ($contact['source'] == 'external') {
$objectdetail = new Contact($this->db);
$objectdetail->fetch($contact['id']);
$soc=new Societe($this->db);
$soc = new Societe($this->db);
$soc->fetch($contact['socid']);
$contact['socname']=$soc->name;
$contact['socname'] = $soc->name;
}
$contact['fullname']=$objectdetail->getFullName($outputlangs, 1);
$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
$tmparray=$this->get_substitutionarray_tasksressource($contact, $outputlangs);
$tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
foreach($tmparray as $key => $val)
foreach ($tmparray as $key => $val)
{
try {
$listlinestaskres->setVars($key, $val, true, 'UTF-8');
@ -636,7 +636,7 @@ class doc_generic_task_odt extends ModelePDFTask
// Time ressources
$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
$sql.= ", u.lastname, u.firstname";
$sql .= ", u.lastname, u.firstname";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE t.fk_task =".$object->id;
@ -654,27 +654,27 @@ class doc_generic_task_odt extends ModelePDFTask
{
$row = $this->db->fetch_array($resql);
if (!empty($row['fk_user'])) {
$objectdetail=new User($this->db);
$objectdetail = new User($this->db);
$objectdetail->fetch($row['fk_user']);
// TODO Use a cache to aoid fetch for same user
$row['fullcivname']=$objectdetail->getFullName($outputlangs, 1);
$row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
} else {
$row['fullcivname']='';
$row['fullcivname'] = '';
}
$tmparray=$this->get_substitutionarray_taskstime($row, $outputlangs);
$tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
foreach($tmparray as $key => $val)
foreach ($tmparray as $key => $val)
{
try
{
$listlinestasktime->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
catch(SegmentException $e)
catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -692,24 +692,24 @@ class doc_generic_task_odt extends ModelePDFTask
$listtasksfiles = $odfHandler->setSegment('tasksfiles');
$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref);
$filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
foreach ($filearray as $filedetail)
{
$tmparray=$this->get_substitutionarray_task_file($filedetail, $outputlangs);
$tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
foreach($tmparray as $key => $val)
foreach ($tmparray as $key => $val)
{
try
{
$listtasksfiles->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
catch(SegmentException $e)
catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -720,9 +720,9 @@ class doc_generic_task_odt extends ModelePDFTask
$odfHandler->mergeSegment($listtasksfiles);
}
catch(OdfException $e)
catch (OdfException $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
@ -735,25 +735,25 @@ class doc_generic_task_odt extends ModelePDFTask
$listlines = $odfHandler->setSegment('projectfiles');
$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
$filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
foreach ($filearray as $filedetail)
{
//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
$tmparray=$this->get_substitutionarray_project_file($filedetail, $outputlangs);
$tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
foreach($tmparray as $key => $val)
foreach ($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
catch(SegmentException $e)
catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -762,21 +762,21 @@ class doc_generic_task_odt extends ModelePDFTask
}
$odfHandler->mergeSegment($listlines);
}
catch(OdfException $e)
catch (OdfException $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace tags of lines for contacts
$sourcearray=array('internal','external');
$contact_arrray=array();
$sourcearray = array('internal', 'external');
$contact_arrray = array();
foreach ($sourcearray as $source) {
$contact_temp=$project->liste_contact(-1, $source);
$contact_temp = $project->liste_contact(-1, $source);
if ((is_array($contact_temp) && count($contact_temp) > 0))
{
$contact_arrray=array_merge($contact_arrray, $contact_temp);
$contact_arrray = array_merge($contact_arrray, $contact_temp);
}
}
if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@ -787,33 +787,33 @@ class doc_generic_task_odt extends ModelePDFTask
foreach ($contact_arrray as $contact)
{
if ($contact['source']=='internal') {
$objectdetail=new User($this->db);
if ($contact['source'] == 'internal') {
$objectdetail = new User($this->db);
$objectdetail->fetch($contact['id']);
$contact['socname']=$mysoc->name;
} elseif ($contact['source']=='external') {
$objectdetail=new Contact($this->db);
$contact['socname'] = $mysoc->name;
} elseif ($contact['source'] == 'external') {
$objectdetail = new Contact($this->db);
$objectdetail->fetch($contact['id']);
$soc=new Societe($this->db);
$soc = new Societe($this->db);
$soc->fetch($contact['socid']);
$contact['socname']=$soc->name;
$contact['socname'] = $soc->name;
}
$contact['fullname']=$objectdetail->getFullName($outputlangs, 1);
$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
$tmparray=$this->get_substitutionarray_project_contacts($contact, $outputlangs);
$tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
foreach($tmparray as $key => $val)
foreach ($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
catch(SegmentException $e)
catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -822,9 +822,9 @@ class doc_generic_task_odt extends ModelePDFTask
}
$odfHandler->mergeSegment($listlines);
}
catch(OdfException $e)
catch (OdfException $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
@ -832,8 +832,8 @@ class doc_generic_task_odt extends ModelePDFTask
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Write new file
@ -841,7 +841,7 @@ class doc_generic_task_odt extends ModelePDFTask
try {
$odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -850,26 +850,26 @@ class doc_generic_task_odt extends ModelePDFTask
try {
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
}
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
$odfHandler = null; // Destroy object
$this->result = array('fullpath'=>$file);
return 1; // Success
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}

View File

@ -22,7 +22,7 @@
* \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
/**
@ -34,7 +34,7 @@ class mod_task_universal extends ModeleNumRefTask
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
* @var string Error code (or message)
@ -46,12 +46,12 @@ class mod_task_universal extends ModeleNumRefTask
* @deprecated
* @see name
*/
public $nom='Universal';
public $nom = 'Universal';
/**
* @var string name
*/
public $name='Universal';
public $name = 'Universal';
/**
@ -61,36 +61,36 @@ class mod_task_universal extends ModeleNumRefTask
*/
public function info()
{
global $conf,$langs;
global $conf, $langs;
// Load translation files required by the page
$langs->loadLangs(array("projects","admin"));
$langs->loadLangs(array("projects", "admin"));
$form = new Form($this->db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="updateMaskTask">';
$texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="updateMaskTask">';
$texte .= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
$tooltip.=$langs->trans("GenericMaskCodes5");
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
$tooltip .= $langs->trans("GenericMaskCodes2");
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -102,14 +102,14 @@ class mod_task_universal extends ModeleNumRefTask
*/
public function getExample()
{
global $conf,$langs,$mysoc;
global $conf, $langs, $mysoc;
$old_code_client=$mysoc->code_client;
$mysoc->code_client='CCCCCCCCCC';
$old_code_client = $mysoc->code_client;
$mysoc->code_client = 'CCCCCCCCCC';
$numExample = $this->getNextValue($mysoc, '');
$mysoc->code_client=$old_code_client;
$mysoc->code_client = $old_code_client;
if (! $numExample)
if (!$numExample)
{
$numExample = $langs->trans('NotConfigured');
}
@ -125,21 +125,21 @@ class mod_task_universal extends ModeleNumRefTask
*/
public function getNextValue($objsoc, $object)
{
global $db,$conf;
global $db, $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// On defini critere recherche compteur
$mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
$mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK;
if (! $mask)
if (!$mask)
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return 0;
}
$date=empty($object->date_c)?dol_now():$object->date_c;
$numFinal=get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc)?$objsoc->code_client:''), $date);
$date = empty($object->date_c) ?dol_now() : $object->date_c;
$numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
return $numFinal;
}

View File

@ -65,37 +65,37 @@ class doc_generic_proposal_odt extends ModelePDFPropales
global $conf, $langs, $mysoc;
// Load translation files required by the page
$langs->loadLangs(array("main","companies"));
$langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
$this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Page size for A4 format
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->format = array($this->page_largeur, $this->page_hauteur);
$this->marge_gauche = 0;
$this->marge_droite = 0;
$this->marge_haute = 0;
$this->marge_basse = 0;
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
}
@ -107,114 +107,114 @@ class doc_generic_proposal_odt extends ModelePDFPropales
*/
public function info($langs)
{
global $conf,$langs;
global $conf, $langs;
// Load translation files required by the page
$langs->loadLangs(array("errors","companies"));
$langs->loadLangs(array("errors", "companies"));
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="PROPALE_ADDON_PDF_ODT_PATH">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="PROPALE_ADDON_PDF_ODT_PATH">';
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
$texte.= '<input type="hidden" name="param2" value="PROPALE_ADDON_PDF_ODT_DEFAULT">';
$texte.= '<input type="hidden" name="param3" value="PROPALE_ADDON_PDF_ODT_TOBILL">';
$texte.= '<input type="hidden" name="param4" value="PROPALE_ADDON_PDF_ODT_CLOSED">';
$texte .= '<input type="hidden" name="param2" value="PROPALE_ADDON_PDF_ODT_DEFAULT">';
$texte .= '<input type="hidden" name="param3" value="PROPALE_ADDON_PDF_ODT_TOBILL">';
$texte .= '<input type="hidden" name="param4" value="PROPALE_ADDON_PDF_ODT_CLOSED">';
}
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
$texte .= '<tr><td>';
$texttitle = $langs->trans("ListOfDirectories");
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH)));
$listoffiles = array();
foreach ($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (! $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
else
{
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->PROPALE_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte .= '<textarea class="flat" cols="60" name="value1">';
$texte .= $conf->global->PROPALE_ADDON_PDF_ODT_PATH;
$texte .= '</textarea>';
$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte .= '<br></div></div>';
// Scan directories
$nbofiles=count($listoffiles);
if (! empty($conf->global->PROPALE_ADDON_PDF_ODT_PATH))
$nbofiles = count($listoffiles);
if (!empty($conf->global->PROPALE_ADDON_PDF_ODT_PATH))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
$texte.=count($listoffiles);
$texte .= count($listoffiles);
//$texte.=$nbofiles?'</a>':'';
$texte.='</b>';
$texte .= '</b>';
}
if ($nbofiles)
{
$texte.='<div id="div_'.get_class($this).'" class="hidden">';
foreach($listoffiles as $file)
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
foreach ($listoffiles as $file)
{
$texte.=$file['name'].'<br>';
$texte .= $file['name'].'<br>';
}
$texte.='<div id="div_'.get_class($this).'">';
$texte .= '<div id="div_'.get_class($this).'">';
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
// Model for creation
$liste=ModelePDFPropales::liste_modeles($this->db);
$texte.= '<table width="50%;">';
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value2', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT);
$texte.= "</td></tr>";
$liste = ModelePDFPropales::liste_modeles($this->db);
$texte .= '<table width="50%;">';
$texte .= '<tr>';
$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
$texte .= '<td colspan="">';
$texte .= $form->selectarray('value2', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT);
$texte .= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value3', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte .= '<tr>';
$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
$texte .= '<td colspan="">';
$texte .= $form->selectarray('value3', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL);
$texte .= "</td></tr>";
$texte .= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value4', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED);
$texte.= "</td></tr>";
$texte.= '</table>';
$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
$texte .= '<td colspan="">';
$texte .= $form->selectarray('value4', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED);
$texte .= "</td></tr>";
$texte .= '</table>';
}
}
$texte.= '</td>';
$texte .= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte .= '</td>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -234,7 +234,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
global $user,$langs,$conf,$mysoc,$hookmanager;
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
{
@ -243,17 +243,17 @@ class doc_generic_proposal_odt extends ModelePDFPropales
}
// Add odtgeneration hook
if (! is_object($hookmanager))
if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
if (!is_object($outputlangs)) $outputlangs = $langs;
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
@ -261,11 +261,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales
if ($conf->propal->multidir_output[$conf->entity])
{
// If $object is id instead of object
if (! is_object($object))
if (!is_object($object))
{
$id = $object;
$object = new Propal($this->db);
$result=$object->fetch($id);
$result = $object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db, $object->error);
@ -275,14 +275,14 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$dir = $conf->propal->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
$file = $dir."/".$objectref.".odt";
if (! file_exists($dir))
if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
@ -290,26 +290,26 @@ class doc_generic_proposal_odt extends ModelePDFPropales
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp=preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp=preg_replace('/modele_/i', '', $newfiletmp);
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
$newfiletmp = $objectref.'_'.$newfiletmp;
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{
$format=$conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format='%Y%m%d%H%M%S';
$filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$format = $conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format = '%Y%m%d%H%M%S';
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
$file = $dir.'/'.$filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
@ -319,20 +319,20 @@ class doc_generic_proposal_odt extends ModelePDFPropales
// If CUSTOMER contact defined on proposal, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
$contactobject=null;
if (! empty($usecontact))
$contactobject = null;
if (!empty($usecontact))
{
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
else {
$socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
@ -341,10 +341,10 @@ class doc_generic_proposal_odt extends ModelePDFPropales
}
else
{
$socobject=$object->thirdparty;
$socobject = $object->thirdparty;
}
// Make substitution
$substitutionarray=array(
$substitutionarray = array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
@ -353,15 +353,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Line of free text
$newfreetext='';
$paramfreetext='PROPOSAL_FREE_TEXT';
if (! empty($conf->global->$paramfreetext))
$newfreetext = '';
$paramfreetext = 'PROPOSAL_FREE_TEXT';
if (!empty($conf->global->$paramfreetext))
{
$newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray);
$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
}
// Open and load template
@ -371,15 +371,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->propal->multidir_temp[$object->entity],
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
catch (Exception $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -402,24 +402,24 @@ class doc_generic_proposal_odt extends ModelePDFPropales
// Define substitution array
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
$array_objet=$this->get_substitutionarray_object($object, $outputlangs);
$array_user=$this->get_substitutionarray_user($user, $outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
$array_other = $this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in object as contact_xxx tags
$array_thirdparty_contact = array();
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key=>$value)
foreach ($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/', $key)) // Image
@ -432,7 +432,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -444,7 +444,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
try {
$listlines = $odfHandler->setSegment('lines');
}
catch(OdfException $e)
catch (OdfException $e)
{
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
@ -454,22 +454,22 @@ class doc_generic_proposal_odt extends ModelePDFPropales
{
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_lines($line, $outputlangs);
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key => $val)
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
catch(SegmentException $e)
catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -479,16 +479,16 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$odfHandler->mergeSegment($listlines);
}
}
catch(OdfException $e)
catch (OdfException $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
$tmparray = $outputlangs->get_translations_for_substitutions();
foreach ($tmparray as $key=>$value)
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
@ -500,15 +500,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales
}
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Write new file
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -517,26 +517,26 @@ class doc_generic_proposal_odt extends ModelePDFPropales
try {
$odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
}
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
$odfHandler = null; // Destroy object
$this->result = array('fullpath'=>$file);
return 1; // Success
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}

View File

@ -25,7 +25,7 @@
* \brief File that contains the numbering module rules Saphir
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
/**
@ -37,7 +37,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
* @var string Error code (or message)
@ -49,12 +49,12 @@ class mod_propale_saphir extends ModeleNumRefPropales
* @deprecated
* @see name
*/
public $nom='Saphir';
public $nom = 'Saphir';
/**
* @var string model name
*/
public $name='Saphir';
public $name = 'Saphir';
/**
@ -71,28 +71,28 @@ class mod_propale_saphir extends ModeleNumRefPropales
$form = new Form($this->db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="updateMask">';
$texte .= '<input type="hidden" name="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
$texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal"));
$tooltip.=$langs->trans("GenericMaskCodes5");
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal"));
$tooltip .= $langs->trans("GenericMaskCodes2");
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal"));
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpropal" value="'.$conf->global->PROPALE_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpropal" value="'.$conf->global->PROPALE_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -104,17 +104,17 @@ class mod_propale_saphir extends ModeleNumRefPropales
*/
public function getExample()
{
global $conf,$langs,$mysoc;
global $conf, $langs, $mysoc;
$old_code_client=$mysoc->code_client;
$old_code_type=$mysoc->typent_code;
$mysoc->code_client='CCCCCCCCCC';
$mysoc->typent_code='TTTTTTTTTT';
$old_code_client = $mysoc->code_client;
$old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';
$numExample = $this->getNextValue($mysoc, '');
$mysoc->code_client=$old_code_client;
$mysoc->typent_code=$old_code_type;
$mysoc->code_client = $old_code_client;
$mysoc->typent_code = $old_code_type;
if (! $numExample)
if (!$numExample)
{
$numExample = 'NotConfigured';
}
@ -130,16 +130,16 @@ class mod_propale_saphir extends ModeleNumRefPropales
*/
public function getNextValue($objsoc, $propal)
{
global $db,$conf;
global $db, $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// On defini critere recherche compteur
$mask = $conf->global->PROPALE_SAPHIR_MASK;
if (! $mask)
if (!$mask)
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return 0;
}
@ -148,7 +148,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
$date = $propal->date;
$numFinal=get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity);
$numFinal = get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity);
return $numFinal;
}

View File

@ -59,28 +59,28 @@ class doc_generic_odt extends ModeleThirdPartyDoc
global $conf, $langs, $mysoc;
// Load translation files required by the page
$langs->loadLangs(array("main","companies"));
$langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
$this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Page size for A4 format
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->format = array($this->page_largeur, $this->page_hauteur);
$this->marge_gauche = 0;
$this->marge_droite = 0;
$this->marge_haute = 0;
$this->marge_basse = 0;
$this->option_logo = 1; // Affiche logo
$this->option_logo = 1; // Affiche logo
// Retrieves transmitter
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
}
@ -92,7 +92,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
*/
public function info($langs)
{
global $conf,$langs;
global $conf, $langs;
// Load traductions files required by page
$langs->loadLangs(array("companies", "errors"));
@ -100,76 +100,76 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="COMPANY_ADDON_PDF_ODT_PATH">';
$texte .= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
$texte .= '<tr><td>';
$texttitle = $langs->trans("ListOfDirectories");
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH)));
$listoffiles = array();
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)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) { unset($listofdir[$key]); continue; }
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
else
{
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte.= '<table><tr><td>';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->COMPANY_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</td>';
$texte.= '<td align="center">&nbsp; ';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '</td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte .= '<table><tr><td>';
$texte .= '<textarea class="flat" cols="60" name="value1">';
$texte .= $conf->global->COMPANY_ADDON_PDF_ODT_PATH;
$texte .= '</textarea>';
$texte .= '</td>';
$texte .= '<td align="center">&nbsp; ';
$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte .= '</td>';
$texte .= '</tr>';
$texte .= '</table>';
// Scan directories
$nbofiles=count($listoffiles);
if (! empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH))
$nbofiles = count($listoffiles);
if (!empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
$texte.=$nbofiles;
$texte .= $nbofiles;
//$texte.=$nbofiles?'</a>':'';
$texte.='</b>';
$texte .= '</b>';
}
if ($nbofiles)
{
$texte.='<div id="div_'.get_class($this).'" class="hidden">';
foreach($listoffiles as $file)
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
foreach ($listoffiles as $file)
{
$texte.=$file['name'].'<br>';
$texte .= $file['name'].'<br>';
}
$texte.='<div id="div_'.get_class($this).'">';
$texte .= '<div id="div_'.get_class($this).'">';
}
$texte.= '</td>';
$texte .= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte .= '</td>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -189,7 +189,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
global $user,$langs,$conf,$mysoc,$hookmanager;
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
{
@ -198,16 +198,16 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
// Add odtgeneration hook
if (! is_object($hookmanager)) {
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
if (!is_object($outputlangs)) $outputlangs = $langs;
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@ -216,13 +216,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc
{
$dir = $conf->societe->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->id);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
if (! file_exists($dir))
if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
@ -230,28 +230,28 @@ class doc_generic_odt extends ModeleThirdPartyDoc
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.od(s|t)/i', '', $newfile);
$newfiletmp=preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp=preg_replace('/modele_/i', '', $newfiletmp);
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\.od(s|t)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME))
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME))
{
$newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp;
}
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{
$format=$conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format='%Y%m%d%H%M%S';
$filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
$format = $conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format = '%Y%m%d%H%M%S';
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
$filename = $newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
$object->builddoc_filename=$filename; // For triggers
$file = $dir.'/'.$filename;
$object->builddoc_filename = $filename; // For triggers
//print "newfileformat=".$newfileformat;
//print "newdir=".$dir;
//print "newfile=".$newfile;
@ -268,22 +268,22 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity],
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
catch (Exception $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
//print $odfHandler->__toString()."\n";
// Replace tags of lines for contacts
$contact_arrray=array();
$contact_arrray = array();
$sql = "SELECT p.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
@ -296,10 +296,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc
{
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$i=0;
$i = 0;
$contactstatic = new Contact($this->db);
while($i < $num)
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
@ -307,27 +307,27 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$i++;
}
}
if((is_array($contact_arrray) && count($contact_arrray) > 0))
if ((is_array($contact_arrray) && count($contact_arrray) > 0))
{
try
{
$listlines = $odfHandler->setSegment('companycontacts');
foreach($contact_arrray as $array_key => $contact_id)
foreach ($contact_arrray as $array_key => $contact_id)
{
$res_contact = $contactstatic->fetch($contact_id);
$tmparray=$this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact');
foreach($tmparray as $key => $val)
$tmparray = $this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact');
foreach ($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
catch(SegmentException $e)
catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@ -336,29 +336,29 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
$odfHandler->mergeSegment($listlines);
}
catch(OdfException $e)
catch (OdfException $e)
{
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
//return -1;
}
}
// Make substitutions into odt
$array_user=$this->get_substitutionarray_user($user, $outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($object, $outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$array_user = $this->get_substitutionarray_user($user, $outputlangs);
$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
$array_thirdparty = $this->get_substitutionarray_thirdparty($object, $outputlangs);
$array_other = $this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_other);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Replace variables into document
foreach($tmparray as $key=>$value)
foreach ($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/', $key)) // Image
@ -379,8 +379,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
$tmparray = $outputlangs->get_translations_for_substitutions();
foreach ($tmparray as $key=>$value)
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
@ -392,15 +392,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc
}
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Write new file
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) {
$this->error=$e->getMessage();
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
@ -411,38 +411,38 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$odfHandler->title = $object->builddoc_filename;
$odfHandler->subject = $object->builddoc_filename;
if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) {
if (!empty($conf->global->ODT_ADD_DOLIBARR_ID)) {
$odfHandler->userdefined['dol_id'] = $object->id;
$odfHandler->userdefined['dol_element'] = $object->element;
}
$odfHandler->saveToDisk($file);
} catch (Exception $e){
$this->error=$e->getMessage();
} catch (Exception $e) {
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
}
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
$odfHandler = null; // Destroy object
$this->result = array('fullpath'=>$file);
return 1; // Success
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
$this->error='UnknownError';
$this->error = 'UnknownError';
return -1;
}
}

View File

@ -37,21 +37,21 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
/**
* @var string model name
*/
public $name='Elephant';
public $name = 'Elephant';
public $code_modifiable; // Code modifiable
public $code_modifiable; // Code modifiable
public $code_modifiable_invalide; // Code modifiable si il est invalide
public $code_modifiable_invalide; // Code modifiable si il est invalide
public $code_modifiable_null; // Code modifiables si il est null
public $code_modifiable_null; // Code modifiables si il est null
public $code_null; // Code facultatif
public $code_null; // Code facultatif
/**
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
* @var int Automatic numbering
@ -92,37 +92,37 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
$langs->load("companies");
$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
$disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">';
$texte.= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">';
$texte.= '<table class="nobordernopadding" width="100%">';
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">';
$texte .= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">';
$texte .= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty"));
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty"));
//$tooltip.=$langs->trans("GenericMaskCodes2"); Not required for third party numbering
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4b");
$tooltip.=$langs->trans("GenericMaskCodes5");
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= $langs->trans("GenericMaskCodes4b");
$tooltip .= $langs->trans("GenericMaskCodes5");
// Parametrage du prefix customers
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte.= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
$texte.= '</tr>';
$texte .= '</tr>';
// Parametrage du prefix suppliers
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>';
$texte.= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte.= '</tr>';
$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>';
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte .= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
$texte .= '</table>';
$texte .= '</form>';
return $texte;
}
@ -141,47 +141,47 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
if ($type == 0 || $type == -1)
{
$examplecust = $this->getNextValue($objsoc, 0);
if (! $examplecust)
if (!$examplecust)
{
$examplecust = $langs->trans('NotConfigured');
}
if($examplecust=="ErrorBadMask")
if ($examplecust == "ErrorBadMask")
{
$langs->load("errors");
$examplecust=$langs->trans($examplecust);
$examplecust = $langs->trans($examplecust);
}
if($examplecust=="ErrorCantUseRazIfNoYearInMask")
if ($examplecust == "ErrorCantUseRazIfNoYearInMask")
{
$langs->load("errors");
$examplecust=$langs->trans($examplecust);
$examplecust = $langs->trans($examplecust);
}
if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
{
$langs->load("errors");
$examplecust=$langs->trans($examplecust);
$examplecust = $langs->trans($examplecust);
}
}
if ($type == 1 || $type == -1)
{
$examplesup = $this->getNextValue($objsoc, 1);
if (! $examplesup)
if (!$examplesup)
{
$examplesup = $langs->trans('NotConfigured');
}
if($examplesup=="ErrorBadMask")
if ($examplesup == "ErrorBadMask")
{
$langs->load("errors");
$examplesup=$langs->trans($examplesup);
$examplesup = $langs->trans($examplesup);
}
if($examplesup=="ErrorCantUseRazIfNoYearInMask")
if ($examplesup == "ErrorCantUseRazIfNoYearInMask")
{
$langs->load("errors");
$examplesup=$langs->trans($examplesup);
$examplesup = $langs->trans($examplesup);
}
if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
{
$langs->load("errors");
$examplesup=$langs->trans($examplesup);
$examplesup = $langs->trans($examplesup);
}
}
@ -199,21 +199,21 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
*/
public function getNextValue($objsoc = 0, $type = -1)
{
global $db,$conf;
global $db, $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Get Mask value
$mask = '';
if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
if (! $mask)
if ($type == 0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
if ($type == 1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
if (!$mask)
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return '';
}
$field='';$where='';
$field = ''; $where = '';
if ($type == 0)
{
$field = 'code_client';
@ -226,9 +226,9 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
}
else return -1;
$now=dol_now();
$now = dol_now();
$numFinal=get_next_value($db, $mask, 'societe', $field, $where, '', $now);
$numFinal = get_next_value($db, $mask, 'societe', $field, $where, '', $now);
return $numFinal;
}
@ -273,32 +273,32 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
{
global $conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$result=0;
$result = 0;
$code = strtoupper(trim($code));
if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
{
$result=0;
$result = 0;
}
elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
{
$result=-2;
$result = -2;
}
else
{
// Get Mask value
$mask = '';
if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
if (! $mask)
if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
if (!$mask)
{
$this->error='NotConfigured';
$this->error = 'NotConfigured';
return -5;
}
$result=check_value($mask, $code);
$result = check_value($mask, $code);
if (is_string($result))
{
$this->error = $result;
@ -325,11 +325,11 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
{
// phpcs:enable
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
else $sql.= " WHERE code_client = '".$code."'";
if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'";
else $sql .= " WHERE code_client = '".$code."'";
if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id;
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
if ($db->num_rows($resql) == 0)

View File

@ -34,13 +34,13 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
/**
* @var string model name
*/
public $name='Aquarium';
public $name = 'Aquarium';
/**
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefixcustomeraccountancycode;
@ -55,10 +55,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
public function __construct()
{
global $conf;
if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411';
if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401';
$this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER;
$this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER;
if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER = '411';
if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401';
$this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER;
$this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER;
}
@ -75,26 +75,26 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
$langs->load("companies");
$tooltip='';
$tooltip = '';
$texte = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">';
$texte.= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">';
$texte.= '<table class="nobordernopadding" width="100%">';
$s1= $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">', $tooltip, 1, 1);
$s2= $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">', $tooltip, 1, 1);
$texte.= '<tr><td>';
$texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."<br>\n";
$texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."<br>\n";
$texte.="<br>\n";
if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte.=$langs->trans('RemoveSpecialChars').' = '.yn(1)."<br>\n";
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">';
$texte .= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">';
$texte .= '<table class="nobordernopadding" width="100%">';
$s1 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">', $tooltip, 1, 1);
$s2 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">', $tooltip, 1, 1);
$texte .= '<tr><td>';
$texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."<br>\n";
$texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."<br>\n";
$texte .= "<br>\n";
if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."<br>\n";
//if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."<br>\n";
if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n";
$texte.= '</td>';
$texte.= '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr></table>';
$texte.= '</form>';
if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) $texte .= $langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n";
$texte .= '</td>';
$texte .= '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte .= '</tr></table>';
$texte .= '</form>';
return $texte;
}
@ -109,10 +109,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
*/
public function getExample($langs, $objsoc = 0, $type = -1)
{
$s='';
$s.=$this->prefixcustomeraccountancycode.'CUSTCODE';
$s.="<br>\n";
$s.=$this->prefixsupplieraccountancycode.'SUPPCODE';
$s = '';
$s .= $this->prefixcustomeraccountancycode.'CUSTCODE';
$s .= "<br>\n";
$s .= $this->prefixsupplieraccountancycode.'SUPPCODE';
return $s;
}
@ -134,17 +134,17 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
$i = 0;
$this->db = $db;
dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:''));
dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(!empty($societe->name) ? $societe->name : ''));
// Regle gestion compte compta
if ($type == 'customer')
{
$codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
$codetouse = (!empty($societe->code_client) ? $societe->code_client : 'CUSTCODE');
$prefix = $this->prefixcustomeraccountancycode;
}
elseif ($type == 'supplier')
{
$codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
$codetouse = (!empty($societe->code_fournisseur) ? $societe->code_fournisseur : 'SUPPCODE');
$prefix = $this->prefixsupplieraccountancycode;
}
else
@ -156,26 +156,26 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
//$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
// Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default)
if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i', '', $codetouse);
if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse);
// Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse=preg_replace('/([a-z])/i', '', $codetouse);
if (!empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse = preg_replace('/([a-z])/i', '', $codetouse);
// Apply a regex replacement pattern on code if COMPANY_AQUARIUM_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed.
if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
{
$codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse);
$codetouse = preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse);
}
$codetouse=$prefix.strtoupper($codetouse);
$codetouse = $prefix.strtoupper($codetouse);
$is_dispo = $this->verif($db, $codetouse, $societe, $type);
if (! $is_dispo)
if (!$is_dispo)
{
$this->code=$codetouse;
$this->code = $codetouse;
}
else
{
// Pour retour
$this->code=$codetouse;
$this->code = $codetouse;
}
dol_syslog("mod_codecompta_aquarium::get_code found code=".$this->code);
return $is_dispo;
@ -194,33 +194,33 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
public function verif($db, $code, $societe, $type)
{
$sql = "SELECT ";
if ($type == 'customer') $sql.= "code_compta";
elseif ($type == 'supplier') $sql.= "code_compta_fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE ";
if ($type == 'customer') $sql.= "code_compta";
elseif ($type == 'supplier') $sql.= "code_compta_fournisseur";
$sql.= " = '".$db->escape($code)."'";
if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id;
if ($type == 'customer') $sql .= "code_compta";
elseif ($type == 'supplier') $sql .= "code_compta_fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE ";
if ($type == 'customer') $sql .= "code_compta";
elseif ($type == 'supplier') $sql .= "code_compta_fournisseur";
$sql .= " = '".$db->escape($code)."'";
if (!empty($societe->id)) $sql .= " AND rowid <> ".$societe->id;
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
if ($db->num_rows($resql) == 0)
{
dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available");
return 1; // Dispo
return 1; // Dispo
}
else
{
dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available");
return 0; // Non dispo
return 0; // Non dispo
}
}
else
{
$this->error=$db->error()." sql=".$sql;
return -1; // Erreur
$this->error = $db->error()." sql=".$sql;
return -1; // Erreur
}
}
}

View File

@ -34,13 +34,13 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
/**
* @var string model name
*/
public $name='Digitaria';
public $name = 'Digitaria';
/**
* Dolibarr version of the loaded document
* @var string
*/
public $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefixcustomeraccountancycode;
@ -55,15 +55,15 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
public function __construct()
{
global $conf, $langs;
if (! isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER='411';
if (! isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER='401';
$this->prefixcustomeraccountancycode=$conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER;
$this->prefixsupplieraccountancycode=$conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER;
if (!isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER = '411';
if (!isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER = '401';
$this->prefixcustomeraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER;
$this->prefixsupplieraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER;
if (! isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER='5';
if (! isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER='5';
$this->customeraccountancycodecharacternumber=$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER;
$this->supplieraccountancycodecharacternumber=$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER;
if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER = '5';
if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER = '5';
$this->customeraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER;
$this->supplieraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER;
}
/**
@ -76,33 +76,33 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
{
global $conf, $form;
$tooltip='';
$tooltip = '';
$texte = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.newToken().'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="COMPANY_DIGITARIA_MASK_SUPPLIER">';
$texte.= '<input type="hidden" name="param2" value="COMPANY_DIGITARIA_MASK_CUSTOMER">';
$texte.= '<input type="hidden" name="param3" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER">';
$texte.= '<input type="hidden" name="param4" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER">';
$texte.= '<table class="nobordernopadding" width="100%">';
$s1= $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER.'">', $tooltip, 1, 1);
$s2= $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER.'">', $tooltip, 1, 1);
$s3= $form->textwithpicto('<input type="text" class="flat" size="2" name="value3" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER.'">', $tooltip, 1, 1);
$s4= $form->textwithpicto('<input type="text" class="flat" size="2" name="value4" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER.'">', $tooltip, 1, 1);
$texte.= '<tr><td>';
$texte.= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2, $s4)."<br>\n";
$texte.= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1, $s3)."<br>\n";
$texte.= "<br>\n";
$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="COMPANY_DIGITARIA_MASK_SUPPLIER">';
$texte .= '<input type="hidden" name="param2" value="COMPANY_DIGITARIA_MASK_CUSTOMER">';
$texte .= '<input type="hidden" name="param3" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER">';
$texte .= '<input type="hidden" name="param4" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER">';
$texte .= '<table class="nobordernopadding" width="100%">';
$s1 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER.'">', $tooltip, 1, 1);
$s2 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER.'">', $tooltip, 1, 1);
$s3 = $form->textwithpicto('<input type="text" class="flat" size="2" name="value3" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER.'">', $tooltip, 1, 1);
$s4 = $form->textwithpicto('<input type="text" class="flat" size="2" name="value4" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER.'">', $tooltip, 1, 1);
$texte .= '<tr><td>';
$texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2, $s4)."<br>\n";
$texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1, $s3)."<br>\n";
$texte .= "<br>\n";
// Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default)
if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte.= $langs->trans('RemoveSpecialChars').' = '.yn(1)."<br>\n";
if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."<br>\n";
// Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed.
if (! empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) $texte.= $langs->trans('COMPANY_DIGITARIA_CLEAN_REGEX').' = '.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX."<br>\n";
if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) $texte .= $langs->trans('COMPANY_DIGITARIA_CLEAN_REGEX').' = '.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX."<br>\n";
// Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default)
if (! isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || ! empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) $texte.= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."<br>\n";
$texte.= '</td>';
$texte.= '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr></table>';
$texte.= '</form>';
if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) $texte .= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."<br>\n";
$texte .= '</td>';
$texte .= '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte .= '</tr></table>';
$texte .= '</form>';
return $texte;
}
@ -119,14 +119,14 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
{
global $mysoc;
$s= $langs->trans("ThirdPartyName").": ".$mysoc->name;
$s.="<br>\n";
$s = $langs->trans("ThirdPartyName").": ".$mysoc->name;
$s .= "<br>\n";
if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $thirdpartylabelexample = preg_replace('/([^a-z0-9])/i', '', $mysoc->name);
$s.="<br>\n";
$s.=$this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber));
$s.="<br>\n";
$s.=$this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber));
if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $thirdpartylabelexample = preg_replace('/([^a-z0-9])/i', '', $mysoc->name);
$s .= "<br>\n";
$s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber));
$s .= "<br>\n";
$s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber));
return $s;
}
@ -143,11 +143,11 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
{
// phpcs:enable
$i = 0;
$this->code='';
$this->code = '';
if (is_object($societe))
{
dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(! empty($societe->name)?$societe->name:''));
dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(!empty($societe->name) ? $societe->name : ''));
if ($type == 'supplier') {
$codetouse = $societe->name;
@ -167,18 +167,18 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
}
// Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default)
if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i', '', $codetouse);
if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse);
// Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed.
if (! empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) // Example: $conf->global->COMPANY_DIGITARIA_CLEAN_REGEX='^..(..)..';
if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) // Example: $conf->global->COMPANY_DIGITARIA_CLEAN_REGEX='^..(..)..';
{
$codetouse=preg_replace('/'.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.'/', '\1\2\3', $codetouse);
$codetouse = preg_replace('/'.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.'/', '\1\2\3', $codetouse);
}
$this->code = $prefix.strtoupper(substr($codetouse, 0, $width));
dol_syslog("mod_codecompta_digitaria::get_code search code proposed=".$this->code);
// Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default)
if (! isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || ! empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE))
if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE))
{
$disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type);
@ -194,9 +194,9 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
}
if ($type == 'supplier') {
$this->code = $prefix . strtoupper(substr($codetouse, 0, $widthsupplier - $a)) . $i;
$this->code = $prefix.strtoupper(substr($codetouse, 0, $widthsupplier - $a)).$i;
} elseif ($type == 'customer') {
$this->code = $prefix . strtoupper(substr($codetouse, 0, $widthcustomer - $a)) . $i;
$this->code = $prefix.strtoupper(substr($codetouse, 0, $widthcustomer - $a)).$i;
}
$disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type);
@ -242,26 +242,26 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
}
$sql = "SELECT ".$typethirdparty." FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE ".$typethirdparty." = '".$code."'";
$sql .= " WHERE ".$typethirdparty." = '".$code."'";
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
if ($db->num_rows($resql) == 0)
{
dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' available");
return 0; // Available
return 0; // Available
}
else
{
dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' not available");
return -1; // Not available
return -1; // Not available
}
}
else
{
$this->error=$db->error()." sql=".$sql;
return -2; // Error
$this->error = $db->error()." sql=".$sql;
return -2; // Error
}
}
}

View File

@ -72,19 +72,19 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
}
//print $key.'-'.$enabled.'-'.$perms.'-'.$label.$_POST["options_" . $key].'<br>'."\n";
if (empty($enabled)) continue; // 0 = Never visible field
if (abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
if (empty($perms)) continue; // 0 = Not visible
if (empty($enabled)) continue; // 0 = Never visible field
if (abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
if (empty($perms)) continue; // 0 = Not visible
// Load language if required
if (! empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$key]);
if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$key]);
if ($action == 'edit_extras')
{
$value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : $object->array_options["options_" . $key]);
$value = (isset($_POST["options_".$key]) ? $_POST["options_".$key] : $object->array_options["options_".$key]);
}
else
{
$value = $object->array_options["options_" . $key];
$value = $object->array_options["options_".$key];
//var_dump($key.' - '.$value);
}
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate')
@ -116,64 +116,64 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
print '<td class="';
//var_dump($action);exit;
if ((! empty($action) && ($action == 'create' || $action == 'edit')) && ! empty($extrafields->attributes[$object->table_element]['required'][$key])) print ' fieldrequired';
if ((!empty($action) && ($action == 'create' || $action == 'edit')) && !empty($extrafields->attributes[$object->table_element]['required'][$key])) print ' fieldrequired';
print '">';
if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) print $form->textwithpicto($langs->trans($label), $langs->trans($extrafields->attributes[$object->table_element]['help'][$key]));
if (!empty($extrafields->attributes[$object->table_element]['help'][$key])) print $form->textwithpicto($langs->trans($label), $langs->trans($extrafields->attributes[$object->table_element]['help'][$key]));
else print $langs->trans($label);
print '</td>';
//TODO Improve element and rights detection
//var_dump($user->rights);
$permok=false;
$keyforperm=$object->element;
if ($object->element == 'fichinter') $keyforperm='ficheinter';
if (isset($user->rights->$keyforperm)) $permok=$user->rights->$keyforperm->creer||$user->rights->$keyforperm->create||$user->rights->$keyforperm->write;
if ($object->element=='order_supplier') $permok=$user->rights->fournisseur->commande->creer;
if ($object->element=='invoice_supplier') $permok=$user->rights->fournisseur->facture->creer;
if ($object->element=='shipping') $permok=$user->rights->expedition->creer;
if ($object->element=='delivery') $permok=$user->rights->expedition->livraison->creer;
if ($object->element=='productlot') $permok=$user->rights->stock->creer;
if ($object->element=='facturerec') $permok=$user->rights->facture->creer;
if (($object->statut == 0 || ! empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key]))
$permok = false;
$keyforperm = $object->element;
if ($object->element == 'fichinter') $keyforperm = 'ficheinter';
if (isset($user->rights->$keyforperm)) $permok = $user->rights->$keyforperm->creer || $user->rights->$keyforperm->create || $user->rights->$keyforperm->write;
if ($object->element == 'order_supplier') $permok = $user->rights->fournisseur->commande->creer;
if ($object->element == 'invoice_supplier') $permok = $user->rights->fournisseur->facture->creer;
if ($object->element == 'shipping') $permok = $user->rights->expedition->creer;
if ($object->element == 'delivery') $permok = $user->rights->expedition->livraison->creer;
if ($object->element == 'productlot') $permok = $user->rights->stock->creer;
if ($object->element == 'facturerec') $permok = $user->rights->facture->creer;
if (($object->statut == 0 || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key]))
&& $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key)
&& empty($extrafields->attributes[$object->table_element]['computed'][$key]))
{
$fieldid='id';
if ($object->table_element == 'societe') $fieldid='socid';
print '<td class="right"><a class="reposition editfielda" href="' . $_SERVER['PHP_SELF'] . '?'.$fieldid.'=' . $object->id . '&action=edit_extras&attribute=' . $key . '&ignorecollapsesetup=1">' . img_edit().'</a></td>';
$fieldid = 'id';
if ($object->table_element == 'societe') $fieldid = 'socid';
print '<td class="right"><a class="reposition editfielda" href="'.$_SERVER['PHP_SELF'].'?'.$fieldid.'='.$object->id.'&action=edit_extras&attribute='.$key.'&ignorecollapsesetup=1">'.img_edit().'</a></td>';
}
print '</tr></table>';
print '</td>';
$html_id = !empty($object->id) ? $object->element.'_extras_'.$key.'_'.$object->id : '';
print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$key.' wordbreak"'.($cols?' colspan="'.$cols.'"':'').'>';
print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$key.' wordbreak"'.($cols ? ' colspan="'.$cols.'"' : '').'>';
// Convert date into timestamp format
if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime')))
if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date', 'datetime')))
{
$datenotinstring = $object->array_options['options_' . $key];
$datenotinstring = $object->array_options['options_'.$key];
// print 'X'.$object->array_options['options_' . $key].'-'.$datenotinstring.'x';
if (! is_numeric($object->array_options['options_' . $key])) // For backward compatibility
if (!is_numeric($object->array_options['options_'.$key])) // For backward compatibility
{
$datenotinstring = $db->jdate($datenotinstring);
}
//print 'x'.$object->array_options['options_' . $key].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour');
$value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $datenotinstring;
$value = isset($_POST["options_".$key]) ? dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]) : $datenotinstring;
}
//TODO Improve element and rights detection
if ($action == 'edit_extras' && $permok && GETPOST('attribute', 'none') == $key)
{
$fieldid='id';
if ($object->table_element == 'societe') $fieldid='socid';
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formextra">';
$fieldid = 'id';
if ($object->table_element == 'societe') $fieldid = 'socid';
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formextra">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="'.$fieldid.'" value="' . $object->id . '">';
print '<input type="hidden" name="attribute" value="'.$key.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="'.$fieldid.'" value="'.$object->id.'">';
print $extrafields->showInputField($key, $value, '', '', '', 0, $object->id, $object->table_element);
print '<input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Modify')) . '">';
print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Modify')).'">';
print '</form>';
}

View File

@ -84,11 +84,11 @@ if (!empty($extrafields))
}
}
print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
$nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines);
$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
if ($nolinesbefore) {
?>
<tr class="liste_titre<?php echo (($nolinesbefore || $object->element=='contrat')?'':' liste_titre_add_') ?> nodrag nodrop">
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
<tr class="liste_titre<?php echo (($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_add_') ?> nodrag nodrop">
<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
<td class="linecolnum center"></td>
<?php } ?>
<td class="linecoldescription minwidth500imp">
@ -124,10 +124,10 @@ if ($nolinesbefore) {
<?php
// Fields for situation invoice
if ($this->situation_cycle_ref) {
print '<td class="linecolcycleref right">' . $langs->trans('Progress') . '</td>';
print '<td class="linecolcycleref right">'.$langs->trans('Progress').'</td>';
print '<td class="linecolcycleref2 right"></td>';
}
if (! empty($usemargins))
if (!empty($usemargins))
{
if (empty($user->rights->margins->creer)) {
$colspan++;
@ -139,8 +139,8 @@ if ($nolinesbefore) {
else
echo $langs->trans('CostPrice');
echo '</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) echo '<td class="margininfos linecolmargin2 right"><span class="np_marginRate">'.$langs->trans('MarginRate').'</span></td>';
if (! empty($conf->global->DISPLAY_MARK_RATES)) echo '<td class="margininfos linecolmargin2 right"><span class="np_markRate">'.$langs->trans('MarkRate').'</span></td>';
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) echo '<td class="margininfos linecolmargin2 right"><span class="np_marginRate">'.$langs->trans('MarginRate').'</span></td>';
if (!empty($conf->global->DISPLAY_MARK_RATES)) echo '<td class="margininfos linecolmargin2 right"><span class="np_markRate">'.$langs->trans('MarkRate').'</span></td>';
}
}
?>
@ -149,11 +149,11 @@ if ($nolinesbefore) {
<?php
}
?>
<tr class="pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element=='contrat')?'':' liste_titre_create'; ?>">
<tr class="pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create'; ?>">
<?php
$coldisplay=0;
$coldisplay = 0;
// Adds a line numbering column
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay++;
echo '<td class="nobottom linecolnum center"></td>';
}
@ -166,21 +166,21 @@ if ($nolinesbefore) {
if (empty($conf->global->MAIN_DISABLE_FREE_LINES))
{
$freelines = true;
$forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service)
$forceall = 1; // We always force all type for free lines (module product or service means we use predefined product or service)
if ($object->element == 'contrat')
{
if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3;
if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall = -1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall = 3;
}
// Free line
echo '<span class="prod_entry_mode_free">';
// Show radio free line
if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
if ($forceall >= 0 && (!empty($conf->product->enabled) || !empty($conf->service->enabled)))
{
echo '<label for="prod_entry_mode_free">';
echo '<input type="radio" class="prod_entry_mode_free" name="prod_entry_mode" id="prod_entry_mode_free" value="free"';
//echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : ((empty($forceall) && (empty($conf->product->enabled) || empty($conf->service->enabled)))?' checked':'') );
echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : '');
echo (GETPOST('prod_entry_mode') == 'free' ? ' checked' : '');
echo '> ';
// Show type selector
echo $langs->trans("FreeLineOfType");
@ -198,36 +198,36 @@ if ($nolinesbefore) {
echo ' ';
}
}
echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type", 'alpha', 2):-1, 'type', 1, 1, $forceall);
echo $form->select_type_of_lines(isset($_POST["type"]) ?GETPOST("type", 'alpha', 2) : -1, 'type', 1, 1, $forceall);
echo '</span>';
}
// Predefined product/service
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
{
if ($forceall >= 0 && $freelines) echo '<br>';
echo '<span class="prod_entry_mode_predef">';
echo '<label for="prod_entry_mode_predef">';
echo '<input type="radio" class="prod_entry_mode_predef" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"'.(GETPOST('prod_entry_mode')=='predef'?' checked':'').'> ';
echo '<input type="radio" class="prod_entry_mode_predef" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"'.(GETPOST('prod_entry_mode') == 'predef' ? ' checked' : '').'> ';
if (empty($senderissupplier))
{
if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToSell');
elseif ((empty($conf->product->enabled) && ! empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) echo $langs->trans('PredefinedServicesToSell');
if (!empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToSell');
elseif ((empty($conf->product->enabled) && !empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) echo $langs->trans('PredefinedServicesToSell');
else echo $langs->trans('PredefinedProductsAndServicesToSell');
}
else
{
if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase');
elseif (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase');
if (!empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase');
elseif (empty($conf->product->enabled) && !empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase');
else echo $langs->trans('PredefinedProductsAndServicesToPurchase');
}
echo '</label>';
echo ' ';
$filtertype='';
if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
$filtertype = '';
if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype = '1';
if (empty($senderissupplier))
{
$statustoshow = 1;
if (! empty($conf->global->ENTREPOT_EXTRA_STATUS))
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS))
{
// hide products in closed warehouse, but show products for internal transfer
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
@ -236,7 +236,7 @@ if ($nolinesbefore) {
{
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array'));
}
if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS))
if (!empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS))
{
?>
<script type="text/javascript">
@ -260,22 +260,22 @@ if ($nolinesbefore) {
// $senderissupplier=2 is the same as 1 but disables test on minimum qty and disable autofill qty with minimum
if ($senderissupplier != 2)
{
$ajaxoptions=array(
'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key
'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
$ajaxoptions = array(
'update' => array('qty'=>'qty', 'remise_percent' => 'discount', 'idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key
'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
);
$alsoproductwithnosupplierprice=0;
$alsoproductwithnosupplierprice = 0;
}
else
{
$ajaxoptions = array(
'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key
);
$alsoproductwithnosupplierprice=1;
$alsoproductwithnosupplierprice = 1;
}
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth500');
if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS))
if (!empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS))
{
?>
<script type="text/javascript">
@ -298,21 +298,21 @@ if ($nolinesbefore) {
}
if (is_object($hookmanager) && empty($senderissupplier))
{
$parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int'));
$reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action);
$parameters = array('fk_parent_line'=>GETPOST('fk_parent_line', 'int'));
$reshook = $hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action);
if (!empty($hookmanager->resPrint)) {
print $hookmanager->resPrint;
}
}
if (is_object($hookmanager) && ! empty($senderissupplier))
if (is_object($hookmanager) && !empty($senderissupplier))
{
$parameters=array('htmlname'=>'addproduct');
$reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action);
$parameters = array('htmlname'=>'addproduct');
$reshook = $hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action);
if (!empty($hookmanager->resPrint)) {
print $hookmanager->resPrint;
}
}
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
if (!empty($conf->variants->enabled)) {
echo '<div id="attributes_box"></div>';
}
@ -320,15 +320,15 @@ if ($nolinesbefore) {
}
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$nbrows=ROWS_2;
$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$toolbarname='dolibarr_details';
if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
$doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%');
$nbrows = ROWS_2;
$enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
$toolbarname = 'dolibarr_details';
if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes';
$doleditor = new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT) ? 100 : $conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%');
$doleditor->Create();
// Show autofill date for recurring invoices
if (! empty($conf->service->enabled) && $object->element == 'facturerec')
if (!empty($conf->service->enabled) && $object->element == 'facturerec')
{
echo '<div class="divlinefordates"><br>';
echo $langs->trans('AutoFillDateFrom').' ';
@ -343,39 +343,39 @@ if ($nolinesbefore) {
{
$coldisplay++;
?>
<td class="nobottom linecolresupplier"><input id="fourn_ref" name="fourn_ref" class="flat minwidth50 maxwidth150" value="<?php echo (isset($_POST["fourn_ref"])?GETPOST("fourn_ref", 'alpha', 2):''); ?>"></td>
<td class="nobottom linecolresupplier"><input id="fourn_ref" name="fourn_ref" class="flat minwidth50 maxwidth150" value="<?php echo (isset($_POST["fourn_ref"]) ?GETPOST("fourn_ref", 'alpha', 2) : ''); ?>"></td>
<?php }
print '<td class="nobottom linecolvat right">';
$coldisplay++;
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0, true);
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1);
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"]) ?GETPOST("tva_tx", 'alpha', 2) : -1), $seller, $buyer, 0, 0, '', false, 1);
?>
</td>
<td class="nobottom linecoluht right"><?php $coldisplay++; ?>
<input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"])?GETPOST("price_ht", 'alpha', 2):''); ?>">
<input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"]) ?GETPOST("price_ht", 'alpha', 2) : ''); ?>">
</td>
<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
$coldisplay++;
?>
<td class="nobottom linecoluht_currency right">
<input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat right" value="<?php echo (isset($_POST["multicurrency_price_ht"])?GETPOST("multicurrency_price_ht", 'alpha', 2):''); ?>">
<input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat right" value="<?php echo (isset($_POST["multicurrency_price_ht"]) ?GETPOST("multicurrency_price_ht", 'alpha', 2) : ''); ?>">
</td>
<?php }
if (! empty($inputalsopricewithtax)) {
if (!empty($inputalsopricewithtax)) {
$coldisplay++;
?>
<td class="nobottom linecoluttc right">
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?GETPOST("price_ttc", 'alpha', 2):''); ?>">
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"]) ?GETPOST("price_ttc", 'alpha', 2) : ''); ?>">
</td>
<?php }
$coldisplay++;
?>
<td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="<?php echo (isset($_POST["qty"])?GETPOST("qty", 'alpha', 2):1); ?>">
<td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="<?php echo (isset($_POST["qty"]) ?GETPOST("qty", 'alpha', 2) : 1); ?>">
</td>
<?php
if($conf->global->PRODUCT_USE_UNITS)
if ($conf->global->PRODUCT_USE_UNITS)
{
$coldisplay++;
print '<td class="nobottom linecoluseunit left">';
@ -383,13 +383,13 @@ if ($nolinesbefore) {
print '</td>';
}
$remise_percent = $buyer->remise_percent;
if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')
if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')
{
$remise_percent = $seller->remise_supplier_percent;
}
$coldisplay++;
?>
<td class="nobottom nowrap linecoldiscount right"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat right" value="<?php echo (isset($_POST["remise_percent"])?GETPOST("remise_percent", 'alpha', 2):$remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
<td class="nobottom nowrap linecoldiscount right"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat right" value="<?php echo (isset($_POST["remise_percent"]) ?GETPOST("remise_percent", 'alpha', 2) : $remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
<?php
if ($this->situation_cycle_ref) {
$coldisplay++;
@ -397,33 +397,33 @@ if ($nolinesbefore) {
$coldisplay++;
print '<td></td>';
}
if (! empty($usemargins))
if (!empty($usemargins))
{
if (!empty($user->rights->margins->creer)) {
$coldisplay++;
?>
<td class="nobottom margininfos linecolmargin right">
<!-- For predef product -->
<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
<?php if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { ?>
<select id="fournprice_predef" name="fournprice_predef" class="flat minwidth75imp" style="display: none;"></select>
<?php } ?>
<!-- For free product -->
<input type="text" id="buying_price" name="buying_price" class="flat maxwidth75 right" value="<?php echo (isset($_POST["buying_price"])?GETPOST("buying_price", 'alpha', 2):''); ?>">
<input type="text" id="buying_price" name="buying_price" class="flat maxwidth75 right" value="<?php echo (isset($_POST["buying_price"]) ?GETPOST("buying_price", 'alpha', 2) : ''); ?>">
</td>
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
{
echo '<td class="nobottom nowrap margininfos right"><input class="flat right" type="text" size="2" id="np_marginRate" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?GETPOST("np_marginRate", 'alpha', 2):'').'"><span class="np_marginRate hideonsmartphone">%</span></td>';
echo '<td class="nobottom nowrap margininfos right"><input class="flat right" type="text" size="2" id="np_marginRate" name="np_marginRate" value="'.(isset($_POST["np_marginRate"]) ?GETPOST("np_marginRate", 'alpha', 2) : '').'"><span class="np_marginRate hideonsmartphone">%</span></td>';
$coldisplay++;
}
if (! empty($conf->global->DISPLAY_MARK_RATES))
if (!empty($conf->global->DISPLAY_MARK_RATES))
{
echo '<td class="nobottom nowrap margininfos right"><input class="flat right" type="text" size="2" id="np_markRate" name="np_markRate" value="'.(isset($_POST["np_markRate"])?GETPOST("np_markRate", 'alpha', 2):'').'"><span class="np_markRate hideonsmartphone">%</span></td>';
echo '<td class="nobottom nowrap margininfos right"><input class="flat right" type="text" size="2" id="np_markRate" name="np_markRate" value="'.(isset($_POST["np_markRate"]) ?GETPOST("np_markRate", 'alpha', 2) : '').'"><span class="np_markRate hideonsmartphone">%</span></td>';
$coldisplay++;
}
}
}
$coldisplay+=$colspan;
$coldisplay += $colspan;
?>
<td class="nobottom linecoledit center valignmiddle" colspan="<?php echo $colspan; ?>">
<input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline" id="addline">
@ -480,20 +480,20 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
print "</tr>\n";
}
print "<script>\n";
if (! empty($usemargins) && $user->rights->margins->creer)
if (!empty($usemargins) && $user->rights->margins->creer)
{
?>
/* Some js test when we click on button "Add" */
jQuery(document).ready(function() {
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
$("input[name='np_marginRate']:first").blur(function(e) {
return checkFreeLine(e, "np_marginRate");
});
<?php
}
if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
if (!empty($conf->global->DISPLAY_MARK_RATES)) { ?>
$("input[name='np_markRate']:first").blur(function(e) {
return checkFreeLine(e, "np_markRate");
});

View File

@ -2,7 +2,7 @@
<?php
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
if (empty($conf) || !is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
@ -16,7 +16,7 @@ $formresources = new FormResource($db);
$out = '<div class="tagtable centpercent noborder borderbottom allwidth nohover">';
$out .= '<form class="tagtr nohover '.($var==true?'pair':'impair').'" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$out .= '<form class="tagtr nohover '.($var == true ? 'pair' : 'impair').'" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
$out .= '<input type="hidden" name="action" value="add_element_resource">';
$out .= '<input type="hidden" name="element" value="'.$element.'">';
@ -28,18 +28,18 @@ $out .= '<input type="hidden" name="resource_type" value="'.(empty($resource_typ
// Place
$out .= '<div class="tagtd">'.$langs->trans("SelectResource").'</div>';
$out .= '<div class="tagtd">';
$events=array();
$events = array();
$out .= $formresources->select_resource_list('', 'fk_resource', '', 1, 1, 0, $events, '', 2, null);
$out .= '</div>';
$out .= '<div class="tagtd"><label>'.$langs->trans('Busy').'</label> '.$form->selectyesno('busy', (isset($_POST['busy'])?$_POST['busy']:1), 1).'</div>';
$out .= '<div class="tagtd"><label>'.$langs->trans('Mandatory').'</label> '.$form->selectyesno('mandatory', (isset($_POST['mandatory'])?$_POST['mandatory']:0), 1).'</div>';
$out .= '<div class="tagtd"><label>'.$langs->trans('Busy').'</label> '.$form->selectyesno('busy', (isset($_POST['busy']) ? $_POST['busy'] : 1), 1).'</div>';
$out .= '<div class="tagtd"><label>'.$langs->trans('Mandatory').'</label> '.$form->selectyesno('mandatory', (isset($_POST['mandatory']) ? $_POST['mandatory'] : 0), 1).'</div>';
$out .= '<div class="tagtd right">';
$out .='<input type="submit" id="add-resource-place" class="button" value="'.$langs->trans("Add").'"/>';
$out .= '<input type="submit" id="add-resource-place" class="button" value="'.$langs->trans("Add").'"/>';
$out .= '</div>';
$out .='</form>';
$out .= '</form>';
$out .= '</div>';
$out .= '<br>';

View File

@ -47,7 +47,7 @@ $arrayofparameters['ThirdParty'] = array(
'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICY_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200'),
);
if (! empty($conf->global->DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT)) {
if (!empty($conf->global->DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT)) {
$arrayofparameters['Contact'] = array(
'DATAPOLICY_CONTACT_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICY_CONTACT_PROSPECT'=>array('css'=>'minwidth200'),
@ -56,7 +56,7 @@ if (! empty($conf->global->DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT)) {
'DATAPOLICY_CONTACT_FOURNISSEUR'=>array('css'=>'minwidth200'),
);
}
if (! empty($conf->adherent->enabled)) {
if (!empty($conf->adherent->enabled)) {
$arrayofparameters['Member'] = array(
'DATAPOLICY_ADHERENT'=>array('css'=>'minwidth200'),
);

View File

@ -32,14 +32,14 @@ class Loan extends CommonObject
/**
* @var string ID to identify managed object
*/
public $element='loan';
public $element = 'loan';
public $table='loan';
public $table = 'loan';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element='loan';
public $table_element = 'loan';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
@ -124,35 +124,35 @@ class Loan extends CommonObject
public function fetch($id)
{
$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public, l.insurance_amount,";
$sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project";
$sql.= " FROM ".MAIN_DB_PREFIX."loan as l";
$sql.= " WHERE l.rowid = ".$id;
$sql .= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project";
$sql .= " FROM ".MAIN_DB_PREFIX."loan as l";
$sql .= " WHERE l.rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->datestart = $this->db->jdate($obj->datestart);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->datestart = $this->db->jdate($obj->datestart);
$this->dateend = $this->db->jdate($obj->dateend);
$this->label = $obj->label;
$this->capital = $obj->capital;
$this->nbterm = $obj->nbterm;
$this->nbterm = $obj->nbterm;
$this->rate = $obj->rate;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->insurance_amount = $obj->insurance_amount;
$this->paid = $obj->paid;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->insurance_amount = $obj->insurance_amount;
$this->paid = $obj->paid;
$this->account_capital = $obj->accountancy_account_capital;
$this->account_capital = $obj->accountancy_account_capital;
$this->account_insurance = $obj->accountancy_account_insurance;
$this->account_interest = $obj->accountancy_account_interest;
$this->fk_project = $obj->fk_project;
$this->fk_project = $obj->fk_project;
$this->db->free($resql);
return 1;
@ -165,7 +165,7 @@ class Loan extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -181,14 +181,14 @@ class Loan extends CommonObject
{
global $conf, $langs;
$error=0;
$error = 0;
$now=dol_now();
$now = dol_now();
// clean parameters
$newcapital=price2num($this->capital, 'MT');
$newcapital = price2num($this->capital, 'MT');
if (empty($this->insurance_amount)) $this->insurance_amount = 0;
$newinsuranceamount=price2num($this->insurance_amount, 'MT');
$newinsuranceamount = price2num($this->insurance_amount, 'MT');
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital);
@ -200,56 +200,56 @@ class Loan extends CommonObject
if (isset($this->fk_project)) $this->fk_project = (int) $this->fk_project;
// Check parameters
if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend))
if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend))
{
$this->error="ErrorBadParameter";
$this->error = "ErrorBadParameter";
return -2;
}
if (($conf->accounting->enabled) && empty($this->account_capital))
{
$this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
return -2;
}
if (($conf->accounting->enabled) && empty($this->account_insurance))
{
$this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
return -2;
}
if (($conf->accounting->enabled) && empty($this->account_interest))
{
$this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
return -2;
}
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public,";
$sql.= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,";
$sql.= " datec, fk_projet, fk_user_author, insurance_amount)";
$sql.= " VALUES ('".$this->db->escape($this->label)."',";
$sql.= " '".$this->db->escape($this->fk_bank)."',";
$sql.= " '".price2num($newcapital)."',";
$sql.= " '".$this->db->idate($this->datestart)."',";
$sql.= " '".$this->db->idate($this->dateend)."',";
$sql.= " '".$this->db->escape($this->nbterm)."',";
$sql.= " '".$this->db->escape($this->rate)."',";
$sql.= " '".$this->db->escape($this->note_private)."',";
$sql.= " '".$this->db->escape($this->note_public)."',";
$sql.= " '".$this->db->escape($this->account_capital)."',";
$sql.= " '".$this->db->escape($this->account_insurance)."',";
$sql.= " '".$this->db->escape($this->account_interest)."',";
$sql.= " ".$conf->entity.",";
$sql.= " '".$this->db->idate($now)."',";
$sql.= " ".(empty($this->fk_project)?'NULL':$this->fk_project).",";
$sql.= " ".$user->id.",";
$sql.= " '".price2num($newinsuranceamount)."'";
$sql.= ")";
$sql .= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,";
$sql .= " datec, fk_projet, fk_user_author, insurance_amount)";
$sql .= " VALUES ('".$this->db->escape($this->label)."',";
$sql .= " '".$this->db->escape($this->fk_bank)."',";
$sql .= " '".price2num($newcapital)."',";
$sql .= " '".$this->db->idate($this->datestart)."',";
$sql .= " '".$this->db->idate($this->dateend)."',";
$sql .= " '".$this->db->escape($this->nbterm)."',";
$sql .= " '".$this->db->escape($this->rate)."',";
$sql .= " '".$this->db->escape($this->note_private)."',";
$sql .= " '".$this->db->escape($this->note_public)."',";
$sql .= " '".$this->db->escape($this->account_capital)."',";
$sql .= " '".$this->db->escape($this->account_insurance)."',";
$sql .= " '".$this->db->escape($this->account_interest)."',";
$sql .= " ".$conf->entity.",";
$sql .= " '".$this->db->idate($now)."',";
$sql .= " ".(empty($this->fk_project) ? 'NULL' : $this->fk_project).",";
$sql .= " ".$user->id.",";
$sql .= " '".price2num($newinsuranceamount)."'";
$sql .= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."loan");
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan");
//dol_syslog("Loans::create this->id=".$this->id);
$this->db->commit();
@ -257,7 +257,7 @@ class Loan extends CommonObject
}
else
{
$this->error=$this->db->error();
$this->error = $this->db->error();
$this->db->rollback();
return -1;
}
@ -272,23 +272,23 @@ class Loan extends CommonObject
*/
public function delete($user)
{
$error=0;
$error = 0;
$this->db->begin();
// Get bank transaction lines for this loan
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$account=new Account($this->db);
$lines_url=$account->get_url('', $this->id, 'loan');
$account = new Account($this->db);
$lines_url = $account->get_url('', $this->id, 'loan');
// Delete bank urls
foreach ($lines_url as $line_url)
{
if (! $error)
if (!$error)
{
$accountline=new AccountLine($this->db);
$accountline = new AccountLine($this->db);
$accountline->fetch($line_url['fk_bank']);
$result=$accountline->delete_urls($user);
$result = $accountline->delete_urls($user);
if ($result < 0)
{
$error++;
@ -297,31 +297,31 @@ class Loan extends CommonObject
}
// Delete payments
if (! $error)
if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
$resql = $this->db->query($sql);
if (!$resql)
{
$error++;
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
}
}
if (! $error)
if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
$resql = $this->db->query($sql);
if (!$resql)
{
$error++;
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
}
}
if (! $error)
if (!$error)
{
$this->db->commit();
return 1;
@ -344,29 +344,29 @@ class Loan extends CommonObject
{
$this->db->begin();
if (! is_numeric($this->nbterm))
if (!is_numeric($this->nbterm))
{
$this->error='BadValueForParameterForNbTerm';
$this->error = 'BadValueForParameterForNbTerm';
return -1;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."loan";
$sql.= " SET label='".$this->db->escape($this->label)."',";
$sql.= " capital='".price2num($this->db->escape($this->capital))."',";
$sql.= " datestart='".$this->db->idate($this->datestart)."',";
$sql.= " dateend='".$this->db->idate($this->dateend)."',";
$sql.= " nbterm=".$this->nbterm.",";
$sql.= " rate=".$this->db->escape($this->rate).",";
$sql.= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',";
$sql.= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',";
$sql.= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',";
$sql.= " fk_projet=".(empty($this->fk_project)?'NULL':$this->fk_project).",";
$sql.= " fk_user_modif = ".$user->id.",";
$sql.= " insurance_amount = '".price2num($this->db->escape($this->insurance_amount))."'";
$sql.= " WHERE rowid=".$this->id;
$sql .= " SET label='".$this->db->escape($this->label)."',";
$sql .= " capital='".price2num($this->db->escape($this->capital))."',";
$sql .= " datestart='".$this->db->idate($this->datestart)."',";
$sql .= " dateend='".$this->db->idate($this->dateend)."',";
$sql .= " nbterm=".$this->nbterm.",";
$sql .= " rate=".$this->db->escape($this->rate).",";
$sql .= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',";
$sql .= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',";
$sql .= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',";
$sql .= " fk_projet=".(empty($this->fk_project) ? 'NULL' : $this->fk_project).",";
$sql .= " fk_user_modif = ".$user->id.",";
$sql .= " insurance_amount = '".price2num($this->db->escape($this->insurance_amount))."'";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$this->db->commit();
@ -374,7 +374,7 @@ class Loan extends CommonObject
}
else
{
$this->error=$this->db->error();
$this->error = $this->db->error();
$this->db->rollback();
return -1;
}
@ -391,13 +391,13 @@ class Loan extends CommonObject
{
// phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."loan SET";
$sql.= " paid = 1";
$sql.= " WHERE rowid = ".$this->id;
$sql .= " paid = 1";
$sql .= " WHERE rowid = ".$this->id;
$return = $this->db->query($sql);
if ($return) {
return 1;
} else {
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -427,42 +427,42 @@ class Loan extends CommonObject
{
// phpcs:enable
global $langs;
$langs->loadLangs(array("customers","bills"));
$langs->loadLangs(array("customers", "bills"));
if ($mode == 0 || $mode == 1)
{
if ($status == 0) return $langs->trans("Unpaid");
elseif ($status == 1) return $langs->trans("Paid");
if ($status == 0) return $langs->trans("Unpaid");
elseif ($status == 1) return $langs->trans("Paid");
}
elseif ($mode == 2)
{
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
}
elseif ($mode == 3)
{
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6');
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6');
}
elseif ($mode == 4)
{
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
}
elseif ($mode == 5)
{
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
elseif ($mode == 6)
{
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
else return "Error, mode/status not found";
@ -480,20 +480,20 @@ class Loan extends CommonObject
{
global $langs;
$result='';
$result = '';
$tooltip = '<u>' . $langs->trans("ShowLoan") . '</u>';
if (! empty($this->ref))
$tooltip .= '<br><strong>' . $langs->trans('Ref') . ':</strong> ' . $this->ref;
if (! empty($this->label))
$tooltip .= '<br><strong>' . $langs->trans('Label') . ':</strong> ' . $this->label;
$tooltip = '<u>'.$langs->trans("ShowLoan").'</u>';
if (!empty($this->ref))
$tooltip .= '<br><strong>'.$langs->trans('Ref').':</strong> '.$this->ref;
if (!empty($this->label))
$tooltip .= '<br><strong>'.$langs->trans('Label').':</strong> '.$this->label;
$linkstart = '<a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$this->id.'" title="'.str_replace('\n', '', dol_escape_htmltag($tooltip, 1)).'" class="classfortooltip">';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref, $maxlen):$this->ref);
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref);
$result .= $linkend;
return $result;
@ -510,7 +510,7 @@ class Loan extends CommonObject
{
global $user, $langs, $conf;
$now=dol_now();
$now = dol_now();
// Initialise parameters
$this->id = 0;
@ -536,28 +536,28 @@ class Loan extends CommonObject
*/
public function getSumPayment()
{
$table='payment_loan';
$field='fk_loan';
$table = 'payment_loan';
$field = 'fk_loan';
$sql = 'SELECT sum(amount) as amount';
$sql.= ' FROM '.MAIN_DB_PREFIX.$table;
$sql.= ' WHERE '.$field.' = '.$this->id;
$sql .= ' FROM '.MAIN_DB_PREFIX.$table;
$sql .= ' WHERE '.$field.' = '.$this->id;
dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$amount=0;
$amount = 0;
$obj = $this->db->fetch_object($resql);
if ($obj) $amount=$obj->amount?$obj->amount:0;
if ($obj) $amount = $obj->amount ? $obj->amount : 0;
$this->db->free($resql);
return $amount;
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -571,8 +571,8 @@ class Loan extends CommonObject
public function info($id)
{
$sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,';
$sql.= ' l.tms';
$sql.= ' WHERE l.rowid = '.$id;
$sql .= ' l.tms';
$sql .= ' WHERE l.rowid = '.$id;
dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql);
@ -595,7 +595,7 @@ class Loan extends CommonObject
$muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_creation = $this->db->jdate($obj->datec);
if (empty($obj->fk_user_modif)) $obj->tms = "";
$this->date_modification = $this->db->jdate($obj->tms);
@ -610,7 +610,7 @@ class Loan extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}

View File

@ -44,45 +44,45 @@ llxHeader("", $title, $help_url);
$head = loan_prepare_head($object);
dol_fiche_head($head, 'FinancialCommitment', $langs->trans("Loan"), -1, 'bill');
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/list.php">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/loan/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref = '<div class="refidno">';
// Ref loan
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
// Project
if (! empty($conf->projet->enabled))
if (!empty($conf->projet->enabled))
{
$langs->loadLangs(array("projects"));
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->loan->write)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= '<a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$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="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
$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="'.$_SESSION['newtoken'].'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {
$morehtmlref.='';
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>';
$morehtmlref .= '</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
if ($action == 'createecheancier') {

View File

@ -33,21 +33,21 @@ $langs->loadLangs(array('companies', 'bills', 'products', 'margins'));
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$TSelectedCats=GETPOST('categories', 'array');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$TSelectedCats = GETPOST('categories', 'array');
// Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if (! empty($user->socid)) $socid=$user->socid;
$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
if(empty($user->rights->margins->liretous)) accessforbidden();
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
if (!empty($user->socid)) $socid = $user->socid;
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
if (empty($user->rights->margins->liretous)) accessforbidden();
$mesg = '';
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -55,26 +55,26 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
if (!$sortfield)
{
if ($id > 0)
{
$sortfield="f.datef";
$sortorder="DESC";
$sortfield = "f.datef";
$sortorder = "DESC";
}
else
{
$sortfield="p.ref";
$sortorder="ASC";
$sortfield = "p.ref";
$sortorder = "ASC";
}
}
$startdate=$enddate='';
$startdate = $enddate = '';
if (!empty($_POST['startdatemonth']))
$startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
$startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
if (!empty($_POST['enddatemonth']))
$enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
$enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
/*
@ -82,19 +82,19 @@ if (!empty($_POST['enddatemonth']))
*/
$product_static = new Product($db);
$invoicestatic=new Facture($db);
$invoicestatic = new Facture($db);
$form = new Form($db);
llxHeader('', $langs->trans("Margins").' - '.$langs->trans("Products"));
$text=$langs->trans("Margins");
$text = $langs->trans("Margins");
//print load_fiche_titre($text);
// Show tabs
$head=marges_prepare_head($user);
$titre=$langs->trans("Margins");
$picto='margin';
$head = marges_prepare_head($user);
$titre = $langs->trans("Margins");
$picto = 'margin';
print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">';
@ -108,8 +108,8 @@ if ($id > 0) {
$form->select_produits($id, 'id', '', 20, 0, 1, 2, '', 1, array(), 0, 'All');
print '</td></tr>';
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.datef";
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "f.datef";
}
else {
print '<tr><td class="titlefield">'.$langs->trans('ChooseProduct/Service').'</td>';
@ -154,14 +154,14 @@ print '<span id="totalMargin"></span>'; // set by jquery (see below)
print '</td></tr>';
// Margin Rate
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
print '<span id="marginRate"></span>'; // set by jquery (see below)
print '</td></tr>';
}
// Mark Rate
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
print '<span id="markRate"></span>'; // set by jquery (see below)
print '</td></tr>';
@ -176,38 +176,38 @@ print '</form>';
$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
$sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,";
if ($id > 0) $sql.= " d.fk_product,";
if ($id > 0) $sql.= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
$sql.= " SUM(d.total_ht) as selling_price,";
if ($id > 0) $sql .= " d.fk_product,";
if ($id > 0) $sql .= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
$sql .= " SUM(d.total_ht) as selling_price,";
// Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this)
$sql.= " SUM(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
$sql.= " SUM(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = d.fk_product";
if (! empty($TSelectedCats)) {
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=p.rowid';
$sql .= " SUM(".$db->ifsql('d.total_ht < 0', 'd.qty * d.buy_price_ht * -1', 'd.qty * d.buy_price_ht').") as buying_price,";
$sql .= " SUM(".$db->ifsql('d.total_ht < 0', '-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))', 'd.total_ht - (d.buy_price_ht * d.qty)').") as marge";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = d.fk_product";
if (!empty($TSelectedCats)) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=p.rowid';
}
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")";
$sql.= " AND d.fk_facture = f.rowid";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
$sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")";
$sql .= " AND d.fk_facture = f.rowid";
if ($id > 0)
$sql.= " AND d.fk_product =".$id;
if (! empty($TSelectedCats)) {
$sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats) . ')';
$sql .= " AND d.fk_product =".$id;
if (!empty($TSelectedCats)) {
$sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats).')';
}
if (!empty($startdate))
$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
$sql .= " AND f.datef >= '".$db->idate($startdate)."'";
if (!empty($enddate))
$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
$sql .= " AND f.datef <= '".$db->idate($enddate)."'";
$sql .= " AND d.buy_price_ht IS NOT NULL";
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
$sql .= " AND d.buy_price_ht <> 0";
if ($id > 0) $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut";
else $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity";
$sql.=$db->order($sortfield, $sortorder);
if ($id > 0) $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut";
else $sql .= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity";
$sql .= $db->order($sortfield, $sortorder);
// TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
@ -222,15 +222,15 @@ if ($result)
//var_dump($conf->global->MARGIN_TYPE);
if ($conf->global->MARGIN_TYPE == "1")
$labelcostprice='BuyingPrice';
$labelcostprice = 'BuyingPrice';
else // value is 'costprice' or 'pmp'
$labelcostprice='CostPrice';
$labelcostprice = 'CostPrice';
$moreforfilter='';
$moreforfilter = '';
$i = 0;
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre">';
if ($id > 0) {
@ -244,9 +244,9 @@ if ($result)
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&amp;id=".$id, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&amp;id=".$id, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&amp;id=".$id, 'align="right"', $sortfield, $sortorder);
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$id, 'align="right"', $sortfield, $sortorder);
if (! empty($conf->global->DISPLAY_MARK_RATES))
if (!empty($conf->global->DISPLAY_MARK_RATES))
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$id, 'align="right"', $sortfield, $sortorder);
print "</tr>\n";
@ -265,20 +265,20 @@ if ($result)
if ($marge < 0)
{
$marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ;
$markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ;
$marginRate = ($pa != 0) ?-1 * (100 * $marge / $pa) : '';
$markRate = ($pv != 0) ?-1 * (100 * $marge / $pv) : '';
}
else
{
$marginRate = ($pa != 0)?(100 * $marge / $pa):'' ;
$markRate = ($pv != 0)?(100 * $marge / $pv):'' ;
$marginRate = ($pa != 0) ? (100 * $marge / $pa) : '';
$markRate = ($pv != 0) ? (100 * $marge / $pv) : '';
}
print '<tr class="oddeven">';
if ($id > 0) {
print '<td>';
$invoicestatic->id=$objp->facid;
$invoicestatic->ref=$objp->ref;
$invoicestatic->id = $objp->facid;
$invoicestatic->ref = $objp->ref;
print $invoicestatic->getNomUrl(1);
print "</td>\n";
print "<td class=\"center\">";
@ -288,13 +288,13 @@ if ($result)
print '<td>';
if ($objp->rowid > 0)
{
$product_static->type=$objp->fk_product_type;
$product_static->id=$objp->rowid;
$product_static->ref=$objp->ref;
$product_static->label=$objp->label;
$product_static->entity=$objp->pentity;
$text=$product_static->getNomUrl(1);
print $text.= ' - '.$objp->label;
$product_static->type = $objp->fk_product_type;
$product_static->id = $objp->rowid;
$product_static->ref = $objp->ref;
$product_static->label = $objp->label;
$product_static->entity = $objp->pentity;
$text = $product_static->getNomUrl(1);
print $text .= ' - '.$objp->label;
}
else
{
@ -306,10 +306,10 @@ if ($result)
print "<td class=\"right\">".price($pv, null, null, null, null, $rounding)."</td>\n";
print "<td class=\"right\">".price($pa, null, null, null, null, $rounding)."</td>\n";
print "<td class=\"right\">".price($marge, null, null, null, null, $rounding)."</td>\n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td class=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
print "</tr>\n";
$i++;
@ -322,8 +322,8 @@ if ($result)
$totalMargin = $cumul_vente - $cumul_achat;
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
$marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : '';
$markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : '';
print '<tr class="liste_total">';
if ($id > 0)
@ -334,10 +334,10 @@ if ($result)
print "<td class=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n";
print "<td class=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
print "<td class=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td class=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
print "</tr>\n";
print "</table>";
@ -359,8 +359,8 @@ $(document).ready(function() {
});
$("#totalMargin").html("'.price($totalMargin, null, null, null, null, $rounding).'");
$("#marginRate").html("'.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%").'");
$("#markRate").html("'.(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%").'");
$("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%").'");
$("#markRate").html("'.(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%").'");
});
</script>

View File

@ -30,15 +30,15 @@ $langs->loadLangs(array("companies", "bills", "products", "margins"));
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
// Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if (! empty($user->socid)) $socid=$user->socid;
$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
if(empty($user->rights->margins->liretous)) accessforbidden();
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
if (!empty($user->socid)) $socid = $user->socid;
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
if (empty($user->rights->margins->liretous)) accessforbidden();
$object = new Product($db);
@ -51,19 +51,19 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.datef";
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "f.datef";
/*
* View
*/
$invoicestatic=new Facture($db);
$invoicestatic = new Facture($db);
$form = new Form($db);
if ($id > 0 || ! empty($ref))
if ($id > 0 || !empty($ref))
{
$result = $object->fetch($id, $ref);
@ -72,13 +72,13 @@ if ($id > 0 || ! empty($ref))
$shortlabel = dol_trunc($object->label, 16);
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT))
{
$title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Card');
$helpurl='EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card');
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
}
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE))
{
$title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Card');
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card');
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
}
llxHeader('', $title, $helpurl);
@ -88,14 +88,14 @@ if ($id > 0 || ! empty($ref))
*/
if ($result > 0)
{
$head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type== Product::TYPE_SERVICE?'service':'product');
$head = product_prepare_head($object);
$titre = $langs->trans("CardProduct".$object->type);
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
dol_fiche_head($head, 'margin', $titre, -1, $picto);
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref');
dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref');
print '<div class="fichecenter">';
@ -109,14 +109,14 @@ if ($id > 0 || ! empty($ref))
print '</td></tr>';
// Margin Rate
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<tr><td>'.$langs->trans("MarginRate").'</td><td colspan="3">';
print '<span id="marginRate"></span>'; // set by jquery (see below)
print '</td></tr>';
}
// Mark Rate
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print '<tr><td>'.$langs->trans("MarkRate").'</td><td colspan="3">';
print '<span id="markRate"></span>'; // set by jquery (see below)
print '</td></tr>';
@ -132,29 +132,29 @@ if ($id > 0 || ! empty($ref))
if ($user->rights->facture->lire) {
$sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,";
$sql.= " f.rowid as facid, f.ref, f.total as total_ht,";
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.type,";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " sc.fk_soc, sc.fk_user,";
$sql.= " sum(d.total_ht) as selling_price,"; // may be negative or positive
$sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note
$sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note
$sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // not always positive in case of Credit note
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.fk_statut > 0";
$sql.= " AND f.entity IN (".getEntity('invoice').")";
$sql.= " AND d.fk_facture = f.rowid";
$sql.= " AND d.fk_product =".$object->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (! empty($socid)) $sql.= " AND f.fk_soc = $socid";
$sql .= " f.rowid as facid, f.ref, f.total as total_ht,";
$sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,";
$sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive
$sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note
$sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note
$sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge"; // not always positive in case of Credit note
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= ", ".MAIN_DB_PREFIX."facturedet as d";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.fk_statut > 0";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND d.fk_facture = f.rowid";
$sql .= " AND d.fk_product =".$object->id;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if (!empty($socid)) $sql .= " AND f.fk_soc = $socid";
$sql .= " AND d.buy_price_ht IS NOT NULL";
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0";
$sql.= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user";
$sql.= $db->order($sortfield, $sortorder);
$sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= $db->order($sortfield, $sortorder);
// TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
dol_syslog('margin:tabs:productMargins.php', LOG_DEBUG);
@ -178,9 +178,9 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre("BuyingPrice", $_SERVER["PHP_SELF"], "buying_price", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right ');
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right ');
if (! empty($conf->global->DISPLAY_MARK_RATES))
if (!empty($conf->global->DISPLAY_MARK_RATES))
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&amp;id=".$object->id, '', $sortfield, $sortorder, 'right ');
print "</tr>\n";
@ -194,13 +194,13 @@ if ($id > 0 || ! empty($ref))
while ($i < $num /*&& $i < $conf->liste_limit*/) {
$objp = $db->fetch_object($result);
$marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ;
$markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ;
$marginRate = ($objp->buying_price != 0) ? (100 * $objp->marge / $objp->buying_price) : '';
$markRate = ($objp->selling_price != 0) ? (100 * $objp->marge / $objp->selling_price) : '';
print '<tr class="oddeven">';
print '<td>';
$invoicestatic->id=$objp->facid;
$invoicestatic->ref=$objp->ref;
$invoicestatic->id = $objp->facid;
$invoicestatic->ref = $objp->ref;
print $invoicestatic->getNomUrl(1);
print "</td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($objp->name, 44).'</a></td>';
@ -211,10 +211,10 @@ if ($id > 0 || ! empty($ref))
print "<td class=\"right\">".price($objp->buying_price, null, null, null, null, $rounding)."</td>\n";
print "<td class=\"right\">".price($objp->qty, null, null, null, null, $rounding)."</td>\n";
print "<td class=\"right\">".price($objp->marge, null, null, null, null, $rounding)."</td>\n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td class=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
print '<td class="right">'.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).'</td>';
print "</tr>\n";
$i++;
@ -229,13 +229,13 @@ if ($id > 0 || ! empty($ref))
$totalMargin = $cumul_vente - $cumul_achat;
if ($totalMargin < 0)
{
$marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):'';
$marginRate = ($cumul_achat != 0) ?-1 * (100 * $totalMargin / $cumul_achat) : '';
$markRate = ($cumul_vente != 0) ?-1 * (100 * $totalMargin / $cumul_vente) : '';
}
else
{
$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
$marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : '';
$markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : '';
}
print '<tr class="liste_total">';
print '<td colspan=4>'.$langs->trans('TotalMargin')."</td>";
@ -243,10 +243,10 @@ if ($id > 0 || ! empty($ref))
print '<td class="right">'.price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
print '<td class="right">'.price($cumul_qty, null, null, null, null, $rounding)."</td>\n";
print '<td class="right">'.price($totalMargin, null, null, null, null, $rounding)."</td>\n";
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td class="right">'.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td class="right">'.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
if (!empty($conf->global->DISPLAY_MARK_RATES))
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
print "</table>";
@ -265,8 +265,8 @@ print '
<script type="text/javascript">
$(document).ready(function() {
$("#totalMargin").html("'. price($totalMargin, null, null, null, null, $rounding).'");
$("#marginRate").html("'.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%").'");
$("#markRate").html("'.(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%").'");
$("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%").'");
$("#markRate").html("'.(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%").'");
});
</script>
';

View File

@ -37,12 +37,12 @@ class Opensurveysondage extends CommonObject
/**
* @var string ID to identify managed object
*/
public $element='opensurvey_sondage';
public $element = 'opensurvey_sondage';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element='opensurvey_sondage';
public $table_element = 'opensurvey_sondage';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
@ -71,8 +71,8 @@ class Opensurveysondage extends CommonObject
public $fk_user_creat;
public $titre;
public $date_fin='';
public $status=1;
public $date_fin = '';
public $status = 1;
public $format;
public $mailsonde;
@ -126,60 +126,60 @@ class Opensurveysondage extends CommonObject
*/
public function create(User $user, $notrigger = 0)
{
$error=0;
$error = 0;
// Clean parameters
$this->cleanParameters();
// Check parameters
if (! $this->date_fin > 0)
if (!$this->date_fin > 0)
{
$this->error='BadValueForEndDate';
$this->error = 'BadValueForEndDate';
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage(";
$sql.= "id_sondage,";
$sql.= "commentaires,";
$sql.= "fk_user_creat,";
$sql.= "titre,";
$sql.= "date_fin,";
$sql.= "status,";
$sql.= "format,";
$sql.= "mailsonde,";
$sql.= "allow_comments,";
$sql.= "allow_spy,";
$sql.= "sujet";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->id_sondage)."',";
$sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").",";
$sql.= " ".$user->id.",";
$sql.= " '".$this->db->escape($this->titre)."',";
$sql.= " '".$this->db->idate($this->date_fin)."',";
$sql.= " ".$this->status.",";
$sql.= " '".$this->db->escape($this->format)."',";
$sql.= " ".$this->db->escape($this->mailsonde).",";
$sql.= " ".$this->db->escape($this->allow_comments).",";
$sql.= " ".$this->db->escape($this->allow_spy).",";
$sql.= " '".$this->db->escape($this->sujet)."'";
$sql.= ")";
$sql .= "id_sondage,";
$sql .= "commentaires,";
$sql .= "fk_user_creat,";
$sql .= "titre,";
$sql .= "date_fin,";
$sql .= "status,";
$sql .= "format,";
$sql .= "mailsonde,";
$sql .= "allow_comments,";
$sql .= "allow_spy,";
$sql .= "sujet";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->id_sondage)."',";
$sql .= " ".(empty($this->commentaires) ? 'NULL' : "'".$this->db->escape($this->commentaires)."'").",";
$sql .= " ".$user->id.",";
$sql .= " '".$this->db->escape($this->titre)."',";
$sql .= " '".$this->db->idate($this->date_fin)."',";
$sql .= " ".$this->status.",";
$sql .= " '".$this->db->escape($this->format)."',";
$sql .= " ".$this->db->escape($this->mailsonde).",";
$sql .= " ".$this->db->escape($this->allow_comments).",";
$sql .= " ".$this->db->escape($this->allow_spy).",";
$sql .= " '".$this->db->escape($this->sujet)."'";
$sql .= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (! $error)
if (!$error)
{
if (! $notrigger)
if (!$notrigger)
{
global $langs, $conf;
// Call trigger
$result=$this->call_trigger('OPENSURVEY_CREATE', $user);
$result = $this->call_trigger('OPENSURVEY_CREATE', $user);
if ($result < 0) $error++;
// End call triggers
}
@ -188,13 +188,13 @@ class Opensurveysondage extends CommonObject
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{
@ -214,25 +214,25 @@ class Opensurveysondage extends CommonObject
public function fetch($id, $numsurvey = '')
{
$sql = "SELECT";
$sql.= " t.id_sondage,";
$sql.= " t.commentaires as description,";
$sql.= " t.mail_admin,";
$sql.= " t.nom_admin,";
$sql.= " t.fk_user_creat,";
$sql.= " t.titre,";
$sql.= " t.date_fin,";
$sql.= " t.status,";
$sql.= " t.format,";
$sql.= " t.mailsonde,";
$sql.= " t.allow_comments,";
$sql.= " t.allow_spy,";
$sql.= " t.sujet,";
$sql.= " t.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t";
$sql.= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'";
$sql .= " t.id_sondage,";
$sql .= " t.commentaires as description,";
$sql .= " t.mail_admin,";
$sql .= " t.nom_admin,";
$sql .= " t.fk_user_creat,";
$sql .= " t.titre,";
$sql .= " t.date_fin,";
$sql .= " t.status,";
$sql .= " t.format,";
$sql .= " t.mailsonde,";
$sql .= " t.allow_comments,";
$sql .= " t.allow_spy,";
$sql .= " t.sujet,";
$sql .= " t.tms";
$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t";
$sql .= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
@ -240,9 +240,9 @@ class Opensurveysondage extends CommonObject
$obj = $this->db->fetch_object($resql);
$this->id_sondage = $obj->id_sondage;
$this->ref = $this->id_sondage; //For compatibility
$this->ref = $this->id_sondage; //For compatibility
$this->commentaires = $obj->description; // deprecated
$this->commentaires = $obj->description; // deprecated
$this->description = $obj->description;
$this->mail_admin = $obj->mail_admin;
$this->nom_admin = $obj->nom_admin;
@ -257,12 +257,12 @@ class Opensurveysondage extends CommonObject
$this->fk_user_creat = $obj->fk_user_creat;
$this->date_m = $this->db->jdate($obj->tls);
$ret=1;
$ret = 1;
}
else
{
$sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey);
$this->error='Fetch no poll found for '.$sondage;
$this->error = 'Fetch no poll found for '.$sondage;
dol_syslog($this->error, LOG_ERR);
$ret = 0;
}
@ -271,8 +271,8 @@ class Opensurveysondage extends CommonObject
}
else
{
$this->error="Error ".$this->db->lasterror();
$ret=-1;
$this->error = "Error ".$this->db->lasterror();
$ret = -1;
}
return $ret;
@ -289,7 +289,7 @@ class Opensurveysondage extends CommonObject
public function update(User $user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$error = 0;
// Clean parameters
$this->cleanParameters();
@ -300,35 +300,35 @@ class Opensurveysondage extends CommonObject
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET";
$sql.= " id_sondage=".(isset($this->id_sondage)?"'".$this->db->escape($this->id_sondage)."'":"null").",";
$sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").",";
$sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").",";
$sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").",";
$sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").",";
$sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').",";
$sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").",";
$sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").",";
$sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").",";
$sql.= " allow_comments=".$this->db->escape($this->allow_comments).",";
$sql.= " allow_spy=".$this->db->escape($this->allow_spy);
$sql .= " id_sondage=".(isset($this->id_sondage) ? "'".$this->db->escape($this->id_sondage)."'" : "null").",";
$sql .= " commentaires=".(isset($this->commentaires) ? "'".$this->db->escape($this->commentaires)."'" : "null").",";
$sql .= " mail_admin=".(isset($this->mail_admin) ? "'".$this->db->escape($this->mail_admin)."'" : "null").",";
$sql .= " nom_admin=".(isset($this->nom_admin) ? "'".$this->db->escape($this->nom_admin)."'" : "null").",";
$sql .= " titre=".(isset($this->titre) ? "'".$this->db->escape($this->titre)."'" : "null").",";
$sql .= " date_fin=".(dol_strlen($this->date_fin) != 0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').",";
$sql .= " status=".(isset($this->status) ? "'".$this->db->escape($this->status)."'" : "null").",";
$sql .= " format=".(isset($this->format) ? "'".$this->db->escape($this->format)."'" : "null").",";
$sql .= " mailsonde=".(isset($this->mailsonde) ? $this->db->escape($this->mailsonde) : "null").",";
$sql .= " allow_comments=".$this->db->escape($this->allow_comments).",";
$sql .= " allow_spy=".$this->db->escape($this->allow_spy);
$sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
$sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
$this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (! $error)
if (!$error)
{
if (! $notrigger)
if (!$notrigger)
{
// Call triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf);
if ($result < 0) { $error++; $this->errors = $interface->errors; }
// End call triggers
}
}
@ -336,13 +336,13 @@ class Opensurveysondage extends CommonObject
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{
@ -362,7 +362,7 @@ class Opensurveysondage extends CommonObject
public function delete(User $user, $notrigger = 0, $numsondage = '')
{
global $conf, $langs;
$error=0;
$error = 0;
if (empty($numsondage))
{
@ -371,44 +371,44 @@ class Opensurveysondage extends CommonObject
$this->db->begin();
if (! $error)
if (!$error)
{
if (! $notrigger)
if (!$notrigger)
{
// Call trigger
$result=$this->call_trigger('OPENSURVEY_DELETE', $user);
$result = $this->call_trigger('OPENSURVEY_DELETE', $user);
if ($result < 0) $error++;
// End call triggers
}
}
if (! $error)
if (!$error)
{
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'";
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'";
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'";
$resql = $this->db->query($sql);
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'";
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage";
$sql.= " WHERE id_sondage = '".$this->db->escape($numsondage)."'";
$sql .= " WHERE id_sondage = '".$this->db->escape($numsondage)."'";
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{
@ -432,43 +432,43 @@ class Opensurveysondage extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("ShowSurvey") . '</u>';
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref.'<br>';
$label.= '<b>' . $langs->trans('Title') . ':</b> ' . $this->title.'<br>';
$label = '<u>'.$langs->trans("ShowSurvey").'</u>';
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref.'<br>';
$label .= '<b>'.$langs->trans('Title').':</b> '.$this->title.'<br>';
$url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id;
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
$linkclose='';
$linkclose = '';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowMyObject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
$result .= $linkend;
return $result;
@ -483,28 +483,28 @@ class Opensurveysondage extends CommonObject
public function fetch_lines()
{
// phpcs:enable
$ret=array();
$ret = array();
$sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
$sql.= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'";
$resql=$this->db->query($sql);
$sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'";
$resql = $this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj=$this->db->fetch_object($resql);
$tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses);
$obj = $this->db->fetch_object($resql);
$tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses);
$ret[]=$tmp;
$ret[] = $tmp;
$i++;
}
}
else dol_print_error($this->db);
$this->lines=$ret;
$this->lines = $ret;
return count($this->lines);
}
@ -517,18 +517,18 @@ class Opensurveysondage extends CommonObject
*/
public function initAsSpecimen()
{
$this->id=0;
$this->id = 0;
$this->id_sondage='';
$this->commentaires='Comment of the specimen survey';
$this->description='Comment of the specimen survey';
$this->mail_admin='';
$this->nom_admin='';
$this->titre='This is a specimen survey';
$this->date_fin=dol_now()+3600*24*10;
$this->status=1;
$this->format='classic';
$this->mailsonde='';
$this->id_sondage = '';
$this->commentaires = 'Comment of the specimen survey';
$this->description = 'Comment of the specimen survey';
$this->mail_admin = '';
$this->nom_admin = '';
$this->titre = 'This is a specimen survey';
$this->date_fin = dol_now() + 3600 * 24 * 10;
$this->status = 1;
$this->format = 'classic';
$this->mailsonde = '';
}
/**
@ -541,14 +541,14 @@ class Opensurveysondage extends CommonObject
$comments = array();
$sql = 'SELECT id_comment, usercomment, comment';
$sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments';
$sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
$sql.= " ORDER BY id_comment";
$sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments';
$sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'";
$sql .= " ORDER BY id_comment";
$resql = $this->db->query($sql);
if ($resql)
{
$num_rows=$this->db->num_rows($resql);
$num_rows = $this->db->num_rows($resql);
if ($num_rows > 0)
{
@ -572,7 +572,7 @@ class Opensurveysondage extends CommonObject
public function addComment($comment, $comment_user)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)";
$sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')";
$sql .= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')";
$resql = $this->db->query($sql);
if (!$resql) {

View File

@ -60,37 +60,37 @@ $object = new Opensurveysondage($db);
$opensurvey_static = new Opensurveysondage($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->opensurvey->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array
$diroutputmassaction = $conf->opensurvey->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
if (! $sortfield) $sortfield="p.date_fin";
if (! $sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield = "p.date_fin";
if (!$sortorder) $sortorder = "DESC";
// Security check
if (!$user->rights->opensurvey->read) accessforbidden();
// Definition of fields for list
$arrayfields=array();
foreach($arrayfields as $key => $val)
$arrayfields = array();
foreach ($arrayfields as $key => $val)
{
// If $val['visible']==0, then we never show the field
if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
}
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
{
foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) {
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1),
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
);
}
}
@ -120,23 +120,23 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$search_status='';
$search_title='';
$search_ref='';
$toselect='';
$search_array_options=array();
$search_status = '';
$search_title = '';
$search_ref = '';
$toselect = '';
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
// Mass actions
$objectclass='Opensurveysondage';
$objectlabel='Opensurveysondage';
$objectclass = 'Opensurveysondage';
$objectlabel = 'Opensurveysondage';
$uploaddir = $conf->opensurvey->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -220,25 +220,25 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
llxHeader('', $title, $help_url);
$arrayofselected=is_array($toselect)?$toselect:array();
$arrayofselected = is_array($toselect) ? $toselect : array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
$fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname';
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
$fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 'firstname' : 'lastname';
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available
$arrayofmassactions = array(
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
if ($permissiontodelete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
// List of surveys into database
@ -258,16 +258,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('NewSurvey'), '', 'fa fa-plus-c
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit);
// Add code for pre mass action (confirmation or email presend form)
$topicmail="SendOpenSurveyRef";
$modelmail="opensurvey";
$objecttmp=new Opensurveysondage($db);
$trackid='surv'.$object->id;
$topicmail = "SendOpenSurveyRef";
$modelmail = "opensurvey";
$objecttmp = new Opensurveysondage($db);
$trackid = 'surv'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>';
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
}
$moreforfilter = '';
@ -304,18 +304,18 @@ print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
$arraystatus=array('-1'=>'&nbsp;','0'=>$langs->trans("Draft"),'1'=>$langs->trans("Opened"),'2'=>$langs->trans("Closed"));
print '<td class="liste_titre" align="center">'. $form->selectarray('search_status', $arraystatus, $search_status).'</td>';
$arraystatus = array('-1'=>'&nbsp;', '0'=>$langs->trans("Draft"), '1'=>$langs->trans("Opened"), '2'=>$langs->trans("Closed"));
print '<td class="liste_titre" align="center">'.$form->selectarray('search_status', $arraystatus, $search_status).'</td>';
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="liste_titre maxwidthsearch">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>'."\n";
@ -374,19 +374,19 @@ while ($i < min($num, $limit))
print '<td>';
print $opensurvey_static->getNomUrl(1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
// Title
print '<td>'.dol_htmlentities($obj->titre).'</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
// Type
print '<td>';
$type=($obj->format=='A')?'classic':'date';
print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'), 1), 'width="16"', 1);
print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate");
$type = ($obj->format == 'A') ? 'classic' : 'date';
print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1);
print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate");
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
print '<td>';
// Author
@ -402,36 +402,36 @@ while ($i < min($num, $limit))
print dol_htmlentities($obj->nom_admin);
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
// Nb of voters
print'<td class="right">'.$nbuser.'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day');
if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); }
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
print '<td class="center">'.$opensurvey_static->getLibStatut(5).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
print '</tr>'."\n";
$i++;
@ -445,15 +445,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
if ($num == 0)
{
$colspan = 8;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
$db->free($resql);
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
@ -463,19 +463,19 @@ print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
$hidegeneratedfilelistifempty=1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
// Show list of available documents
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;', '&', $param);
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
$filedir=$diroutputmassaction;
$genallowed=$permissiontoread;
$delallowed=$permissiontoadd;
$filedir = $diroutputmassaction;
$genallowed = $permissiontoread;
$delallowed = $permissiontoadd;
print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}

View File

@ -70,7 +70,7 @@ $refalreadyexists = 0;
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$type = (GETPOST('type', 'int') !== '')? GETPOST('type', 'int'):Product::TYPE_PRODUCT;
$type = (GETPOST('type', 'int') !== '') ? GETPOST('type', 'int') : Product::TYPE_PRODUCT;
$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
@ -1222,15 +1222,15 @@ else
// Accountancy codes
print '<table class="border centpercent">';
if (! empty($conf->accounting->enabled))
if (!empty($conf->accounting->enabled))
{
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td>';
if($type = 0) {
$accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell')?GETPOST('accountancy_code_sell', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT);
if ($type = 0) {
$accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ?GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT);
} else {
$accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell')?GETPOST('accountancy_code_sell', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT);
$accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ?GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT);
}
print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, '');
print '</td></tr>';
@ -1240,10 +1240,10 @@ else
{
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
print '<td>';
if($type = 0) {
$accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra')?GETPOST('accountancy_code_sell_intra', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT);
if ($type = 0) {
$accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ?GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT);
} else {
$accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra')?GETPOST('accountancy_code_sell_intra', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT);
$accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ?GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT);
}
print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, null, 1, 1, '');
print '</td></tr>';
@ -1252,11 +1252,11 @@ else
// Accountancy_code_sell_export
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
print '<td>';
if($type = 0)
if ($type = 0)
{
$accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export')?GETPOST('accountancy_code_sell_export', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT);
$accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ?GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT);
} else {
$accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export')?GETPOST('accountancy_code_sell_export', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT);
$accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ?GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT);
}
print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, null, 1, 1, '');
print '</td></tr>';

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf)) {
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
}
@ -70,10 +70,10 @@ if ($object->element == 'product')
{
print '<td class="fieldrequired">'.$langs->trans("Warehouse").'</td>';
print '<td>';
print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid", 'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot', 'int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100');
print $formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100');
print ' &nbsp; <select name="mouvement" id="mouvement">';
print '<option value="0">'.$langs->trans("Add").'</option>';
print '<option value="1"'.(GETPOST('mouvement')?' selected="selected"':'').'>'.$langs->trans("Delete").'</option>';
print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
print '</select>';
print '</td>';
}
@ -81,10 +81,10 @@ if ($object->element == 'stock')
{
print '<td class="fieldrequired">'.$langs->trans("Product").'</td>';
print '<td>';
$form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500');
$form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500');
print ' &nbsp; <select name="mouvement" id="mouvement">';
print '<option value="0">'.$langs->trans("Add").'</option>';
print '<option value="1"'.(GETPOST('mouvement')?' selected="selected"':'').'>'.$langs->trans("Delete").'</option>';
print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
print '</select>';
print '</td>';
}
@ -96,7 +96,7 @@ if ($object->element == 'stock')
print '<tr>';
print '<td>'.$langs->trans("UnitPurchaseValue").'</td>';
print '<td colspan="'.(!empty($conf->projet->enabled) ? '1' : '3').'"><input name="unitprice" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>';
if (! empty($conf->projet->enabled))
if (!empty($conf->projet->enabled))
{
print '<td>'.$langs->trans('Project').'</td>';
print '<td>';
@ -106,36 +106,36 @@ if (! empty($conf->projet->enabled))
print '</tr>';
// Serial / Eat-by date
if (! empty($conf->productbatch->enabled) &&
if (!empty($conf->productbatch->enabled) &&
(($object->element == 'product' && $object->hasbatch())
|| ($object->element == 'stock'))
)
{
print '<tr>';
print '<td'.($object->element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">';
print '<td'.($object->element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">';
print '<input type="text" name="batch_number" size="40" value="'.GETPOST("batch_number").'">';
print '</td>';
print '</tr>';
print '<tr>';
print '<td>'.$langs->trans("EatByDate").'</td><td>';
$eatbyselected=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
$eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
print $form->selectDate($eatbyselected, 'eatby', '', '', 1, "");
print '</td>';
print '<td>'.$langs->trans("SellByDate").'</td><td>';
$sellbyselected=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
$sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
print $form->selectDate($sellbyselected, 'sellby', '', '', 1, "");
print '</td>';
print '</tr>';
}
// Label of mouvement of id of inventory
$valformovementlabel=((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref));
$valformovementlabel = ((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref));
print '<tr>';
print '<td>'.$langs->trans("MovementLabel").'</td>';
print '<td>';
print '<input type="text" name="label" class="minwidth300" value="'.$valformovementlabel.'">';
print '</td>';
print '<td>'.$langs->trans("InventoryCode").'</td><td><input class="maxwidth100onsmartphone" name="inventorycode" id="inventorycode" value="'.(isset($_POST["inventorycode"])?GETPOST("inventorycode", 'alpha'):dol_print_date(dol_now(), '%y%m%d%H%M%S')).'"></td>';
print '<td>'.$langs->trans("InventoryCode").'</td><td><input class="maxwidth100onsmartphone" name="inventorycode" id="inventorycode" value="'.(isset($_POST["inventorycode"]) ?GETPOST("inventorycode", 'alpha') : dol_print_date(dol_now(), '%y%m%d%H%M%S')).'"></td>';
print '</tr>';
print '</table>';

View File

@ -20,7 +20,7 @@
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf)) {
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
}
@ -29,23 +29,23 @@ if (empty($conf) || ! is_object($conf)) {
<!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP -->
<?php
$productref='';
$productref = '';
if ($object->element == 'product') $productref = $object->ref;
$langs->load("productbatch");
if (empty($id)) $id = $object->id;
$pdluoid=GETPOST('pdluoid', 'int');
$pdluoid = GETPOST('pdluoid', 'int');
$pdluo = new Productbatch($db);
if ($pdluoid > 0)
{
$result=$pdluo->fetch($pdluoid);
$result = $pdluo->fetch($pdluoid);
if ($result > 0)
{
$pdluoid=$pdluo->id;
$pdluoid = $pdluo->id;
}
else
{
@ -74,14 +74,14 @@ if ($object->element == 'product')
{
print '<td class="fieldrequired">'.$langs->trans("WarehouseSource").'</td>';
print '<td>';
print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid", 'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot', 'int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1);
print $formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1);
print '</td>';
}
if ($object->element == 'stock')
{
print '<td class="fieldrequired">'.$langs->trans("Product").'</td>';
print '<td>';
$form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500');
$form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500');
print '</td>';
}
@ -92,44 +92,44 @@ if ($object->element == 'stock')
print '</tr>';
// Serial / Eat-by date
if (! empty($conf->productbatch->enabled) &&
if (!empty($conf->productbatch->enabled) &&
(($object->element == 'product' && $object->hasbatch())
|| ($object->element == 'stock'))
)
{
print '<tr>';
print '<td'.($object->element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">';
print '<td'.($object->element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").'</td><td colspan="3">';
if ($pdluoid > 0)
{
// If form was opened for a specific pdluoid, field is disabled
print '<input type="text" name="batch_number_bis" size="40" disabled="disabled" value="'.(GETPOST('batch_number')?GETPOST('batch_number'):$pdluo->batch).'">';
print '<input type="hidden" name="batch_number" value="'.(GETPOST('batch_number')?GETPOST('batch_number'):$pdluo->batch).'">';
print '<input type="text" name="batch_number_bis" size="40" disabled="disabled" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">';
print '<input type="hidden" name="batch_number" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">';
}
else
{
print '<input type="text" name="batch_number" size="40" value="'.(GETPOST('batch_number')?GETPOST('batch_number'):$pdluo->batch).'">';
print '<input type="text" name="batch_number" size="40" value="'.(GETPOST('batch_number') ?GETPOST('batch_number') : $pdluo->batch).'">';
}
print '</td>';
print '</tr>';
print '<tr>';
print '<td>'.$langs->trans("EatByDate").'</td><td>';
print $form->selectDate(($d_eatby?$d_eatby:$pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
print '</td>';
print '<td>'.$langs->trans("SellByDate").'</td><td>';
print $form->selectDate(($d_sellby?$d_sellby:$pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
print $form->selectDate(($d_sellby ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
print '</td>';
print '</tr>';
}
// Label
$valformovementlabel=(GETPOST("label")?GETPOST("label"):$langs->trans("MovementTransferStock", $productref));
$valformovementlabel = (GETPOST("label") ?GETPOST("label") : $langs->trans("MovementTransferStock", $productref));
print '<tr>';
print '<td>'.$langs->trans("MovementLabel").'</td>';
print '<td>';
print '<input type="text" name="label" class="minwidth300" value="'.dol_escape_htmltag($valformovementlabel).'">';
print '</td>';
print '<td>'.$langs->trans("InventoryCode").'</td><td><input class="maxwidth100onsmartphone" name="inventorycode" id="inventorycode" value="'.(isset($_POST["inventorycode"])?GETPOST("inventorycode", 'alpha'):dol_print_date(dol_now(), '%y%m%d%H%M%S')).'"></td>';
print '<td>'.$langs->trans("InventoryCode").'</td><td><input class="maxwidth100onsmartphone" name="inventorycode" id="inventorycode" value="'.(isset($_POST["inventorycode"]) ?GETPOST("inventorycode", 'alpha') : dol_print_date(dol_now(), '%y%m%d%H%M%S')).'"></td>';
print '</tr>';
print '</table>';

View File

@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$langs->loadLangs(array("admin", "companies", "other"));
$action=GETPOST('action', 'alpha');
$value=GETPOST('value', 'alpha');
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
if (!$user->admin) accessforbidden();
@ -79,8 +79,8 @@ if ($action == 'updateoptions')
{
$companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha');
$res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -94,8 +94,8 @@ if ($action == 'updateoptions')
{
$contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha');
$res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -109,8 +109,8 @@ if ($action == 'updateoptions')
{
$customertypedefault = GETPOST('defaultcustomertype', 'int');
$res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -127,25 +127,25 @@ if ($action == 'set')
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type='company';
$type = 'company';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")";
$sql .= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql .= ($label ? "'".$db->escape($label)."'" : 'null').", ";
$sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null");
$sql .= ")";
$resql=$db->query($sql);
if (! $resql) dol_print_error($db);
$resql = $db->query($sql);
if (!$resql) dol_print_error($db);
}
// Disable a document generator module
if ($action== 'del')
if ($action == 'del')
{
$type='company';
$type = 'company';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity;
$resql=$db->query($sql);
if (! $resql) dol_print_error($db);
$sql .= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity;
$resql = $db->query($sql);
if (!$resql) dol_print_error($db);
}
// Define default generator
@ -159,21 +159,21 @@ if ($action == 'setdoc')
dolibarr_set_const($db, "COMPANY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity);
// On active le modele
$type='company';
$type = 'company';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del.= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'";
$sql_del.= " AND type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity;
$sql_del .= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'";
$sql_del .= " AND type = '".$type."'";
$sql_del .= " AND entity = ".$conf->entity;
dol_syslog("societe.php ".$sql);
$result1=$db->query($sql_del);
$result1 = $db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")";
$sql .= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql .= ($label ? "'".$db->escape($label)."'" : 'null').", ";
$sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null");
$sql .= ")";
dol_syslog("societe.php", LOG_DEBUG);
$result2=$db->query($sql);
$result2 = $db->query($sql);
if ($result1 && $result2)
{
$db->commit();
@ -185,11 +185,11 @@ if ($action == 'setdoc')
}
//Activate Set ref in list
if ($action=="setaddrefinlist") {
if ($action == "setaddrefinlist") {
$setaddrefinlist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -200,11 +200,11 @@ if ($action=="setaddrefinlist") {
}
//Activate Set adress in list
if ($action=="setaddadressinlist") {
if ($action == "setaddadressinlist") {
$val = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -215,11 +215,11 @@ if ($action=="setaddadressinlist") {
}
//Activate Ask For Preferred Shipping Method
if ($action=="setaskforshippingmet") {
if ($action == "setaskforshippingmet") {
$setaskforshippingmet = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -230,11 +230,11 @@ if ($action=="setaskforshippingmet") {
}
//Activate "Disable prospect/customer type"
if ($action=="setdisableprospectcustomer") {
if ($action == "setdisableprospectcustomer") {
$setdisableprospectcustomer = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -249,7 +249,7 @@ if ($action == 'setprofid')
{
$status = GETPOST('status', 'alpha');
$idprof="SOCIETE_".$value."_UNIQUE";
$idprof = "SOCIETE_".$value."_UNIQUE";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
{
//header("Location: ".$_SERVER["PHP_SELF"]);
@ -266,7 +266,7 @@ if ($action == 'setprofidmandatory')
{
$status = GETPOST('status', 'alpha');
$idprof="SOCIETE_".$value."_MANDATORY";
$idprof = "SOCIETE_".$value."_MANDATORY";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
{
//header("Location: ".$_SERVER["PHP_SELF"]);
@ -283,7 +283,7 @@ if ($action == 'setprofidinvoicemandatory')
{
$status = GETPOST('status', 'alpha');
$idprof="SOCIETE_".$value."_INVOICE_MANDATORY";
$idprof = "SOCIETE_".$value."_INVOICE_MANDATORY";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0)
{
//header("Location: ".$_SERVER["PHP_SELF"]);
@ -310,11 +310,11 @@ if ($action == 'sethideinactivethirdparty')
dol_print_error($db);
}
}
if($action=='setonsearchandlistgooncustomerorsuppliercard'){
if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
$setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error)
if (!$res > 0) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -330,12 +330,12 @@ if($action=='setonsearchandlistgooncustomerorsuppliercard'){
clearstatcache();
$form=new Form($db);
$form = new Form($db);
$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros';
$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros';
llxHeader('', $langs->trans("CompanySetup"), $help_url);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup');
@ -343,8 +343,8 @@ $head = societe_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company');
$dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
foreach ($conf->modules_parts['models'] as $mo) $dirsociete[]=$mo.'core/modules/societe/'; //Add more models
$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
foreach ($conf->modules_parts['models'] as $mo) $dirsociete[] = $mo.'core/modules/societe/'; //Add more models
// Module to manage customer/supplier code
@ -370,16 +370,16 @@ foreach ($dirsociete as $dirroot)
if (is_resource($handle))
{
// Loop on each module find in opened directory
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
$file = substr($file, 0, dol_strlen($file) - 4);
try {
dol_include_once($dirroot.$file.'.php');
}
catch(Exception $e)
catch (Exception $e)
{
dol_syslog($e->getMessage(), LOG_ERR);
}
@ -387,7 +387,7 @@ foreach ($dirsociete as $dirroot)
$modCodeTiers = new $file;
// Show modules according to features level
if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
$arrayofmodules[$file] = $modCodeTiers;
@ -399,7 +399,7 @@ foreach ($dirsociete as $dirroot)
$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
foreach($arrayofmodules as $file => $modCodeTiers)
foreach ($arrayofmodules as $file => $modCodeTiers)
{
print '<tr class="oddeven">'."\n";
print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
@ -414,16 +414,16 @@ foreach($arrayofmodules as $file => $modCodeTiers)
}
else
{
$disabled = (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
$disabled = (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
print '<td class="center">';
if (! $disabled) print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">';
if (!$disabled) print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">';
print img_picto($langs->trans("Disabled"), 'switch_off');
if (! $disabled) print '</a>';
if (!$disabled) print '</a>';
print '</td>';
}
print '<td class="center">';
$s=$modCodeTiers->getToolTip($langs, null, -1);
$s = $modCodeTiers->getToolTip($langs, null, -1);
print $form->textwithpicto('', $s, 1);
print '</td>';
@ -458,16 +458,16 @@ foreach ($dirsociete as $dirroot)
$handle = @opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
$file = substr($file, 0, dol_strlen($file) - 4);
try {
dol_include_once($dirroot.$file.'.php');
}
catch(Exception $e)
catch (Exception $e)
{
dol_syslog($e->getMessage(), LOG_ERR);
}
@ -484,7 +484,7 @@ foreach ($dirsociete as $dirroot)
$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
foreach($arrayofmodules as $file => $modCodeCompta)
foreach ($arrayofmodules as $file => $modCodeCompta)
{
print '<tr class="oddeven">';
print '<td>'.$modCodeCompta->name."</td><td>\n";
@ -505,7 +505,7 @@ foreach($arrayofmodules as $file => $modCodeCompta)
print '</a></td>';
}
print '<td class="center">';
$s=$modCodeCompta->getToolTip($langs, null, -1);
$s = $modCodeCompta->getToolTip($langs, null, -1);
print $form->textwithpicto('', $s, 1);
print '</td>';
print "</tr>\n";
@ -523,14 +523,14 @@ print load_fiche_titre($langs->trans("ModelModules"), '', '');
// Load array def with activated templates
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = 'company'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = 'company'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
@ -557,30 +557,30 @@ foreach ($dirsociete as $dirroot)
{
$dir = dol_buildpath($dirroot.'doc/', 0);
$handle=@opendir($dir);
$handle = @opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (preg_match('/\.modules\.php$/i', $file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
try {
dol_include_once($dirroot.'doc/'.$file);
}
catch(Exception $e)
catch (Exception $e)
{
dol_syslog($e->getMessage(), LOG_ERR);
}
$module = new $classname($db);
$modulequalified=1;
if (! empty($module->version)) {
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
$modulequalified = 1;
if (!empty($module->version)) {
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
}
if ($modulequalified)
@ -625,14 +625,14 @@ foreach ($dirsociete as $dirroot)
}
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
$htmltooltip .= '<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1);
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraft").': '.yn((!empty($module->option_draft_watermark) ? $module->option_draft_watermark : ''), 1, 1);
print '<td class="center nowrap">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
@ -642,11 +642,11 @@ foreach ($dirsociete as $dirroot)
print '<td class="center nowrap">';
if ($module->type == 'pdf')
{
$linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
$linkspec = '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
}
else
{
$linkspec=img_object($langs->trans("PreviewNotAvailable"), 'generic');
$linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic');
}
print $linkspec;
print '</td>';
@ -676,38 +676,38 @@ print '<td class="center">'.$langs->trans("MustBeMandatory").'</td>';
print '<td class="center">'.$langs->trans("MustBeInvoiceMandatory").'</td>';
print "</tr>\n";
$profid['IDPROF1'][0]=$langs->trans("ProfId1");
$profid['IDPROF1'][1]=$langs->transcountry('ProfId1', $mysoc->country_code);
$profid['IDPROF2'][0]=$langs->trans("ProfId2");
$profid['IDPROF2'][1]=$langs->transcountry('ProfId2', $mysoc->country_code);
$profid['IDPROF3'][0]=$langs->trans("ProfId3");
$profid['IDPROF3'][1]=$langs->transcountry('ProfId3', $mysoc->country_code);
$profid['IDPROF4'][0]=$langs->trans("ProfId4");
$profid['IDPROF4'][1]=$langs->transcountry('ProfId4', $mysoc->country_code);
$profid['IDPROF5'][0]=$langs->trans("ProfId5");
$profid['IDPROF5'][1]=$langs->transcountry('ProfId5', $mysoc->country_code);
$profid['IDPROF6'][0]=$langs->trans("ProfId6");
$profid['IDPROF6'][1]=$langs->transcountry('ProfId6', $mysoc->country_code);
$profid['EMAIL'][0]=$langs->trans("EMail");
$profid['EMAIL'][1]=$langs->trans('Email');
$profid['IDPROF1'][0] = $langs->trans("ProfId1");
$profid['IDPROF1'][1] = $langs->transcountry('ProfId1', $mysoc->country_code);
$profid['IDPROF2'][0] = $langs->trans("ProfId2");
$profid['IDPROF2'][1] = $langs->transcountry('ProfId2', $mysoc->country_code);
$profid['IDPROF3'][0] = $langs->trans("ProfId3");
$profid['IDPROF3'][1] = $langs->transcountry('ProfId3', $mysoc->country_code);
$profid['IDPROF4'][0] = $langs->trans("ProfId4");
$profid['IDPROF4'][1] = $langs->transcountry('ProfId4', $mysoc->country_code);
$profid['IDPROF5'][0] = $langs->trans("ProfId5");
$profid['IDPROF5'][1] = $langs->transcountry('ProfId5', $mysoc->country_code);
$profid['IDPROF6'][0] = $langs->trans("ProfId6");
$profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code);
$profid['EMAIL'][0] = $langs->trans("EMail");
$profid['EMAIL'][1] = $langs->trans('Email');
$nbofloop=count($profid);
foreach($profid as $key => $val)
$nbofloop = count($profid);
foreach ($profid as $key => $val)
{
if ($profid[$key][1]!='-')
if ($profid[$key][1] != '-')
{
print '<tr class="oddeven">';
print '<td>'.$profid[$key][0]."</td><td>\n";
print $profid[$key][1];
print '</td>';
$idprof_unique ='SOCIETE_'.$key.'_UNIQUE';
$idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY';
$idprof_invoice_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY';
$idprof_unique = 'SOCIETE_'.$key.'_UNIQUE';
$idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY';
$idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY';
$verif=(empty($conf->global->$idprof_unique)?false:true);
$mandatory=(empty($conf->global->$idprof_mandatory)?false:true);
$invoice_mandatory=(empty($conf->global->$idprof_invoice_mandatory)?false:true);
$verif = (empty($conf->global->$idprof_unique) ?false:true);
$mandatory = (empty($conf->global->$idprof_mandatory) ?false:true);
$invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true);
if ($verif)
{
@ -761,7 +761,7 @@ print "<br>\n";
print load_fiche_titre($langs->trans("Other"), '', '');
// Autres options
$form=new Form($db);
$form = new Form($db);
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -778,7 +778,7 @@ print '<td width="80">&nbsp;</td></tr>'."\n";
print '<tr class="oddeven">';
print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>';
if (! $conf->use_javascript_ajax)
if (!$conf->use_javascript_ajax)
{
print '<td class="nowrap right" colspan="2">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
@ -787,7 +787,7 @@ if (! $conf->use_javascript_ajax)
else
{
print '<td width="60" class="right">';
$arrval=array('0'=>$langs->trans("No"),
$arrval = array('0'=>$langs->trans("No"),
'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
@ -802,7 +802,7 @@ print '</tr>';
print '<tr class="oddeven">';
print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>';
if (! $conf->use_javascript_ajax)
if (!$conf->use_javascript_ajax)
{
print '<td class="nowrap right" colspan="2">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
@ -811,7 +811,7 @@ if (! $conf->use_javascript_ajax)
else
{
print '<td width="60" class="right">';
$arrval=array('0'=>$langs->trans("No"),
$arrval = array('0'=>$langs->trans("No"),
'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',

View File

@ -42,22 +42,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$langs->loadLangs(array("companies","commercial","bills","banks","users"));
if (! empty($conf->categorie->enabled)) $langs->load("categories");
if (! empty($conf->incoterm->enabled)) $langs->load("incoterm");
if (! empty($conf->notification->enabled)) $langs->load("mails");
$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
if (!empty($conf->categorie->enabled)) $langs->load("categories");
if (!empty($conf->incoterm->enabled)) $langs->load("incoterm");
if (!empty($conf->notification->enabled)) $langs->load("mails");
$mesg=''; $error=0; $errors=array();
$mesg = ''; $error = 0; $errors = array();
$action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$confirm = GETPOST('confirm');
$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
if ($user->socid) $socid=$user->socid;
if (empty($socid) && $action == 'view') $action='create';
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
if ($user->socid) $socid = $user->socid;
if (empty($socid) && $action == 'view') $action = 'create';
$object = new Societe($db);
$extrafields = new ExtraFields($db);
@ -88,7 +88,7 @@ if (!empty($canvas))
// Security check
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas);
if(empty($user->rights->societe->contact->lire)) accessforbidden();
if (empty($user->rights->societe->contact->lire)) accessforbidden();
@ -151,7 +151,7 @@ dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company');
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
dol_fiche_end();

View File

@ -37,15 +37,15 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$langs->loadLangs(array('agenda', 'admin', 'other'));
$def = array();
$actiontest=GETPOST('test', 'alpha');
$actionsave=GETPOST('save', 'alpha');
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'useragenda'; // To manage different context of search
$actiontest = GETPOST('test', 'alpha');
$actionsave = GETPOST('save', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useragenda'; // To manage different context of search
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
// List of available colors
$colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5');
$colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', 'A4A4A5');
// Security check
$id = GETPOST('id', 'int');
@ -54,25 +54,25 @@ $object->fetch($id, '', '', 1);
$object->getrights();
// Security check
$socid=0;
$socid = 0;
if ($user->socid > 0) $socid = $user->socid;
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
// If user is not user that read and no permission to read other users, we stop
if (($object->id != $user->id) && (! $user->rights->user->user->lire))
if (($object->id != $user->id) && (!$user->rights->user->user->lire))
accessforbidden();
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('usercard','useragenda','globalcard'));
$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard'));
/*
* Actions
*/
$parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
@ -97,16 +97,16 @@ if (empty($reshook)) {
if (!empty($src) && !dol_is_url($src)) {
setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
$error ++;
$errorsaved ++;
$error++;
$errorsaved++;
break;
}
$tabparam['AGENDA_EXT_NAME_'.$id.'_'.$i]=$name;
$tabparam['AGENDA_EXT_SRC_'.$id.'_'.$i]=$src;
$tabparam['AGENDA_EXT_OFFSETTZ_'.$id.'_'.$i]=$offsettz;
$tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i]=$color;
$tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i]=$enabled;
$tabparam['AGENDA_EXT_NAME_'.$id.'_'.$i] = $name;
$tabparam['AGENDA_EXT_SRC_'.$id.'_'.$i] = $src;
$tabparam['AGENDA_EXT_OFFSETTZ_'.$id.'_'.$i] = $offsettz;
$tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i] = $color;
$tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i] = $enabled;
$i++;
}
@ -114,7 +114,7 @@ if (empty($reshook)) {
if (!$error) {
$result = dol_set_user_param($db, $conf, $object, $tabparam);
if (!$result > 0) {
$error ++;
$error++;
}
}
@ -134,12 +134,12 @@ if (empty($reshook)) {
* View
*/
$form=new Form($db);
$formadmin=new FormAdmin($db);
$formother=new FormOther($db);
$form = new Form($db);
$formadmin = new FormAdmin($db);
$formother = new FormOther($db);
$arrayofjs=array();
$arrayofcss=array();
$arrayofjs = array();
$arrayofcss = array();
llxHeader('', $langs->trans("UserSetup"), '', '', 0, 0, $arrayofjs, $arrayofcss);
@ -148,7 +148,7 @@ print '<form name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="pos
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
$head=user_prepare_head($object);
$head = user_prepare_head($object);
dol_fiche_head($head, 'extsites', $langs->trans("User"), -1, 'user');
@ -167,8 +167,8 @@ print '<br>';
print '<span class="opacitymedium">'.$langs->trans("AgendaExtSitesDesc")."</span><br>\n";
print "<br>\n";
$selectedvalue=$conf->global->AGENDA_DISABLE_EXT;
if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
$selectedvalue = $conf->global->AGENDA_DISABLE_EXT;
if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1;
print '<div class="div-table-responsive">';
@ -182,29 +182,29 @@ print "<td>".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFix
print '<td class="right">'.$langs->trans("Color").'</td>';
print "</tr>";
$i=1;
$i = 1;
while ($i <= $MAXAGENDA)
{
$key=$i;
$name='AGENDA_EXT_NAME_'.$id.'_'.$key;
$src='AGENDA_EXT_SRC_'.$id.'_'.$key;
$offsettz='AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key;
$color='AGENDA_EXT_COLOR_'.$id.'_'.$key;
$key = $i;
$name = 'AGENDA_EXT_NAME_'.$id.'_'.$key;
$src = 'AGENDA_EXT_SRC_'.$id.'_'.$key;
$offsettz = 'AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key;
$color = 'AGENDA_EXT_COLOR_'.$id.'_'.$key;
print '<tr class="oddeven">';
// Nb
print '<td class="maxwidth50onsmartphone">'.$langs->trans("AgendaExtNb", $key)."</td>";
// Name
print '<td class="maxwidth50onsmartphone"><input type="text" class="flat hideifnotset minwidth100" name="AGENDA_EXT_NAME_'.$id.'_'.$key.'" value="'. (GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$key)?GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$key):$object->conf->$name) . '"></td>';
print '<td class="maxwidth50onsmartphone"><input type="text" class="flat hideifnotset minwidth100" name="AGENDA_EXT_NAME_'.$id.'_'.$key.'" value="'.(GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$key) ?GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$key) : $object->conf->$name).'"></td>';
// URL
print '<td class="maxwidth50onsmartphone"><input type="url" class="flat hideifnotset" name="AGENDA_EXT_SRC_'.$id.'_'.$key.'" value="'. (GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$key)?GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$key):$object->conf->$src) . '"></td>';
print '<td class="maxwidth50onsmartphone"><input type="url" class="flat hideifnotset" name="AGENDA_EXT_SRC_'.$id.'_'.$key.'" value="'.(GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$key) ?GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$key) : $object->conf->$src).'"></td>';
// Offset TZ
print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key.'" value="'. (GETPOST('AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key)?GETPOST('AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key):$object->conf->$offsettz) . '" size="1"></td>';
print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key.'" value="'.(GETPOST('AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key) ?GETPOST('AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key) : $object->conf->$offsettz).'" size="1"></td>';
// Color (Possible colors are limited by Google)
print '<td class="nowrap right">';
//print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist);
print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key)?GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key):$object->conf->$color), "AGENDA_EXT_COLOR_".$id.'_'.$key, 'extsitesconfig', 1, '', 'hideifnotset');
print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key) ?GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key) : $object->conf->$color), "AGENDA_EXT_COLOR_".$id.'_'.$key, 'extsitesconfig', 1, '', 'hideifnotset');
print '</td>';
print "</tr>";
$i++;