Merge remote-tracking branch 'upstream/develop' into actioncomm_category

This commit is contained in:
Frédéric FRANCE 2019-12-03 17:56:43 +01:00
commit 4c5c6b6ff1
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
134 changed files with 4371 additions and 4234 deletions

View File

@ -67,6 +67,21 @@ with
}
}
* In tecnickcom/tcpdf/include/tcpdf_static, in function fopenLocal, replace
if (strpos($filename, '://') === false) {
with
if (strpos($filename, '//') === 0)
{
// Share folder on a (windows) server
// e.g.: "//[MyServerName]/[MySharedFolder]/"
//
// nothing to change
}
elseif (strpos($filename, '://') === false)
* To avoid to have QRcode changed because generated with a random mask, replace
define('QR_FIND_FROM_RANDOM', 2);
with

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
$langs->loadLangs(array("companies", "bills", "members", "users", "other"));
$langs->loadLangs(array("companies", "bills", "members", "users", "other", "paypal"));
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
@ -822,7 +822,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$trigger_name = 'MEMBER_SENTBYMAIL';
$triggersendname = 'MEMBER_SENTBYMAIL';
$paramname = 'id';
$mode = 'emailfrommember';
$trackid = 'mem'.$object->id;

View File

@ -95,7 +95,7 @@ if ($action == 'update' && empty($_POST["cancel"]))
// Actions to send emails
$id = 0;
$actiontypecode = ''; // Not an event for agenda
$trigger_name = ''; // Disable triggers
$triggersendname = ''; // Disable triggers
$paramname = 'id';
$mode = 'emailfortest';
$trackid = (($action == 'testhtml') ? "testhtml" : "test");

View File

@ -77,7 +77,7 @@ if ($action == 'update' && empty($_POST["cancel"]))
// Actions to send emails
$id=0;
$actiontypecode=''; // Not an event for agenda
$trigger_name=''; // Disable triggers
$triggersendname = ''; // Disable triggers
$paramname='id';
$mode='emailfortest';
$trackid=(($action == 'testhtml')?"testhtml":"test");

View File

@ -97,7 +97,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
$trigger_name = 'ASSET_SENTBYMAIL';
$triggersendname = 'ASSET_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_ASSET_TO';
$trackid = 'asset'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';

View File

@ -46,7 +46,7 @@ function blockedlogadmin_prepare_head()
$b=new BlockedLog($db);
if ($b->alreadyUsed())
{
$head[$h][1].=' <span class="badge">...</span>';
$head[$h][1].='<span class="badge marginleftonlyshort">...</span>';
}
$head[$h][2] = 'fingerprints';
$h++;

View File

@ -119,7 +119,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$trigger_name = 'BOM_SENTBYMAIL';
$triggersendname = 'BOM_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_BOM_TO';
$trackid = 'bom'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';

View File

@ -1051,7 +1051,7 @@ class BOMLine extends CommonObjectLine
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',),
'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
//'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'),
//'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'),
'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
);

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

@ -72,6 +72,7 @@ $coldisplay++;
$tmpproduct = new Product($object->db);
$tmpproduct->fetch($line->fk_product);
print $tmpproduct->getNomUrl(1);
print ' - '.$tmpproduct->label;
print '</td>';
print '<td class="linecolqty nowrap right">';
$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

@ -695,7 +695,7 @@ if ($object->id > 0)
print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id.'">'.$langs->trans("AllPropals").' <span class="badge">'.$num.'</span></a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id.'">'.$langs->trans("AllPropals").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';
@ -780,7 +780,7 @@ if ($object->id > 0)
print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomerOrders", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' <span class="badge">'.$num.'</span></a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomerOrders", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'">'.$langs->trans("AllOrders").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
//if($num2 > 0) print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').'</a></td>';
//else print '<td width="20px" class="right"><a href="#">'.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'</a></td>';
@ -856,7 +856,7 @@ if ($object->id > 0)
print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSendings", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expedition/list.php?socid='.$object->id.'">'.$langs->trans("AllSendings").' <span class="badge">'.$num.'</span></a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastSendings", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/expedition/list.php?socid='.$object->id.'">'.$langs->trans("AllSendings").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/expedition/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';
@ -921,7 +921,7 @@ if ($object->id > 0)
print '<tr class="liste_titre">';
print '<td colspan="6"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->id.'">'.$langs->trans("AllContracts").' <span class="badge">'.$num.'</span></a></td>';
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->id.'">'.$langs->trans("AllContracts").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
//print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/contract/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';
@ -990,7 +990,7 @@ if ($object->id > 0)
print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">';
print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'">'.$langs->trans("AllInterventions").' <span class="badge">'.$num.'</span></td>';
print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'">'.$langs->trans("AllInterventions").'<span class="badge marginleftonlyshort">'.$num.'</span></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/fichinter/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';
@ -1063,7 +1063,7 @@ if ($object->id > 0)
print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllCustomerTemplateInvoices").' <span class="badge">'.$num.'</span></a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllCustomerTemplateInvoices").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '</tr></table></td>';
print '</tr>';
}
@ -1168,7 +1168,7 @@ if ($object->id > 0)
print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre">';
print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllBills").' <span class="badge">'.$num.'</span></a></td>';
print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllBills").'<span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';

View File

@ -251,7 +251,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
print '<th colspan="3">'.$langs->trans("SupplierProposalsDraft").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
if ($num > 0)
{
@ -333,7 +333,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("DraftOrders").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
print '<th colspan="3">'.$langs->trans("DraftOrders").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
if ($num > 0)
{
@ -422,7 +422,7 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande-
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
print '<th colspan="3">'.$langs->trans("DraftSuppliersOrders").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
if ($num > 0)
{

View File

@ -781,7 +781,7 @@ if (empty($reshook))
// Actions to send emails
$actiontypecode = 'AC_OTH_AUTO';
$trigger_name = 'PROPAL_SENTBYMAIL';
$triggersendname = 'PROPAL_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_PROPOSAL_TO';
$trackid = 'pro'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';

View File

@ -2501,11 +2501,11 @@ class Propal extends CommonObject
if ($resql)
{
$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->modelpdf;
$trigger_name = 'PROPAL_CLOSE_REFUSED';
$triggerName = 'PROPAL_CLOSE_REFUSED';
if ($statut == self::STATUS_SIGNED)
{
$trigger_name = 'PROPAL_CLOSE_SIGNED';
$triggerName = 'PROPAL_CLOSE_SIGNED';
$modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->modelpdf;
// The connected company is classified as a client
@ -2522,7 +2522,7 @@ class Propal extends CommonObject
}
if ($statut == self::STATUS_BILLED) // Why this ?
{
$trigger_name = 'PROPAL_CLASSIFY_BILLED';
$triggerName = 'PROPAL_CLASSIFY_BILLED';
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
@ -2550,7 +2550,7 @@ class Propal extends CommonObject
if (!$notrigger && empty($error))
{
// Call trigger
$result = $this->call_trigger($trigger_name, $user);
$result = $this->call_trigger($triggerName, $user);
if ($result < 0) { $error++; }
// End call triggers
}

View File

@ -62,10 +62,12 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
//if ($user->rights->facture->creer)
$amount_ttc_1 = GETPOST('amount_ttc_1');
$amount_ttc_1 = price2num($amount_ttc_1);
$amount_ttc_2 = GETPOST('amount_ttc_2');
$amount_ttc_2 = price2num($amount_ttc_2);
$error = 0;
$remid = GETPOST("remid") ?GETPOST("remid") : 0;
$remid = (GETPOST("remid", 'int') ? GETPOST("remid", 'int') : 0);
$discount = new DiscountAbsolute($db);
$res = $discount->fetch($remid);
if (!$res > 0)

View File

@ -1415,7 +1415,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$trigger_name = 'ORDER_SENTBYMAIL';
$triggersendname = 'ORDER_SENTBYMAIL';
$paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add
$trackid = 'ord'.$object->id;

View File

@ -223,7 +223,7 @@ if (empty($reshook))
$permissiontoread = $user->rights->commande->lire;
$permissiontodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->multidir_output[$conf->entity];
$trigger_name = 'ORDER_SENTBYMAIL';
$triggersendname = 'ORDER_SENTBYMAIL';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}

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

@ -2481,7 +2481,7 @@ if (empty($reshook))
// Actions to send emails
if (empty($id)) $id = $facid;
$trigger_name = 'BILL_SENTBYMAIL';
$triggersendname = 'BILL_SENTBYMAIL';
$paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_INVOICE_TO';
$trackid = 'inv'.$object->id;

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

@ -170,7 +170,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("CustomersDraftInvoices").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
print '<th colspan="3">'.$langs->trans("CustomersDraftInvoices").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
if ($num)
{
$companystatic = new Societe($db);
@ -257,7 +257,7 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("SuppliersDraftInvoices").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
print '<th colspan="3">'.$langs->trans("SuppliersDraftInvoices").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
if ($num)
{
$companystatic = new Societe($db);

View File

@ -482,7 +482,7 @@ if (empty($reshook))
}
// Actions to send emails
$trigger_name = 'CONTACT_SENTBYMAIL';
$triggersendname = 'CONTACT_SENTBYMAIL';
$paramname = 'id';
$mode = 'emailfromcontact';
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';

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

@ -1002,7 +1002,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$trigger_name = 'CONTRACT_SENTBYMAIL';
$triggersendname = 'CONTRACT_SENTBYMAIL';
$paramname = 'id';
$mode = 'emailfromcontract';
$trackid = 'con'.$object->id;

View File

@ -260,7 +260,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire)
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="3">'.$langs->trans("DraftContracts").($num ? ' <span class="badge">'.$num.'</span>' : '').'</th></tr>';
print '<th colspan="3">'.$langs->trans("DraftContracts").($num ? '<span class="badge marginleftonlyshort">'.$num.'</span>' : '').'</th></tr>';
if ($num)
{
$companystatic = new Societe($db);

View File

@ -26,7 +26,7 @@
// $id must be defined
// $paramname may be defined
// $autocopy may be defined (used to know the automatic BCC to add)
// $trigger_name must be set (can be '')
// $triggersendname must be set (can be '')
// $actiontypecode can be set
// $object and $uobject may be defined
@ -453,12 +453,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$object->email_subject = $subject;
$object->email_msgid = $mailfile->msgid;
// Call of triggers
if (! empty($trigger_name))
// Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprcated)
if (! empty($triggersendname) || ! empty($trigger_name))
{
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result=$interface->run_triggers($trigger_name, $object, $user, $langs, $conf);
$result=$interface->run_triggers(empty($triggersendname)?$trigger_name:$triggersendname, $object, $user, $langs, $conf);
if ($result < 0) {
setEventMessages($interface->error, $interface->errors, 'errors');
}

View File

@ -289,25 +289,49 @@ if ($type == 'directory')
}
else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"));
if ($module == 'medias')
{
$useinecm = 6;
$modulepart='medias';
$perm=($user->rights->website->write || $user->rights->emailing->creer);
$title='none';
}
else
{
$useinecm = 5;
$modulepart='ecm';
$perm=$user->rights->ecm->upload;
$title=''; // Use default
}
if ($module == 'medias')
{
$useinecm = 6;
$modulepart='medias';
$perm=($user->rights->website->write || $user->rights->emailing->creer);
$title='none';
}
elseif($module == 'ecm') // DMS/ECM -> manual structure
{
if($user->rights->ecm->read)
{
// Buttons: Preview
$useinecm = 2;
}
// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
//var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
if($user->rights->ecm->upload)
{
// Buttons: Preview + Delete
$useinecm = 4;
}
if($user->rights->ecm->setup)
{
// Buttons: Preview + Delete + Edit
$useinecm = 5;
}
$perm=$user->rights->ecm->upload;
$modulepart='ecm';
$title=''; // Use default
}
else
{
$useinecm = 5;
$modulepart='ecm';
$perm=$user->rights->ecm->upload;
$title=''; // Use default
}
// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
//var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
}
}

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

@ -4956,11 +4956,11 @@ abstract class CommonObject
* NB: Error from trigger are stacked in interface->errors
* NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction.
*
* @param string $trigger_name trigger's name to execute
* @param string $triggerName trigger's name to execute
* @param User $user Object user
* @return int Result of run_triggers
*/
public function call_trigger($trigger_name, $user)
public function call_trigger($triggerName, $user)
{
// phpcs:enable
global $langs, $conf;
@ -4972,7 +4972,7 @@ abstract class CommonObject
include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
$interface = new Interfaces($this->db);
$result = $interface->run_triggers($trigger_name, $this, $user, $langs, $conf);
$result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
if ($result < 0)
{

View File

@ -689,6 +689,11 @@ class DiscountAbsolute
global $langs;
$result='';
$link = '';
$linkend = '';
$label = '';
$picto = '';
$ref = '';
if ($option == 'invoice') {
$facid=! empty($this->discount_type)?$this->fk_invoice_supplier_source:$this->fk_facture_source;

View File

@ -228,6 +228,7 @@ class Form
elseif (preg_match('/^select;/', $typeofdata))
{
$arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
$arraylist = array();
foreach ($arraydata as $val)
{
$tmp = explode(':', $val);
@ -265,6 +266,7 @@ class Form
elseif (preg_match('/^select;/', $typeofdata))
{
$arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
$arraylist = array();
foreach ($arraydata as $val)
{
$tmp = explode(':', $val);
@ -4869,7 +4871,7 @@ class Form
* @param int $forcecombo Force to use combo box
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param int $nooutput No print output. Return it only.
* @return void
* @return void|string
*/
public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0)
{

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;

View File

@ -1099,7 +1099,7 @@ class FormFile
if ($disablecrop == -1)
{
$disablecrop = 1;
if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'project', 'product', 'produit', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0;
if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'mrp', 'project', 'product', 'produit', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0;
}
// Define relative path used to store the file

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'));
@ -341,6 +341,7 @@ class Notify
$object_type = '';
$link = '';
$num = 0;
$error = 0;
$oldref=(empty($object->oldref)?$object->ref:$object->oldref);
$newref=(empty($object->newref)?$object->ref:$object->newref);
@ -408,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/';
@ -508,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 = '';
@ -519,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(
@ -555,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);
}
@ -569,7 +570,7 @@ class Notify
else
{
$error++;
$this->errors[]=$mailfile->error;
$this->errors[] = $mailfile->error;
}
}
else
@ -587,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)
@ -606,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');
@ -616,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/';
@ -721,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 = '';
@ -732,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);
@ -742,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,
@ -787,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);
}
@ -796,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

@ -486,7 +486,7 @@ function actions_prepare_head($object)
$nbLinks=Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$object->id;
$head[$h][1] = $langs->trans("Documents");
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
$head[$h][2] = 'documents';
$h++;

View File

@ -185,7 +185,7 @@ function account_statement_prepare_head($object, $num)
$head[$h][0] = DOL_URL_ROOT."/compta/bank/account_statement_document.php?account=".$object->id."&num=".$num;
$head[$h][1] = $langs->trans("Documents");
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
$head[$h][2] = 'document';
$h++;

View File

@ -228,7 +228,7 @@ function societe_prepare_head(Societe $object)
$head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
$head[$h][1] = $title;
if ($foundonexternalonlinesystem) $head[$h][1] .= ' <span class="badge">...</span>';
if ($foundonexternalonlinesystem) $head[$h][1] .= '<span class="badge marginleftonlyshort">...</span>';
elseif ($nbBankAccount > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbBankAccount.'</span>';
$head[$h][2] = 'rib';
$h++;

View File

@ -7896,23 +7896,26 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
$tmpfile = preg_replace('/\.noexe$/', '', $file);
// Text files
// Plain text files
if (preg_match('/\.txt$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; }
if (preg_match('/\.rtx$/i', $tmpfile)) { $mime = 'text/richtext'; $imgmime = 'text.png'; $famime = 'file-text-o'; }
if (preg_match('/\.csv$/i', $tmpfile)) { $mime = 'text/csv'; $imgmime = 'text.png'; $famime = 'file-text-o'; }
if (preg_match('/\.tsv$/i', $tmpfile)) { $mime = 'text/tab-separated-values'; $imgmime = 'text.png'; $famime = 'file-text-o'; }
if (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; }
if (preg_match('/\.ini$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'ini'; $famime = 'file-text-o'; }
if (preg_match('/\.md$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'md'; $famime = 'file-text-o'; }
if (preg_match('/\.css$/i', $tmpfile)) { $mime = 'text/css'; $imgmime = 'css.png'; $srclang = 'css'; $famime = 'file-text-o'; }
// Certificate files
if (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; }
// HTML/XML
// XML based (HTML/XML/XAML)
if (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { $mime = 'text/html'; $imgmime = 'html.png'; $srclang = 'html'; $famime = 'file-text-o'; }
if (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) { $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xml'; $famime = 'file-text-o'; }
if (preg_match('/\.xaml$/i', $tmpfile)) { $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xaml'; $famime = 'file-text-o'; }
// Languages
if (preg_match('/\.bas$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'bas'; $famime = 'file-code-o'; }
if (preg_match('/\.(c)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'c'; $famime = 'file-code-o'; }
if (preg_match('/\.(cpp)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cpp'; $famime = 'file-code-o'; }
if (preg_match('/\.cs$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cs'; $famime = 'file-code-o'; }
if (preg_match('/\.(h)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'h'; $famime = 'file-code-o'; }
if (preg_match('/\.(java|jsp)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'java'; $famime = 'file-code-o'; }
if (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'php.png'; $srclang = 'php'; $famime = 'file-code-o'; }

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

@ -111,7 +111,7 @@ function project_prepare_head($object)
if (!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
$head[$h][2] = 'notes';
$h++;
}
@ -2071,18 +2071,23 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide
else {
if ($task->hasDelay()) $out .= img_warning($langs->trans("Late")).' ';
$out .= !empty($diff) ? $diff.' ' : '';
$url = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$task->id;
$out .= !empty($diff) ? $diff.' ' : '';
$out .= '<a href="'.$url.'" >';
$out .= '<b title="'.$langs->trans('TimeSpent').'" >';
if ($task->duration_effective) $out .= convertSecondToTime($task->duration_effective, $timespentoutputformat);
else $out .= '--:--';
$out .= '</b>';
$out .= '</a>';
$out .= '/';
$out .= '<a href="'.$url.'" >';
$out .= '<span title="'.$langs->trans('PlannedWorkload').'" >';
if ($task->planned_workload) $out .= convertSecondToTime($task->planned_workload, $plannedworkloadoutputformat);
else $out .= '--:--';
$out .= '</a>';
}
$out .= ' </span>';
}
@ -2094,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

@ -510,6 +510,7 @@ class ExportExcel extends ModeleExports
{
$c = intval($c);
$letter = '';
if ($c <= 0) {
return '';
}

View File

@ -62,11 +62,11 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
*/
public function info()
{
global $conf, $langs;
global $conf, $langs, $db;
$langs->load("bills");
$form = new Form($this->db);
$form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';

View File

@ -150,6 +150,8 @@ class modStripe extends DolibarrModules
'target' => '',
'user' => 0
);
$r++;
$this->menu[$r] = array(
'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
'type' => 'left',

View File

@ -189,7 +189,7 @@ class modWebsite extends DolibarrModules
$src=$srcroot.'/'.$cursorfile['name'];
$dest=$destroot.'/'.$cursorfile['name'];
$result=dol_copy($src, $dest, 0, 0);
$result=dol_copy($src, $dest, 0, 1); // For full zip templates, we overwrite old existing files
if ($result < 0) {
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);

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';
/**
@ -64,35 +64,35 @@ class mod_propale_saphir extends ModeleNumRefPropales
*/
public function info()
{
global $conf, $langs;
global $conf, $langs, $db;
$langs->load("bills");
$form = new Form($this->db);
$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="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

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
/* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php';
*/
class mod_reception_moonstone extends ModelNumRefReception
{
public $version='dolibarr';
public $version = 'dolibarr';
public $error = '';
public $nom = 'Moonstone';
@ -40,11 +41,11 @@ class mod_reception_moonstone extends ModelNumRefReception
*/
public function info()
{
global $conf,$langs;
global $conf, $langs, $db;
$langs->load("bills");
$form = new Form($this->db);
$form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';

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

@ -825,7 +825,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
}
// Escompte
if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
if ($object->close_code == FactureFournisseur::CLOSECODE_DISCOUNTVAT)
{
$index++;
$pdf->SetFillColor(255, 255, 255);

View File

@ -64,11 +64,11 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
*/
public function info()
{
global $conf, $langs;
global $conf, $langs, $db;
$langs->load("bills");
$form = new Form($this->db);
$form = new Form($db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';

View File

@ -210,6 +210,17 @@ elseif ($modulepart == 'bom')
$dir = $conf->$modulepart->dir_output; // By default
}
}
elseif ($modulepart == 'mrp')
{
require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
$object = new MO($db);
if ($id > 0)
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir = $conf->$modulepart->dir_output; // By default
}
}
elseif ($modulepart == 'bank')
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@ -222,7 +233,7 @@ elseif ($modulepart == 'bank')
}
}
else {
print 'Action crop for modulepart = '.$modulepart.' is not supported yet.';
print 'Action crop for modulepart = '.$modulepart.' is not supported yet by photos_resize.php.';
}
if (empty($backtourl))
@ -237,6 +248,7 @@ if (empty($backtourl))
elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('mrp'))) $backtourl = DOL_URL_ROOT."/mrp/mo_document.php?id=".$id.'&file='.urldecode($_POST["file"]);
else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]);
}

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

@ -81,7 +81,7 @@ if ($permtoadd)
else
{
print '<a href="#" class="inline-block valignmiddle toolbarbutton" title="'.$langs->trans("NotAllowed").'">';
print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '<img class="toolbarbutton disabled" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
if ($module == 'ecm')

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

@ -795,18 +795,18 @@ class EcmDirectory // extends CommonObject
* NB2: if trigger fail, action should be canceled.
* NB3: Should be deleted if EcmDirectory extend CommonObject
*
* @param string $trigger_name trigger's name to execute
* @param string $triggerName trigger's name to execute
* @param User $user Object user
* @return int Result of run_triggers
*/
public function call_trigger($trigger_name, $user)
public function call_trigger($triggerName, $user)
{
// phpcs:enable
global $langs,$conf;
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers($trigger_name, $this, $user, $langs, $conf);
$result=$interface->run_triggers($triggerName, $this, $user, $langs, $conf);
if ($result < 0) {
if (!empty($this->errors))
{

View File

@ -849,7 +849,7 @@ if (empty($reshook))
// Actions to send emails
if (empty($id)) $id = $facid;
$trigger_name = 'SHIPPING_SENTBYMAIL';
$triggersendname = 'SHIPPING_SENTBYMAIL';
$paramname = 'id';
$mode = 'emailfromshipment';
$trackid = 'shi'.$object->id;

View File

@ -1411,7 +1411,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
$trigger_name = 'EXPENSEREPORT_SENTBYMAIL';
$triggersendname = 'EXPENSEREPORT_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO';
$trackid = 'exp'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
@ -2148,12 +2148,15 @@ else
if ($action != 'editline' || $line->rowid != GETPOST('rowid', 'int'))
{
print '<tr class="oddeven">';
// Num
print '<td class="center">';
print $numline;
print '</td>';
// Date
print '<td class="center">'.dol_print_date($db->jdate($line->date), 'day').'</td>';
// Project
if (!empty($conf->projet->enabled))
{

View File

@ -721,7 +721,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
$trigger_name = 'FICHINTER_SENTBYMAIL';
$triggersendname = 'FICHINTER_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_FICHINTER_TO';
$trackid = 'int'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';

View File

@ -468,7 +468,7 @@ if ($object->id > 0)
print '<table class="noborder centpercent lastrecordtable">';
print '<tr class="liste_titre'.(($num == 0) ? ' nobottom' : '').'">';
print '<td colspan="3">'.$langs->trans("ProductsAndServices").'</td><td class="right">';
print '<a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/product/list.php?fourn_id='.$object->id.'">'.$langs->trans("AllProductReferencesOfSupplier").' <span class="badge">'.$object->nbOfProductRefs().'</span>';
print '<a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/product/list.php?fourn_id='.$object->id.'">'.$langs->trans("AllProductReferencesOfSupplier").'<span class="badge marginleftonlyshort">'.$object->nbOfProductRefs().'</span>';
print '</a></td></tr>';
$return = array();
@ -542,7 +542,7 @@ if ($object->id > 0)
print '<tr class="liste_titre">';
print '<td colspan="3">';
print '<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id.'">'.$langs->trans("AllPriceRequests").' <span class="badge">'.$num.'</span></td>';
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id.'">'.$langs->trans("AllPriceRequests").'<span class="badge marginleftonlyshort">'.$num.'</span></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/supplier_proposal/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table>';
print '</td></tr>';
@ -653,7 +653,7 @@ if ($object->id > 0)
print '<tr class="liste_titre">';
print '<td colspan="3">';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' <span class="badge">'.$num.'</span></td>';
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'">'.$langs->trans("AllOrders").'<span class="badge marginleftonlyshort">'.$num.'</span></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table>';
print '</td></tr>';
@ -725,7 +725,7 @@ if ($object->id > 0)
print '<tr class="liste_titre">';
print '<td colspan="4">';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id.'">'.$langs->trans('AllBills').' <span class="badge">'.$num.'</span></td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id.'">'.$langs->trans('AllBills').'<span class="badge marginleftonlyshort">'.$num.'</span></td>';
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
print '</tr></table>';
print '</td></tr>';

View File

@ -2420,18 +2420,19 @@ class CommandeFournisseur extends CommonOrder
if ($resql)
{
// Trigger names for each status
$trigger_name[0] = 'DRAFT';
$trigger_name[1] = 'VALIDATED';
$trigger_name[2] = 'APPROVED';
$trigger_name[3] = 'ORDERED'; // Ordered
$trigger_name[4] = 'RECEIVED_PARTIALLY';
$trigger_name[5] = 'RECEIVED_COMPLETELY';
$trigger_name[6] = 'CANCELED';
$trigger_name[7] = 'CANCELED';
$trigger_name[9] = 'REFUSED';
$triggerName = array();
$triggerName[0] = 'DRAFT';
$triggerName[1] = 'VALIDATED';
$triggerName[2] = 'APPROVED';
$triggerName[3] = 'ORDERED'; // Ordered
$triggerName[4] = 'RECEIVED_PARTIALLY';
$triggerName[5] = 'RECEIVED_COMPLETELY';
$triggerName[6] = 'CANCELED';
$triggerName[7] = 'CANCELED';
$triggerName[9] = 'REFUSED';
// Call trigger
$result = $this->call_trigger("ORDER_SUPPLIER_STATUS_".$trigger_name[$status], $user);
$result = $this->call_trigger("ORDER_SUPPLIER_STATUS_".$triggerName[$status], $user);
if ($result < 0) { $error++; }
// End call triggers
}

View File

@ -1028,7 +1028,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
$trigger_name = 'ORDER_SUPPLIER_SENTBYMAIL';
$triggersendname = 'ORDER_SUPPLIER_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO';
$trackid = 'sor'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';

View File

@ -1497,7 +1497,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
$trigger_name = 'BILL_SUPPLIER_SENTBYMAIL';
$triggersendname = 'BILL_SUPPLIER_SENTBYMAIL';
$paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
$trackid = 'sin'.$object->id;

View File

@ -872,7 +872,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
$trigger_name='HOLIDAY_SENTBYMAIL';
$triggersendname = 'HOLIDAY_SENTBYMAIL';
$autocopy='MAIN_MAIL_AUTOCOPY_HOLIDAY_TO';
$trackid='leav'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';

View File

@ -1805,21 +1805,33 @@ class TCPDF_STATIC {
return $ret;
}
/**
* Wrapper to use fopen only with local files
* @param filename (string) Name of the file to open
* @param $mode (string)
* @return Returns a file pointer resource on success, or FALSE on error.
* @public static
*/
public static function fopenLocal($filename, $mode) {
if (strpos($filename, '://') === false) {
$filename = 'file://'.$filename;
} elseif (stream_is_local($filename) !== true) {
return false;
}
return fopen($filename, $mode);
}
/**
* Wrapper to use fopen only with local files
* @param string $filename The full path to the file to open
* @param string $mode Acceses type for the file ('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+' or 'e')
* @return resource Returns a file pointer resource on success, or FALSE on error.
* @public static
*/
public static function fopenLocal($filename, $mode)
{
if (strpos($filename, '//') === 0)
{
// Share folder on a (windows) server
// e.g.: "//[MyServerName]/[MySharedFolder]/"
//
// nothing to change
}
elseif (strpos($filename, '://') === false)
{
$filename = 'file://'.$filename;
}
elseif (stream_is_local($filename) !== true)
{
return false;
}
return fopen($filename, $mode);
}
/**
* Check if the URL exist.

View File

@ -78,7 +78,7 @@ ALTER TABLE llx_rights_def ADD COLUMN family_position INTEGER NOT NULL DEFAULT 0
UPDATE llx_rights_def SET subperms = 'write' WHERE perms = 'fiscalyear' AND module = 'accounting' AND subperms IS NULL;
ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL;
ALTER TABLE llx_bom_bom ADD COLUMN duration double(24,8) DEFAULT NULL;
ALTER TABLE llx_bom_bom ADD COLUMN fk_warehouse integer;
ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0;

View File

@ -26,8 +26,8 @@ CREATE TABLE llx_bom_bom(
note_private text,
fk_warehouse integer,
qty double(24,8),
efficiency double(8,4) DEFAULT 1,
duration double(8,4) DEFAULT NULL,
efficiency double(24,8) DEFAULT 1,
duration double(24,8) DEFAULT NULL,
date_creation datetime NOT NULL,
date_valid datetime,
tms timestamp,

View File

@ -24,7 +24,7 @@ CREATE TABLE llx_bom_bomline(
qty double(24,8) NOT NULL,
qty_frozen smallint DEFAULT 0,
disable_stock_change smallint DEFAULT 0,
efficiency double(8,4) NOT NULL DEFAULT 1,
efficiency double(24,8) NOT NULL DEFAULT 1,
position integer NOT NULL DEFAULT 0
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;

View File

@ -1138,7 +1138,7 @@ TriggerAlwaysActive=Triggers in this file are always active, whatever are the ac
TriggerActiveAsModuleActive=Triggers in this file are active as module <b>%s</b> is enabled.
GeneratedPasswordDesc=Choose the method to be used for auto-generated passwords.
DictionaryDesc=Insert all reference data. You can add your values to the default.
ConstDesc=This page allows you to edit (override) parameters not available in other pages. These are mostly reserved parameters for developers/advanced troubleshooting. For a full list of the parameters available <a href="https://wiki.dolibarr.org/index.php/Setup_Other#List_of_known_hidden_options" title="External Site - opens in a new window" target="_blank">see here</a>.
ConstDesc=This page allows you to edit (override) parameters not available in other pages. These are mostly reserved parameters for developers/advanced troubleshooting only.
MiscellaneousDesc=All other security related parameters are defined here.
LimitsSetup=Limits/Precision setup
LimitsDesc=You can define limits, precisions and optimizations used by Dolibarr here

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>
';

Some files were not shown because too many files have changed in this diff Show More