Merge pull request #16410 from frederic34/comm_codesyntax

code syntax comm directory
This commit is contained in:
Laurent Destailleur 2021-02-26 10:21:48 +01:00 committed by GitHub
commit 573ab9f91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 6072 additions and 4827 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -146,8 +146,12 @@ class ActionCommReminder extends CommonObject
$this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0;
if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
$this->fields['rowid']['visible'] = 0;
}
if (empty($conf->multicompany->enabled)) {
$this->fields['entity']['enabled'] = 0;
}
}
/**
@ -225,16 +229,25 @@ class ActionCommReminder extends CommonObject
global $langs;
$labelStatus = $langs->trans('ToDo');
if ($status == 1) $labelStatus = $langs->trans('Done');
elseif ($status == -1) $labelStatus = $langs->trans('Error');
if ($status == 1) {
$labelStatus = $langs->trans('Done');
} elseif ($status == -1) {
$labelStatus = $langs->trans('Error');
}
$labelStatusShort = $langs->trans('ToDo');
if ($status == 1) $labelStatus = $langs->trans('Done');
elseif ($status == -1) $labelStatus = $langs->trans('Error');
if ($status == 1) {
$labelStatus = $langs->trans('Done');
} elseif ($status == -1) {
$labelStatus = $langs->trans('Error');
}
$statusType = 'status5';
if ($status == 1) $statusType = 'status4';
elseif ($status == -1) $statusType = 'status8';
if ($status == 1) {
$statusType = 'status4';
} elseif ($status == -1) {
$statusType = 'status8';
}
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
}

View File

@ -114,34 +114,50 @@ class AgendaEvents extends DolibarrApi
// 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 ((!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)
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
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;
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)
{
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -150,8 +166,7 @@ class AgendaEvents extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@ -161,13 +176,11 @@ class AgendaEvents extends DolibarrApi
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$i = 0;
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
while ($i < $min) {
$obj = $this->db->fetch_object($result);
$actioncomm_static = new ActionComm($this->db);
if ($actioncomm_static->fetch($obj->rowid)) {
@ -206,12 +219,12 @@ class AgendaEvents extends DolibarrApi
$this->actioncomm->$field = $value;
}
/*if (isset($request_data["lines"])) {
$lines = array();
foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line);
}
$this->expensereport->lines = $lines;
}*/
$lines = array();
foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line);
}
$this->expensereport->lines = $lines;
}*/
if ($this->actioncomm->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating event", array_merge(array($this->actioncomm->error), $this->actioncomm->errors));
}
@ -251,12 +264,15 @@ class AgendaEvents extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
if ($field == 'id') {
continue;
}
$this->actioncomm->$field = $value;
}
if ($this->actioncomm->update(DolibarrApiAccess::$user, 1) > 0)
if ($this->actioncomm->update(DolibarrApiAccess::$user, 1) > 0) {
return $this->get($id);
}
return false;
}
@ -316,8 +332,9 @@ class AgendaEvents extends DolibarrApi
{
$event = array();
foreach (AgendaEvents::$FIELDS as $field) {
if (!isset($data[$field]))
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$event[$field] = $data[$field];
}
return $event;

View File

@ -106,15 +106,16 @@ class CActionComm
{
$sql = "SELECT id, code, type, libelle as label, color, active, picto";
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
if (is_numeric($id)) $sql .= " WHERE id=".(int) $id;
else $sql .= " WHERE code='".$this->db->escape($id)."'";
if (is_numeric($id)) {
$sql .= " WHERE id=".(int) $id;
} else {
$sql .= " WHERE code='".$this->db->escape($id)."'";
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->id;
@ -165,62 +166,76 @@ class CActionComm
if ($active != '') {
$sql .= " AND active=".(int) $active;
}
if (!empty($excludetype)) $sql .= " AND type <> '".$this->db->escape($excludetype)."'";
if ($morefilter) $sql .= " AND ".$morefilter;
if (!empty($excludetype)) {
$sql .= " AND type <> '".$this->db->escape($excludetype)."'";
}
if ($morefilter) {
$sql .= " AND ".$morefilter;
}
$sql .= " ORDER BY type, position, module";
dol_syslog(get_class($this)."::liste_array", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$nump = $this->db->num_rows($resql);
if ($nump)
{
if ($nump) {
$idforallfornewmodule = 97;
$i = 0;
while ($i < $nump)
{
while ($i < $nump) {
$obj = $this->db->fetch_object($resql);
$qualified = 1;
// $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto
if ($qualified && $onlyautoornot > 0 && preg_match('/^system/', $obj->type) && !preg_match('/^AC_OTH/', $obj->code)) $qualified = 0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO)
if ($qualified && $obj->module)
{
if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified = 0;
if ($obj->module == 'order' && !$conf->commande->enabled) $qualified = 0;
if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified = 0;
if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_invoice->enabled)) $qualified = 0;
if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_order->enabled)) $qualified = 0;
if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified = 0;
if ($qualified && $onlyautoornot > 0 && preg_match('/^system/', $obj->type) && !preg_match('/^AC_OTH/', $obj->code)) {
$qualified = 0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO)
}
if ($qualified)
{
if ($qualified && $obj->module) {
if ($obj->module == 'invoice' && !$conf->facture->enabled) {
$qualified = 0;
}
if ($obj->module == 'order' && !$conf->commande->enabled) {
$qualified = 0;
}
if ($obj->module == 'propal' && !$conf->propal->enabled) {
$qualified = 0;
}
if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_invoice->enabled)) {
$qualified = 0;
}
if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_order->enabled)) {
$qualified = 0;
}
if ($obj->module == 'shipping' && !$conf->expedition->enabled) {
$qualified = 0;
}
}
if ($qualified) {
$keyfortrans = '';
$transcode = '';
$code = $obj->code;
$typecalendar = $obj->type;
if ($onlyautoornot > 0 && $typecalendar == 'system') $code = 'AC_MANUAL';
elseif ($onlyautoornot > 0 && $typecalendar == 'systemauto') $code = 'AC_AUTO';
elseif ($onlyautoornot > 0) $code = 'AC_'.strtoupper($obj->module);
if ($onlyautoornot > 0 && $typecalendar == 'system') {
$code = 'AC_MANUAL';
} elseif ($onlyautoornot > 0 && $typecalendar == 'systemauto') {
$code = 'AC_AUTO';
} elseif ($onlyautoornot > 0) {
$code = 'AC_'.strtoupper($obj->module);
}
if ($shortlabel)
{
if ($shortlabel) {
$keyfortrans = "Action".$code.'Short';
$transcode = $langs->trans($keyfortrans);
}
if (empty($keyfortrans) || $keyfortrans == $transcode)
{
if (empty($keyfortrans) || $keyfortrans == $transcode) {
$keyfortrans = "Action".$code;
$transcode = $langs->trans($keyfortrans);
}
$label = (($transcode != $keyfortrans) ? $transcode : $langs->trans($obj->label));
if ($onlyautoornot == -1 && !empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if ($onlyautoornot == -1 && !empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
if ($typecalendar == 'system') {
$label = '&nbsp;&nbsp; '.$label;
$repid[-99] = $langs->trans("ActionAC_MANUAL");
@ -252,9 +267,13 @@ class CActionComm
}
}
if ($idorcode == 'id') $this->liste_array = $repid;
elseif ($idorcode == 'code') $this->liste_array = $repcode;
else $this->liste_array = $repall;
if ($idorcode == 'id') {
$this->liste_array = $repid;
} elseif ($idorcode == 'code') {
$this->liste_array = $repcode;
} else {
$this->liste_array = $repall;
}
return $this->liste_array;
} else {
@ -276,6 +295,8 @@ class CActionComm
// Check if translation available
$transcode = $langs->trans("Action".$this->code);
if ($transcode != "Action".$this->code) return $transcode;
if ($transcode != "Action".$this->code) {
return $transcode;
}
}
}

View File

@ -62,8 +62,7 @@ class ICal
$file_text = '';
$tmparray = file($file);
if (is_array($tmparray))
{
if (is_array($tmparray)) {
$file_text = join("", $tmparray); //load file
$file_text = preg_replace("/[\r\n]{1,} /", "", $file_text);
}
@ -112,21 +111,20 @@ class ICal
$this->file_text = preg_split("[\n]", $this->file_text);
// is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR
if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) return 'error not VCALENDAR';
if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) {
return 'error not VCALENDAR';
}
$insidealarm = 0;
$tmpkey = ''; $tmpvalue = ''; $type = '';
foreach ($this->file_text as $text)
{
foreach ($this->file_text as $text) {
$text = trim($text); // trim one line
if (!empty($text))
{
if (!empty($text)) {
// get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin
list($key, $value) = $this->retun_key_value($text);
//var_dump($text.' -> '.$key.' - '.$value);
switch ($text) // search special string
{
switch ($text) { // search special string
case "BEGIN:VTODO":
$this->todo_count = $this->todo_count + 1; // new to do begin
$type = "VTODO";
@ -152,7 +150,6 @@ class ICal
case "END:VTODO": // end special text - goto VCALENDAR key
case "END:VEVENT":
case "END:VFREEBUSY":
case "END:VCALENDAR":
case "END:DAYLIGHT":
case "END:VTIMEZONE":
@ -169,27 +166,25 @@ class ICal
break;
default: // no special string (SUMMARY, DESCRIPTION, ...)
if ($tmpvalue)
{
if ($tmpvalue) {
$tmpvalue .= $text;
if (!preg_match('/=$/', $text)) // No more lines
{
if (!preg_match('/=$/', $text)) { // No more lines
$key = $tmpkey;
$value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue));
$tmpkey = '';
$tmpvalue = '';
}
} elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value))
{
if (preg_match('/=$/', $value))
{
} elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) {
if (preg_match('/=$/', $value)) {
$tmpkey = $key;
$tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message
} else {
$value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value));
}
} //$value=quotedPrintDecode($tmpvalue.$value);
if (!$insidealarm && !$tmpkey) $this->add_to_array($type, $key, $value); // add to array
if (!$insidealarm && !$tmpkey) {
$this->add_to_array($type, $key, $value); // add to array
}
break;
}
}
@ -214,32 +209,35 @@ class ICal
//print 'type='.$type.' key='.$key.' value='.$value.'<br>'."\n";
if (empty($key))
{
if (empty($key)) {
$key = $this->last_key;
switch ($type)
{
case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break;
case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break;
case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value; break;
switch ($type) {
case 'VEVENT':
$value = $this->cal[$type][$this->event_count][$key].$value;
break;
case 'VFREEBUSY':
$value = $this->cal[$type][$this->freebusy_count][$key].$value;
break;
case 'VTODO':
$value = $this->cal[$type][$this->todo_count][$key].$value;
break;
}
}
if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value);
if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) {
$value = $this->ical_date_to_unix($value);
}
//if ($key == "RRULE" ) $value = $this->ical_rrule($value);
if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE"))
{
if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE"))
{
if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) {
if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) {
list($key, $value) = array($key, $value);
} else {
list($key, $value) = $this->ical_dt_date($key, $value);
}
}
switch ($type)
{
switch ($type) {
case "VTODO":
$this->cal[$type][$this->todo_count][$key] = $value;
break;
@ -270,17 +268,17 @@ class ICal
{
// phpcs:enable
/*
preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches);
preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches);
if (empty($matches))
{
return array(false,$text);
}
else
{
$matches = array_splice($matches, 1, 2);
return $matches;
}*/
if (empty($matches))
{
return array(false,$text);
}
else
{
$matches = array_splice($matches, 1, 2);
return $matches;
}*/
return explode(':', $text, 2);
}
@ -296,8 +294,7 @@ class ICal
// phpcs:enable
$result = array();
$rrule = explode(';', $value);
foreach ($rrule as $line)
{
foreach ($rrule as $line) {
$rcontent = explode('=', $line);
$result[$rcontent[0]] = $rcontent[1];
}
@ -319,8 +316,9 @@ class ICal
$ntime = 0;
// TIME LIMITED EVENT
if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date))
if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) {
$ntime = dol_mktime($date[4], $date[5], $date[6], $date[2], $date[3], $date[1], true);
}
//if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1];
//print dol_print_date($ntime,'dayhour');exit;
@ -344,8 +342,7 @@ class ICal
// Analyse TZID
$temp = explode(";", $key);
if (empty($temp[1])) // not TZID
{
if (empty($temp[1])) { // not TZID
$value = str_replace('T', '', $value);
return array($key, $value);
}
@ -368,8 +365,7 @@ class ICal
{
// phpcs:enable
$temp = $this->get_event_list();
if (!empty($temp))
{
if (!empty($temp)) {
usort($temp, array(&$this, "ical_dtstart_compare"));
return $temp;
} else {

View File

@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array('companies', 'commercial', 'other', 'bills'));
@ -45,9 +47,10 @@ $confirm = GETPOST('confirm', 'alpha');
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid > 0)
{
if ($user->socid) {
$socid = $user->socid;
}
if ($user->socid > 0) {
unset($_GET["action"]);
$action = '';
}
@ -55,8 +58,7 @@ $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|
$object = new ActionComm($db);
if ($id > 0)
{
if ($id > 0) {
$ret = $object->fetch($id);
$object->fetch_thirdparty();
}
@ -66,12 +68,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
$modulepart = 'actions';
@ -93,22 +101,24 @@ $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('', $langs->trans("Agenda"), $help_url);
if ($object->id > 0)
{
if ($object->id > 0) {
$result1 = $object->fetch($id);
$result2 = $object->fetch_thirdparty();
$result3 = $object->fetch_contact();
$result4 = $object->fetch_userassigned();
$result5 = $object->fetch_optionals();
if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
{
if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
dol_print_error($db, $object->error);
exit;
}
if ($object->authorid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser; }
if ($object->usermodid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser; }
if ($object->authorid > 0) {
$tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
}
if ($object->usermodid > 0) {
$tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
}
$author = new User($db);
$author->fetch($object->author->id);
@ -142,8 +152,7 @@ if ($object->id > 0)
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref .= $langs->trans('Project').': ';
@ -153,7 +162,9 @@ if ($object->id > 0)
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
if ($proj->title) $morehtmlref .= ' - '.$proj->title;
if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
} else {
$morehtmlref .= '';
}
@ -170,8 +181,7 @@ if ($object->id > 0)
print '<table class="border tableforfield centpercent">';
// Type
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>';
}
@ -180,44 +190,53 @@ if ($object->id > 0)
// Date start
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour');
else print dol_print_date($object->datep, 'day');
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
if (!$object->fulldayevent) {
print dol_print_date($object->datep, 'dayhour');
} else {
print dol_print_date($object->datep, 'day');
}
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
print img_warning($langs->trans("Late"));
}
print '</td>';
print '</tr>';
// Date end
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour');
else print dol_print_date($object->datef, 'day');
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
if (!$object->fulldayevent) {
print dol_print_date($object->datef, 'dayhour');
} else {
print dol_print_date($object->datef, 'day');
}
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
print img_warning($langs->trans("Late"));
}
print '</td></tr>';
// Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>';
}
// Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
$listofuserid = array();
if (empty($donotclearsession))
{
if ($object->userownerid > 0) $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first
if (!empty($object->userassigned)) // Now concat assigned users
{
if (empty($donotclearsession)) {
if ($object->userownerid > 0) {
$listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first
}
if (!empty($object->userassigned)) { // Now concat assigned users
// Restore array with key with same value than param 'id'
$tmplist1 = $object->userassigned;
foreach ($tmplist1 as $key => $val)
{
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val;
foreach ($tmplist1 as $key => $val) {
if ($val['id'] && $val['id'] != $object->userownerid) {
$listofuserid[$val['id']] = $val;
}
}
}
$_SESSION['assignedtouser'] = json_encode($listofuserid);
} else {
if (!empty($_SESSION['assignedtouser']))
{
if (!empty($_SESSION['assignedtouser'])) {
$listofuserid = json_decode($_SESSION['assignedtouser'], true);
}
}
@ -241,8 +260,7 @@ if ($object->id > 0)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,7 @@ $langs->load("commercial");
$id = GETPOST('id', 'int');
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@ -84,8 +83,7 @@ $morehtmlref = '<div class="refidno">';
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref .= $langs->trans('Project').': ';
@ -95,7 +93,9 @@ if (!empty($conf->projet->enabled))
$morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
if ($proj->title) $morehtmlref .= ' - '.$proj->title;
if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
} else {
$morehtmlref .= '';
}

View File

@ -27,7 +27,9 @@
* \brief Page to list actions
*/
if (!defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1);
if (!defined("NOREDIRECTBYMAINTOLOGIN")) {
define('NOREDIRECTBYMAINTOLOGIN', 1);
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@ -55,14 +57,17 @@ $toselect = GETPOST('toselect', 'array');
$confirm = GETPOST('confirm', 'alpha');
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
if (GETPOST('search_actioncode', 'array'))
{
if (GETPOST('search_actioncode', 'array')) {
$actioncode = GETPOST('search_actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
}
if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
if ($actioncode == '' && empty($actioncodearray)) {
$actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
}
$search_id = GETPOST('search_id', 'alpha');
$search_title = GETPOST('search_title', 'alpha');
$search_note = GETPOST('search_note', 'alpha');
@ -70,8 +75,12 @@ $search_note = GETPOST('search_note', 'alpha');
$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'), 'tzuserrel');
$datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'), 'tzuserrel');
$dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'), 'tzuserrel');
if ($search_status == '' && !GETPOSTISSET('search_status')) $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
if ($search_status == '' && !GETPOSTISSET('search_status')) {
$search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
}
if (empty($action) && !GETPOSTISSET('action')) {
$action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
}
$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
@ -89,8 +98,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// If not choice done on calendar owner, we filter on user.
if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
{
if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
$filtert = $user->id;
}
@ -98,30 +106,41 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if ($page == -1 || $page == null) { $page = 0; }
$offset = $limit * $page;
if (!$sortorder)
{
$sortorder = "DESC,DESC";
if ($search_status == 'todo') $sortorder = "DESC,DESC";
if ($page == -1 || $page == null) {
$page = 0;
}
if (!$sortfield)
{
$offset = $limit * $page;
if (!$sortorder) {
$sortorder = "DESC,DESC";
if ($search_status == 'todo') {
$sortorder = "DESC,DESC";
}
}
if (!$sortfield) {
$sortfield = "a.datep,a.id";
if ($search_status == 'todo') $sortfield = "a.datep,a.id";
if ($search_status == 'todo') {
$sortfield = "a.datep,a.id";
}
}
// Security check
$socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'agenda', 0, '', 'myactions');
if ($socid < 0) $socid = '';
if ($socid < 0) {
$socid = '';
}
$canedit = 1;
if (!$user->rights->agenda->myactions->read) accessforbidden();
if (!$user->rights->agenda->allactions->read) $canedit = 0;
if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me
{
if (!$user->rights->agenda->myactions->read) {
accessforbidden();
}
if (!$user->rights->agenda->allactions->read) {
$canedit = 0;
}
if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me
$filtert = $user->id;
}
@ -152,18 +171,14 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
* Actions
*/
if (GETPOST('cancel', 'alpha'))
{
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
{
if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) {
$param = '';
if (is_array($_POST))
{
foreach ($_POST as $key => $val)
{
if (is_array($_POST)) {
foreach ($_POST as $key => $val) {
$param .= '&'.$key.'='.urlencode($val);
}
}
@ -174,13 +189,14 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
$parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
//$actioncode='';
$search_id = '';
$search_title = '';
@ -192,12 +208,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_array_options = array();
}
if (empty($reshook) && !empty($massaction))
{
if (empty($reshook) && !empty($massaction)) {
unset($percent);
switch ($massaction)
{
switch ($massaction) {
case 'set_all_events_to_todo':
$percent = ActionComm::EVENT_TODO;
break;
@ -211,13 +225,10 @@ if (empty($reshook) && !empty($massaction))
break;
}
if (isset($percent))
{
foreach ($toselect as $toselectid)
{
if (isset($percent)) {
foreach ($toselect as $toselectid) {
$result = $object->updatePercent($toselectid, $percent);
if ($result < 0)
{
if ($result < 0) {
dol_print_error($db);
break;
}
@ -226,8 +237,7 @@ if (empty($reshook) && !empty($massaction))
}
// As mass deletion happens with a confirm step, $massaction is not use for the final step (deletion).
if (empty($reshook))
{
if (empty($reshook)) {
$objectclass = 'ActionComm';
$objectlabel = 'Events';
$uploaddir = true;
@ -258,32 +268,78 @@ llxHeader('', $langs->trans("Agenda"), $help_url);
$listofextcals = array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($actioncode != '') {
if (is_array($actioncode)) {
foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action);
} else $param .= "&search_actioncode=".urlencode($actioncode);
foreach ($actioncode as $str_action) {
$param .= "&search_actioncode[]=".urlencode($str_action);
}
} else {
$param .= "&search_actioncode=".urlencode($actioncode);
}
}
if ($resourceid > 0) {
$param .= "&search_resourceid=".urlencode($resourceid);
}
if ($search_status != '' && $search_status > -1) {
$param .= "&search_status=".urlencode($search_status);
}
if ($filter) {
$param .= "&search_filter=".urlencode($filter);
}
if ($filtert) {
$param .= "&search_filtert=".urlencode($filtert);
}
if ($usergroup > 0) {
$param .= "&search_usergroup=".urlencode($usergroup);
}
if ($socid > 0) {
$param .= "&search_socid=".urlencode($socid);
}
if ($showbirthday) {
$param .= "&search_showbirthday=1";
}
if ($pid) {
$param .= "&search_projectid=".urlencode($pid);
}
if ($type) {
$param .= "&search_type=".urlencode($type);
}
if ($search_id != '') {
$param .= '&search_title='.urlencode($search_id);
}
if ($search_title != '') {
$param .= '&search_title='.urlencode($search_title);
}
if ($search_note != '') {
$param .= '&search_note='.$search_note;
}
if (GETPOST('datestartday', 'int')) {
$param .= '&datestartday='.GETPOST('datestartday', 'int');
}
if (GETPOST('datestartmonth', 'int')) {
$param .= '&datestartmonth='.GETPOST('datestartmonth', 'int');
}
if (GETPOST('datestartyear', 'int')) {
$param .= '&datestartyear='.GETPOST('datestartyear', 'int');
}
if (GETPOST('dateendday', 'int')) {
$param .= '&dateendday='.GETPOST('dateendday', 'int');
}
if (GETPOST('dateendmonth', 'int')) {
$param .= '&dateendmonth='.GETPOST('dateendmonth', 'int');
}
if (GETPOST('dateendyear', 'int')) {
$param .= '&dateendyear='.GETPOST('dateendyear', 'int');
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid);
if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status);
if ($filter) $param .= "&search_filter=".urlencode($filter);
if ($filtert) $param .= "&search_filtert=".urlencode($filtert);
if ($usergroup > 0) $param .= "&search_usergroup=".urlencode($usergroup);
if ($socid > 0) $param .= "&search_socid=".urlencode($socid);
if ($showbirthday) $param .= "&search_showbirthday=1";
if ($pid) $param .= "&search_projectid=".urlencode($pid);
if ($type) $param .= "&search_type=".urlencode($type);
if ($search_id != '') $param .= '&search_title='.urlencode($search_id);
if ($search_title != '') $param .= '&search_title='.urlencode($search_title);
if ($search_note != '') $param .= '&search_note='.$search_note;
if (GETPOST('datestartday', 'int')) $param .= '&datestartday='.GETPOST('datestartday', 'int');
if (GETPOST('datestartmonth', 'int')) $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int');
if (GETPOST('datestartyear', 'int')) $param .= '&datestartyear='.GETPOST('datestartyear', 'int');
if (GETPOST('dateendday', 'int')) $param .= '&dateendday='.GETPOST('dateendday', 'int');
if (GETPOST('dateendmonth', 'int')) $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int');
if (GETPOST('dateendyear', 'int')) $param .= '&dateendyear='.GETPOST('dateendyear', 'int');
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -295,16 +351,21 @@ $arrayofmassactions = array(
'set_all_events_to_in_progress' => $langs->trans("SetAllEventsToInProgress"),
'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"),
);
if ($user->rights->agenda->allactions->delete)
{
if ($user->rights->agenda->allactions->delete) {
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
if ($user->rights->agenda->myactions->create) {
$arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$sql = "SELECT";
if ($usergroup > 0) $sql .= " DISTINCT";
if ($usergroup > 0) {
$sql .= " DISTINCT";
}
$sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
$sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,";
$sql .= ' a.fk_user_author,a.fk_user_action,';
@ -315,7 +376,9 @@ $sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as
// 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 : '');
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
@ -325,34 +388,47 @@ $sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) ";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c";
// We must filter on resource table
if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
if ($resourceid > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
}
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
if ($filtert > 0 || $usergroup > 0) {
$sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
}
if ($usergroup > 0) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
}
$sql .= " WHERE c.id = a.fk_action";
$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
// Condition on actioncode
if (!empty($actioncode))
{
if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'";
else {
if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'";
if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'";
if (!empty($actioncode)) {
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
if ($actioncode == 'AC_NON_AUTO') {
$sql .= " AND c.type != 'systemauto'";
} elseif ($actioncode == 'AC_ALL_AUTO') {
$sql .= " AND c.type = 'systemauto'";
} else {
if ($actioncode == 'AC_OTH') {
$sql .= " AND c.type != 'systemauto'";
}
if ($actioncode == 'AC_OTH_AUTO') {
$sql .= " AND c.type = 'systemauto'";
}
}
} else {
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'";
else {
if (is_array($actioncode))
{
if ($actioncode == 'AC_NON_AUTO') {
$sql .= " AND c.type != 'systemauto'";
} elseif ($actioncode == 'AC_ALL_AUTO') {
$sql .= " AND c.type = 'systemauto'";
} else {
if (is_array($actioncode)) {
$sql .= " AND c.code IN ('".implode("','", $actioncode)."')";
} else {
$sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')";
@ -360,35 +436,74 @@ if (!empty($actioncode))
}
}
}
if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid);
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
if ($resourceid > 0) {
$sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
}
if ($pid) {
$sql .= " AND a.fk_project=".$db->escape($pid);
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
}
if ($socid > 0) {
$sql .= " AND s.rowid = ".$socid;
}
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($type) $sql .= " AND c.id = ".(int) $type;
if ($search_status == '0') { $sql .= " AND a.percent = 0"; }
if ($search_status == 'na') { $sql .= " AND a.percent = -1"; } // Not applicable
if ($search_status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
if ($search_status == '100') { $sql .= " AND a.percent = 100"; }
if ($search_status == 'done') { $sql .= " AND (a.percent = 100)"; }
if ($search_status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; }
if ($search_id) $sql .= natural_search("a.id", $search_id, 1);
if ($search_title) $sql .= natural_search("a.label", $search_title);
if ($search_note) $sql .= natural_search('a.note', $search_note);
if ($filtert > 0 || $usergroup > 0) {
$sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
}
if ($type) {
$sql .= " AND c.id = ".(int) $type;
}
if ($search_status == '0') {
$sql .= " AND a.percent = 0";
}
if ($search_status == 'na') {
$sql .= " AND a.percent = -1";
} // Not applicable
if ($search_status == '50') {
$sql .= " AND (a.percent > 0 AND a.percent < 100)";
} // Running already started
if ($search_status == '100') {
$sql .= " AND a.percent = 100";
}
if ($search_status == 'done') {
$sql .= " AND (a.percent = 100)";
}
if ($search_status == 'todo') {
$sql .= " AND (a.percent >= 0 AND a.percent < 100)";
}
if ($search_id) {
$sql .= natural_search("a.id", $search_id, 1);
}
if ($search_title) {
$sql .= natural_search("a.label", $search_title);
}
if ($search_note) {
$sql .= natural_search('a.note', $search_note);
}
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0)
{
if ($filtert > 0 || $usergroup > 0) {
$sql .= " AND (";
if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility
if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
if ($filtert > 0) {
$sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility
}
if ($usergroup > 0) {
$sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
}
$sql .= ")";
}
// The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
if ($dateselect > 0) $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))";
if ($datestart > 0) $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'";
if ($dateend > 0) $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'";
if ($dateselect > 0) {
$sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))";
}
if ($datestart > 0) {
$sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'";
}
if ($dateend > 0) {
$sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'";
}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -401,12 +516,10 @@ $sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
@ -417,8 +530,7 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("comm/action/list.php", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$actionstatic = new ActionComm($db);
$societestatic = new Societe($db);
@ -438,7 +550,9 @@ if ($resql)
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@ -446,8 +560,12 @@ if ($resql)
print '<input type="hidden" name="type" value="'.$type.'">';
$nav = '';
if ($filter) $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
if ($showbirthday) $nav .= '<input type="hidden" name="search_showbirthday" value="1">';
if ($filter) {
$nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
}
if ($showbirthday) {
$nav .= '<input type="hidden" name="search_showbirthday" value="1">';
}
print $nav;
//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
@ -457,19 +575,19 @@ if ($resql)
// Add link to show birthdays
$link = '';
/*
if (empty($conf->use_javascript_ajax))
{
$newparam=$param; // newparam is for birthday links
$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
$link='<a href="'.$_SERVER['PHP_SELF'];
$link.='?'.$newparam;
$link.='">';
if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
else $link.=$langs->trans("AgendaHideBirthdayEvents");
$link.='</a>';
}
*/
if (empty($conf->use_javascript_ajax))
{
$newparam=$param; // newparam is for birthday links
$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
$link='<a href="'.$_SERVER['PHP_SELF'];
$link.='?'.$newparam;
$link.='">';
if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
else $link.=$langs->trans("AgendaHideBirthdayEvents");
$link.='</a>';
}
*/
$s = $newtitle;
@ -550,7 +668,9 @@ if ($resql)
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
if ($massactionbutton) {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
}
$i = 0;
print '<div class="liste_titre liste_titre_bydiv centpercent">';
@ -561,11 +681,21 @@ if ($resql)
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['a.id']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
if (!empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
if (!empty($arrayfields['a.note']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
if (!empty($arrayfields['a.id']['checked'])) {
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
}
if (!empty($arrayfields['owner']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['c.libelle']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['a.label']['checked'])) {
print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
}
if (!empty($arrayfields['a.note']['checked'])) {
print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
}
if (!empty($arrayfields['a.datep']['checked'])) {
print '<td class="liste_titre nowraponall" align="center">';
print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
@ -579,8 +709,12 @@ if ($resql)
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['a.fk_contact']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['a.fk_element']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['a.fk_contact']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['a.fk_element']['checked'])) {
print '<td class="liste_titre"></td>';
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@ -590,8 +724,12 @@ if ($resql)
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['a.datec']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['a.tms']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['a.datec']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['a.tms']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['a.percent']['checked'])) {
print '<td class="liste_titre center">';
$formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125');
@ -606,17 +744,37 @@ if ($resql)
print "</tr>\n";
print '<tr class="liste_titre">';
if (!empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['a.id']['checked'])) {
print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['owner']['checked'])) {
print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['c.libelle']['checked'])) {
print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['a.label']['checked'])) {
print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['a.note']['checked'])) {
print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
}
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
if (!empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $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['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
if (!empty($arrayfields['a.datep']['checked'])) {
print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['a.datep2']['checked'])) {
print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $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['a.fk_contact']['checked'])) {
print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
}
if (!empty($arrayfields['a.fk_element']['checked'])) {
print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -626,10 +784,16 @@ if ($resql)
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['a.datec']['checked'])) {
print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['a.tms']['checked'])) {
print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
}
if (!empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['a.percent']['checked'])) {
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n";
@ -642,13 +806,11 @@ if ($resql)
$arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
$contactListCache = array();
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
// Discard auto action if option is on
if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO')
{
if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') {
$i++;
continue;
}
@ -676,29 +838,34 @@ if ($resql)
}
// User owner
if (!empty($arrayfields['owner']['checked']))
{
if (!empty($arrayfields['owner']['checked'])) {
print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text.
if ($obj->fk_user_action > 0)
{
if ($obj->fk_user_action > 0) {
$userstatic->fetch($obj->fk_user_action);
print $userstatic->getNomUrl(-1);
} else print '&nbsp;';
} else {
print '&nbsp;';
}
print '</td>';
}
// Type
if (!empty($arrayfields['c.libelle']['checked']))
{
if (!empty($arrayfields['c.libelle']['checked'])) {
print '<td class="nowraponall">';
print $actionstatic->getTypePicto();
$labeltype = $obj->type_code;
if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH';
if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
$labeltype = 'AC_OTH';
}
if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') {
$labeltype = $langs->trans("Message");
} else {
if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype];
if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
if (!empty($arraylist[$labeltype])) {
$labeltype = $arraylist[$labeltype];
}
if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) {
$labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
}
}
print dol_trunc($labeltype, 28);
print '</td>';
@ -726,11 +893,21 @@ if ($resql)
print '<td class="center nowraponall">';
print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser');
$late = 0;
if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1;
if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
if ($late) print img_warning($langs->trans("Late")).' ';
if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
$late = 1;
}
if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) {
$late = 1;
}
if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) {
$late = 1;
}
if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
$late = 1;
}
if ($late) {
print img_warning($langs->trans("Late")).' ';
}
print '</td>';
}
@ -744,15 +921,16 @@ if ($resql)
// Third party
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="tdoverflowmax150">';
if ($obj->socid > 0)
{
if ($obj->socid > 0) {
$societestatic->id = $obj->socid;
$societestatic->client = $obj->client;
$societestatic->name = $obj->societe;
$societestatic->email = $obj->socemail;
print $societestatic->getNomUrl(1, '', 28);
} else print '&nbsp;';
} else {
print '&nbsp;';
}
print '</td>';
}
@ -760,17 +938,13 @@ if ($resql)
if (!empty($arrayfields['a.fk_contact']['checked'])) {
print '<td class="tdoverflowmax100">';
if (!empty($actionstatic->socpeopleassigned))
{
if (!empty($actionstatic->socpeopleassigned)) {
$contactList = array();
foreach ($actionstatic->socpeopleassigned as $socpeopleassigned)
{
if (!isset($contactListCache[$socpeopleassigned['id']]))
{
foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) {
if (!isset($contactListCache[$socpeopleassigned['id']])) {
// if no cache found we fetch it
$contact = new Contact($db);
if ($contact->fetch($socpeopleassigned['id']) > 0)
{
if ($contact->fetch($socpeopleassigned['id']) > 0) {
$contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0);
$contactList[] = $contact->getNomUrl(1, '', 0);
}
@ -782,8 +956,7 @@ if ($resql)
if (!empty($contactList)) {
print implode(', ', $contactList);
}
} elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event
{
} elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event
$contactstatic->id = $obj->fk_contact;
$contactstatic->email = $obj->email;
$contactstatic->lastname = $obj->lastname;
@ -835,10 +1008,11 @@ if ($resql)
}
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->id, $arrayofselected)) $selected = 1;
if (in_array($obj->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';

View File

@ -39,7 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
}
$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
@ -49,31 +51,43 @@ $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup",
$showbirthday = 0;
// If not choice done on calendar owner, we filter on user.
if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
{
if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
$filtert = $user->id;
}
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "a.datec";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "a.datec";
}
// Security check
$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'agenda', 0, '', 'myactions');
if ($socid < 0) $socid = '';
if ($socid < 0) {
$socid = '';
}
$canedit = 1;
if (!$user->rights->agenda->myactions->read) accessforbidden();
if (!$user->rights->agenda->allactions->read) $canedit = 0;
if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me
{
if (!$user->rights->agenda->myactions->read) {
accessforbidden();
}
if (!$user->rights->agenda->allactions->read) {
$canedit = 0;
}
if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me
$filtert = $user->id;
}
@ -90,18 +104,20 @@ $type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPO
$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
if (GETPOST('search_actioncode', 'array'))
{
if (GETPOST('search_actioncode', 'array')) {
$actioncode = GETPOST('search_actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
}
if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
if ($actioncode == '' && empty($actioncodearray)) {
$actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
}
$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
if ($dateselect > 0)
{
if ($dateselect > 0) {
$day = GETPOST('dateselectday', 'int');
$month = GETPOST('dateselectmonth', 'int');
$year = GETPOST('dateselectyear', 'int');
@ -112,9 +128,15 @@ $tmp = str_replace(' ', '', $tmp); // FIX 7533
$tmparray = explode('-', $tmp);
$begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9);
$end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18);
if ($begin_h < 0 || $begin_h > 23) $begin_h = 9;
if ($end_h < 1 || $end_h > 24) $end_h = 18;
if ($end_h <= $begin_h) $end_h = $begin_h + 1;
if ($begin_h < 0 || $begin_h > 23) {
$begin_h = 9;
}
if ($end_h < 1 || $end_h > 24) {
$end_h = 18;
}
if ($end_h <= $begin_h) {
$end_h = $begin_h + 1;
}
$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
$tmp = str_replace(' ', '', $tmp); // FIX 7533
@ -122,8 +144,12 @@ $tmparray = explode('-', $tmp);
$begin_d = 1;
$end_d = 53;
if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
if ($status == '' && !GETPOSTISSET('status')) {
$status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
}
if (empty($action) && !GETPOSTISSET('action')) {
$action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
}
if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') {
$action = 'show_month'; $day = '';
@ -149,8 +175,7 @@ $hookmanager->initHooks(array('agenda'));
* Actions
*/
if ($action == 'delete_action')
{
if ($action == 'delete_action') {
$event = new ActionComm($db);
$event->fetch($actionid);
$event->fetch_optionals();
@ -185,7 +210,9 @@ $parameters = array(
'usergroup' => $usergroup,
);
$reshook = $hookmanager->executeHooks('beforeAgendaPerType', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
$form = new Form($db);
$companystatic = new Societe($db);
@ -223,29 +250,65 @@ $tmpday = $first_day;
//print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
$title = $langs->trans("DoneAndToDoActions");
if ($status == 'done') $title = $langs->trans("DoneActions");
if ($status == 'todo') $title = $langs->trans("ToDoActions");
if ($status == 'done') {
$title = $langs->trans("DoneActions");
}
if ($status == 'todo') {
$title = $langs->trans("ToDoActions");
}
$param = '';
if ($actioncode || GETPOSTISSET('search_actioncode')) {
if (is_array($actioncode)) {
foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action);
} else $param .= "&search_actioncode=".urlencode($actioncode);
foreach ($actioncode as $str_action) {
$param .= "&search_actioncode[]=".urlencode($str_action);
}
} else {
$param .= "&search_actioncode=".urlencode($actioncode);
}
}
if ($resourceid > 0) {
$param .= "&search_resourceid=".urlencode($resourceid);
}
if ($status || GETPOSTISSET('status')) {
$param .= "&search_status=".urlencode($status);
}
if ($filter) {
$param .= "&search_filter=".urlencode($filter);
}
if ($filtert) {
$param .= "&search_filtert=".urlencode($filtert);
}
if ($usergroup > 0) {
$param .= "&search_usergroup=".urlencode($usergroup);
}
if ($socid > 0) {
$param .= "&search_socid=".urlencode($socid);
}
if ($showbirthday) {
$param .= "&search_showbirthday=1";
}
if ($pid) {
$param .= "&search_projectid=".urlencode($pid);
}
if ($type) {
$param .= "&search_type=".urlencode($type);
}
if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') {
$param .= '&action='.urlencode($action);
}
if ($begin_h != '') {
$param .= '&begin_h='.urlencode($begin_h);
}
if ($end_h != '') {
$param .= '&end_h='.urlencode($end_h);
}
if ($begin_d != '') {
$param .= '&begin_d='.urlencode($begin_d);
}
if ($end_d != '') {
$param .= '&end_d='.urlencode($end_d);
}
if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid);
if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status);
if ($filter) $param .= "&search_filter=".urlencode($filter);
if ($filtert) $param .= "&search_filtert=".urlencode($filtert);
if ($usergroup > 0) $param .= "&search_usergroup=".urlencode($usergroup);
if ($socid > 0) $param .= "&search_socid=".urlencode($socid);
if ($showbirthday) $param .= "&search_showbirthday=1";
if ($pid) $param .= "&search_projectid=".urlencode($pid);
if ($type) $param .= "&search_type=".urlencode($type);
if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param .= '&action='.urlencode($action);
if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h);
if ($end_h != '') $param .= '&end_h='.urlencode($end_h);
if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d);
if ($end_d != '') $param .= '&end_d='.urlencode($end_d);
$param .= "&maxprint=".urlencode($maxprint);
$paramnoactionodate = $param;
@ -301,28 +364,23 @@ print '<form method="POST" id="searchFormList" class="listactionsfilter" action=
$showextcals = $listofextcals;
// Legend
if ($conf->use_javascript_ajax)
{
if ($conf->use_javascript_ajax) {
$s = '';
$s .= '<script type="text/javascript">'."\n";
$s .= 'jQuery(document).ready(function () {'."\n";
$s .= 'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'."\n";
$s .= 'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'."\n";
$s .= 'jQuery(".family_birthday").toggle();'."\n";
if ($action == "show_week" || $action == "show_month" || empty($action))
{
if ($action == "show_week" || $action == "show_month" || empty($action)) {
$s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {';
$s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n";
}
$s .= '});'."\n";
$s .= '});'."\n";
$s .= '</script>'."\n";
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
$s .= '<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
if (is_array($showextcals) && count($showextcals) > 0)
{
foreach ($showextcals as $val)
{
if (is_array($showextcals) && count($showextcals) > 0) {
foreach ($showextcals as $val) {
$htmlname = md5($val['name']);
$s .= '<script type="text/javascript">'."\n";
$s .= 'jQuery(document).ready(function () {'."\n";
@ -341,11 +399,9 @@ if ($conf->use_javascript_ajax)
// Calendars from hooks
$parameters = array(); $object = null;
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
if (empty($reshook))
{
if (empty($reshook)) {
$s .= $hookmanager->resPrint;
} elseif ($reshook > 1)
{
} elseif ($reshook > 1) {
$s = $hookmanager->resPrint;
}
}
@ -397,8 +453,7 @@ if (empty($reshook)) {
$newcardbutton = '';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
{
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
$tmpforcreatebutton = dol_getdate(dol_now(), true);
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
@ -435,7 +490,9 @@ $eventarray = array();
// DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
$sql = 'SELECT';
if ($usergroup > 0) $sql .= " DISTINCT";
if ($usergroup > 0) {
$sql .= " DISTINCT";
}
$sql .= ' a.id, a.label,';
$sql .= ' a.datep,';
$sql .= ' a.datep2,';
@ -445,31 +502,44 @@ $sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,';
$sql .= ' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto';
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
}
// We must filter on resource table
if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
if ($resourceid > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
}
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
if ($filtert > 0 || $usergroup > 0) {
$sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
}
if ($usergroup > 0) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
}
$sql .= ' WHERE a.fk_action = ca.id';
$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
// Condition on actioncode
if (!empty($actioncode))
{
if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
else {
if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
if (!empty($actioncode)) {
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
if ($actioncode == 'AC_NON_AUTO') {
$sql .= " AND ca.type != 'systemauto'";
} elseif ($actioncode == 'AC_ALL_AUTO') {
$sql .= " AND ca.type = 'systemauto'";
} else {
if ($actioncode == 'AC_OTH') {
$sql .= " AND ca.type != 'systemauto'";
}
if ($actioncode == 'AC_OTH_AUTO') {
$sql .= " AND ca.type = 'systemauto'";
}
}
} else {
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
else {
if (is_array($actioncode))
{
if ($actioncode == 'AC_NON_AUTO') {
$sql .= " AND ca.type != 'systemauto'";
} elseif ($actioncode == 'AC_ALL_AUTO') {
$sql .= " AND ca.type = 'systemauto'";
} else {
if (is_array($actioncode)) {
$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
} else {
$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
@ -477,14 +547,23 @@ if (!empty($actioncode))
}
}
}
if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid);
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid;
if ($resourceid > 0) {
$sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
}
if ($pid) {
$sql .= " AND a.fk_project=".$db->escape($pid);
}
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
}
if ($socid > 0) {
$sql .= ' AND a.fk_soc = '.$socid;
}
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($action == 'show_day')
{
if ($filtert > 0 || $usergroup > 0) {
$sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
}
if ($action == 'show_day') {
$sql .= " AND (";
$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'";
$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
@ -508,18 +587,33 @@ if ($action == 'show_day')
$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')";
$sql .= ')';
}
if ($type) $sql .= " AND ca.id = ".$type;
if ($status == '0') { $sql .= " AND a.percent = 0"; }
if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; }
if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; }
if ($type) {
$sql .= " AND ca.id = ".$type;
}
if ($status == '0') {
$sql .= " AND a.percent = 0";
}
if ($status == '-1') {
$sql .= " AND a.percent = -1";
} // Not applicable
if ($status == '50') {
$sql .= " AND (a.percent > 0 AND a.percent < 100)";
} // Running already started
if ($status == 'done' || $status == '100') {
$sql .= " AND (a.percent = 100)";
}
if ($status == 'todo') {
$sql .= " AND (a.percent >= 0 AND a.percent < 100)";
}
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0)
{
if ($filtert > 0 || $usergroup > 0) {
$sql .= " AND (";
if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert;
if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
if ($filtert > 0) {
$sql .= "ar.fk_element = ".$filtert;
}
if ($usergroup > 0) {
$sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
}
$sql .= ")";
}
// Sort on date
@ -528,17 +622,14 @@ $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action
dol_syslog("comm/action/pertype.php", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
// Discard auto action if option is on
if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO')
{
if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') {
$i++;
continue;
}
@ -572,34 +663,41 @@ if ($resql)
// Defined date_start_in_calendar and date_end_in_calendar property
// They are date start and end of action but modified to not be outside calendar view.
if ($event->percentage <= 0)
{
if ($event->percentage <= 0) {
$event->date_start_in_calendar = $datep;
if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2;
else $event->date_end_in_calendar = $datep;
if ($datep2 != '' && $datep2 >= $datep) {
$event->date_end_in_calendar = $datep2;
} else {
$event->date_end_in_calendar = $datep;
}
} else {
$event->date_start_in_calendar = $datep;
if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2;
else $event->date_end_in_calendar = $datep;
if ($datep2 != '' && $datep2 >= $datep) {
$event->date_end_in_calendar = $datep2;
} else {
$event->date_end_in_calendar = $datep;
}
}
// Define ponctual property
if ($event->date_start_in_calendar == $event->date_end_in_calendar)
{
if ($event->date_start_in_calendar == $event->date_end_in_calendar) {
$event->ponctuel = 1;
}
// Check values
if ($event->date_end_in_calendar < $firstdaytoshow ||
$event->date_start_in_calendar >= $lastdaytoshow)
{
$event->date_start_in_calendar >= $lastdaytoshow) {
// This record is out of visible range
unset($event);
} else {
//print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n";
$event->fetch_userassigned(); // This load $event->userassigned
if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow;
if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1);
if ($event->date_start_in_calendar < $firstdaytoshow) {
$event->date_start_in_calendar = $firstdaytoshow;
}
if ($event->date_end_in_calendar >= $lastdaytoshow) {
$event->date_end_in_calendar = ($lastdaytoshow - 1);
}
// Add an entry in actionarray for each day
$daycursor = $event->date_start_in_calendar;
@ -617,7 +715,9 @@ if ($resql)
$j++;
$daykey += 60 * 60 * 24;
if ($daykey > $event->date_end_in_calendar) $loop = false;
if ($daykey > $event->date_end_in_calendar) {
$loop = false;
}
} while ($loop);
//print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef);
@ -637,11 +737,12 @@ $cacheusers = array();
// Define theme_datacolor array
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php";
if (is_readable($color_file))
{
if (is_readable($color_file)) {
include_once $color_file;
}
if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
if (!is_array($theme_datacolor)) {
$theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
}
$newparam = $param; // newparam is for birthday links
@ -681,8 +782,7 @@ echo "</tr>\n";
echo '<tr class="liste_titre">';
echo '<td></td>';
$i = 0;
for ($h = $begin_d; $h < $end_d; $h++)
{
for ($h = $begin_d; $h < $end_d; $h++) {
echo '<td class="center">';
print '<small style="font-family: courier">'.sprintf("%02d", $h).'</small>';
print "</td>";
@ -698,8 +798,7 @@ $colorsbytype = array();
$labelbytype = array();
$sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position";
$resql = $db->query($sql);
while ($obj = $db->fetch_object($resql))
{
while ($obj = $db->fetch_object($resql)) {
$typeofevents[$obj->code] = $obj->code;
$colorsbytype[$obj->code] = $obj->color;
$labelbytype[$obj->code] = $obj->label;
@ -710,8 +809,7 @@ $todayarray = dol_getdate($now, 'fast');
$sav = $tmpday;
$showheader = true;
$var = false;
foreach ($typeofevents as $typeofevent)
{
foreach ($typeofevents as $typeofevent) {
$var = !$var;
echo "<tr>";
echo '<td class="cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">'.$typeofevent.'</td>';
@ -719,10 +817,8 @@ foreach ($typeofevents as $typeofevent)
// Lopp on each day of week
$i = 0;
for ($iter_day = 0; $iter_day < 8; $iter_day++)
{
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
{
for ($iter_day = 0; $iter_day < 8; $iter_day++) {
if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
$i++;
continue;
}
@ -735,10 +831,16 @@ foreach ($typeofevents as $typeofevent)
$tmpyear = $tmparray['year'];
$style = 'cal_current_month';
if ($iter_day == 6) $style .= ' cal_other_month';
if ($iter_day == 6) {
$style .= ' cal_other_month';
}
$today = 0;
if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1;
if ($today) $style = 'cal_today_peruser';
if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) {
$today = 1;
}
if ($today) {
$style = 'cal_today_peruser';
}
show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var);
@ -751,14 +853,11 @@ foreach ($typeofevents as $typeofevent)
echo "</table>\n";
echo "<br>";
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
$langs->load("commercial");
print '<br>'.$langs->trans("Legend").': <br>';
foreach ($colorsbytype as $code => $color)
{
if ($color)
{
foreach ($colorsbytype as $code => $color) {
if ($color) {
print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ? 'background: #'.$color.';' : '').'width:16px; float: left; margin-right: 4px;">&nbsp;</div>';
print $langs->trans("Action".$code) != "Action".$code ? $langs->trans("Action".$code) : $labelbytype[$code];
//print $code;
@ -860,41 +959,41 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
//if ($username->id && $day==1) var_dump($eventarray);
// We are in a particular day for $username, now we scan all events
foreach ($eventarray as $daykey => $notused)
{
foreach ($eventarray as $daykey => $notused) {
$annee = dol_print_date($daykey, '%Y');
$mois = dol_print_date($daykey, '%m');
$jour = dol_print_date($daykey, '%d');
if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ?
{
if ($day == $jour && $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ?
// Scan all event for this date
foreach ($eventarray[$daykey] as $index => $event)
{
foreach ($eventarray[$daykey] as $index => $event) {
//print $daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."<br>\n";
//var_dump($event);
$keysofuserassigned = array_keys($event->userassigned);
if (!in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show
if (!in_array($username->id, $keysofuserassigned)) {
continue; // We discard record if event is from another user than user we want to show
}
//if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show
$parameters = array();
$reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
$ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
// Define $color (Hex string like '0088FF') and $cssclass of event
$color = -1; $cssclass = ''; $colorindex = -1;
if (in_array($user->id, $keysofuserassigned))
{
if (in_array($user->id, $keysofuserassigned)) {
$nummytasks++; $cssclass = 'family_mytasks';
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color;
} elseif ($event->type_code == 'ICALEVENT')
{
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
$color = $event->type_color;
}
} elseif ($event->type_code == 'ICALEVENT') {
$numical++;
if (!empty($event->icalname))
{
if (!empty($event->icalname)) {
if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
$numicals[dol_string_nospecial($event->icalname)] = 0;
}
@ -903,25 +1002,26 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
$color = $event->icalcolor;
$cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable');
} elseif ($event->type_code == 'BIRTHDAY')
{
} elseif ($event->type_code == 'BIRTHDAY') {
$numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
} else {
$numother++; $cssclass = 'family_other';
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color;
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
$color = $event->type_color;
}
}
if ($color < 0) // Color was not set on user card. Set color according to color index.
{
if ($color < 0) { // Color was not set on user card. Set color according to color index.
// Define color index if not yet defined
$idusertouse = ($event->userownerid ? $event->userownerid : 0);
if (isset($colorindexused[$idusertouse]))
{
if (isset($colorindexused[$idusertouse])) {
$colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
} else {
$colorindex = $nextindextouse;
$colorindexused[$idusertouse] = $colorindex;
if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color
if (!empty($theme_datacolor[$nextindextouse + 1])) {
$nextindextouse++; // Prepare to use next color
}
}
// Define color
$color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
@ -929,60 +1029,57 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
//$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd;
// Define all rects with event (cases1 is first half hour, cases2 is second half hour)
for ($h = $begin_h; $h < $end_h; $h++)
{
for ($h = $begin_h; $h < $end_h; $h++) {
//if ($username->id == 1 && $day==1) print 'h='.$h;
$newcolor = ''; //init
if (empty($event->fulldayevent))
{
if (empty($event->fulldayevent)) {
$a = dol_mktime((int) $h, 0, 0, $month, $day, $year, 'tzuserrel', 0);
$b = dol_mktime((int) $h, 30, 0, $month, $day, $year, 'tzuserrel', 0);
$c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, 'tzuserrel', 0);
$dateendtouse = $event->date_end_in_calendar;
if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++;
if ($dateendtouse == $event->date_start_in_calendar) {
$dateendtouse++;
}
//print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>';
if ($event->date_start_in_calendar < $b && $dateendtouse > $a)
{
if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
$busy = $event->transparency;
$cases1[$h][$event->id]['busy'] = $busy;
$cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel');
if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar)
{
if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
$tmpa = dol_getdate($event->date_start_in_calendar, true);
$tmpb = dol_getdate($event->date_end_in_calendar, true);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel');
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
$cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
} else {
$cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel');
}
}
if ($event->label) {
$cases1[$h][$event->id]['string'] .= ' - '.$event->label;
}
if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label;
$cases1[$h][$event->id]['typecode'] = $event->type_code;
$cases1[$h][$event->id]['color'] = $color;
if ($event->fk_project > 0)
{
if (empty($cacheprojects[$event->fk_project]))
{
if ($event->fk_project > 0) {
if (empty($cacheprojects[$event->fk_project])) {
$tmpproj = new Project($db);
$tmpproj->fetch($event->fk_project);
$cacheprojects[$event->fk_project] = $tmpproj;
}
$cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
}
if ($event->socid > 0)
{
if (empty($cachethirdparties[$event->socid]))
{
if ($event->socid > 0) {
if (empty($cachethirdparties[$event->socid])) {
$tmpthirdparty = new Societe($db);
$tmpthirdparty->fetch($event->socid);
$cachethirdparties[$event->socid] = $tmpthirdparty;
}
$cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
}
if ($event->contact_id > 0)
{
if (empty($cachecontacts[$event->contact_id]))
{
if ($event->contact_id > 0) {
if (empty($cachecontacts[$event->contact_id])) {
$tmpcontact = new Contact($db);
$tmpcontact->fetch($event->contact_id);
$cachecontacts[$event->contact_id] = $tmpcontact;
@ -990,45 +1087,42 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
$cases1[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contact_id]->getFullName($langs);
}
}
if ($event->date_start_in_calendar < $c && $dateendtouse > $b)
{
if ($event->date_start_in_calendar < $c && $dateendtouse > $b) {
$busy = $event->transparency;
$cases2[$h][$event->id]['busy'] = $busy;
$cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel');
if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar)
{
if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
$tmpa = dol_getdate($event->date_start_in_calendar, true);
$tmpb = dol_getdate($event->date_end_in_calendar, true);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel');
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
$cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel');
} else {
$cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel');
}
}
if ($event->label) {
$cases2[$h][$event->id]['string'] .= ' - '.$event->label;
}
if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label;
$cases2[$h][$event->id]['typecode'] = $event->type_code;
$cases2[$h][$event->id]['color'] = $color;
if ($event->fk_project > 0)
{
if (empty($cacheprojects[$event->fk_project]))
{
if ($event->fk_project > 0) {
if (empty($cacheprojects[$event->fk_project])) {
$tmpproj = new Project($db);
$tmpproj->fetch($event->fk_project);
$cacheprojects[$event->fk_project] = $tmpproj;
}
$cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
}
if ($event->socid > 0)
{
if (empty($cachethirdparties[$event->socid]))
{
if ($event->socid > 0) {
if (empty($cachethirdparties[$event->socid])) {
$tmpthirdparty = new Societe($db);
$tmpthirdparty->fetch($event->socid);
$cachethirdparties[$event->socid] = $tmpthirdparty;
}
$cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
}
if ($event->contact_id > 0)
{
if (empty($cachecontacts[$event->contact_id]))
{
if ($event->contact_id > 0) {
if (empty($cachecontacts[$event->contact_id])) {
$tmpcontact = new Contact($db);
$tmpcontact->fetch($event->contact_id);
$cachecontacts[$event->contact_id] = $tmpcontact;
@ -1056,63 +1150,83 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
}
// Now output $casesX
for ($h = $begin_h; $h < $end_h; $h++)
{
for ($h = $begin_h; $h < $end_h; $h++) {
$color1 = ''; $color2 = '';
$style1 = ''; $style2 = '';
$string1 = '&nbsp;'; $string2 = '&nbsp;';
$title1 = ''; $title2 = '';
if (isset($cases1[$h]) && $cases1[$h] != '')
{
if (isset($cases1[$h]) && $cases1[$h] != '') {
//$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
if (count($cases1[$h]) > 1) $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
if (count($cases1[$h]) > 1) {
$title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
}
$string1 = '&nbsp;';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 = 'peruser_notbusy';
else $style1 = 'peruser_busy';
foreach ($cases1[$h] as $id => $ev)
{
if ($ev['busy']) $style1 = 'peruser_busy';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
$style1 = 'peruser_notbusy';
} else {
$style1 = 'peruser_busy';
}
foreach ($cases1[$h] as $id => $ev) {
if ($ev['busy']) {
$style1 = 'peruser_busy';
}
}
}
if (isset($cases2[$h]) && $cases2[$h] != '')
{
if (isset($cases2[$h]) && $cases2[$h] != '') {
//$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
if (count($cases2[$h]) > 1) $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
if (count($cases2[$h]) > 1) {
$title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
}
$string2 = '&nbsp;';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 = 'peruser_notbusy';
else $style2 = 'peruser_busy';
foreach ($cases2[$h] as $id => $ev)
{
if ($ev['busy']) $style2 = 'peruser_busy';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
$style2 = 'peruser_notbusy';
} else {
$style2 = 'peruser_busy';
}
foreach ($cases2[$h] as $id => $ev) {
if ($ev['busy']) {
$style2 = 'peruser_busy';
}
}
}
$ids1 = ''; $ids2 = '';
if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h]));
if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h]));
if (count($cases1[$h]) && array_keys($cases1[$h])) {
$ids1 = join(',', array_keys($cases1[$h]));
}
if (count($cases2[$h]) && array_keys($cases2[$h])) {
$ids2 = join(',', array_keys($cases2[$h]));
}
if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
else echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
if (count($cases1[$h]) == 1) // only 1 event
{
if ($h == $begin_h) {
echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
} else {
echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
}
if (count($cases1[$h]) == 1) { // only 1 event
$output = array_slice($cases1[$h], 0, 1);
$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string'];
if ($output[0]['color']) $color1 = $output[0]['color'];
} elseif (count($cases1[$h]) > 1)
{
if ($output[0]['string']) {
$title1 .= ($title1 ? ' - ' : '').$output[0]['string'];
}
if ($output[0]['color']) {
$color1 = $output[0]['color'];
}
} elseif (count($cases1[$h]) > 1) {
$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
$color1 = '222222';
}
if (count($cases2[$h]) == 1) // only 1 event
{
if (count($cases2[$h]) == 1) { // only 1 event
$output = array_slice($cases2[$h], 0, 1);
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string'];
if ($output[0]['color']) $color2 = $output[0]['color'];
} elseif (count($cases2[$h]) > 1)
{
if ($output[0]['string']) {
$title2 .= ($title2 ? ' - ' : '').$output[0]['string'];
}
if ($output[0]['color']) {
$color2 = $output[0]['color'];
}
} elseif (count($cases2[$h]) > 1) {
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
$color2 = '222222';
}

File diff suppressed because it is too large Load Diff

View File

@ -42,14 +42,22 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if ($page == -1 || $page == null) { $page = 0; }
if ($page == -1 || $page == null) {
$page = 0;
}
$offset = $limit * $page;
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "a.datep";
if (!$sortorder) {
$sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "a.datep";
}
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'agenda', $socid, '', 'myactions');
@ -57,12 +65,10 @@ $result = restrictedArea($user, 'agenda', $socid, '', 'myactions');
* Actions
*/
if ($action == 'builddoc')
{
if ($action == 'builddoc') {
$cat = new CommActionRapport($db, $month, $year);
$result = $cat->write_file(GETPOST('id', 'int'));
if ($result < 0)
{
if ($result < 0) {
setEventMessages($cat->error, $cat->errors, 'errors');
}
}
@ -89,12 +95,10 @@ $sql .= " GROUP BY year, month, df";
$sql .= " ORDER BY year DESC, month DESC, df DESC";
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
@ -105,15 +109,18 @@ $sql .= $db->plimit($limit + 1, $offset);
//print $sql;
dol_syslog("select", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$param = '';
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -137,12 +144,10 @@ if ($resql)
print '<td class="center">'.$langs->trans("Size").'</td>';
print "</tr>\n";
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
if ($obj)
{
if ($obj) {
print '<tr class="oddeven">';
// Date
@ -161,10 +166,11 @@ if ($resql)
$file = $conf->agenda->dir_temp."/".$name;
$modulepart = 'actionsreport';
$documenturl = DOL_URL_ROOT.'/document.php';
if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) {
$documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
}
if (file_exists($file))
{
if (file_exists($file)) {
print '<td class="tdoverflowmax300">';
//print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a>';
@ -174,7 +180,9 @@ if ($resql)
// Show file name with link to download
$out .= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
$mime = dol_mimetype($relativepath, '', 0);
if (preg_match('/text/', $mime)) $out .= ' target="_blank"';
if (preg_match('/text/', $mime)) {
$out .= ' target="_blank"';
}
$out .= ' target="_blank">';
$out .= img_mime($filearray["name"], $langs->trans("File").': '.$filearray["name"]);
$out .= $filearray["name"];

View File

@ -37,13 +37,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'propal'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
/*
@ -76,8 +80,7 @@ print dol_get_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>';
print "</div>";
@ -90,8 +93,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print "<br>";
print load_fiche_titre($langs->trans('NewAttribute'));
@ -103,8 +105,7 @@ if ($action == 'create')
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin)
if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page
$langs->loadlangs(array('admin', 'other', 'propal'));
@ -44,14 +45,18 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'propaldet'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
/*
@ -83,8 +88,7 @@ print dol_get_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
@ -97,8 +101,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
if ($action == 'create')
{
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
@ -110,8 +113,7 @@ if ($action == 'create')
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && !empty($attrname))
{
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -144,7 +144,6 @@ if ($id > 0 && empty($object->id)) {
}
/*
* Actions
*/

View File

@ -32,9 +32,15 @@ $langs->load("companies");
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "p.name";
if ($page < 0) { $page = 0; }
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "p.name";
}
if ($page < 0) {
$page = 0;
}
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
@ -47,7 +53,9 @@ $begin = GETPOST('begin', 'alpha');
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'societe', $socid, '');
@ -57,13 +65,11 @@ $result = restrictedArea($user, 'societe', $socid, '');
llxHeader('', $langs->trans("Contacts"));
if ($type == "c" || $type == "p")
{
if ($type == "c" || $type == "p") {
$label = $langs->trans("Customers");
$urlfiche = "card.php";
}
if ($type == "f")
{
if ($type == "f") {
$label = $langs->trans("Suppliers");
$urlfiche = "card.php";
}
@ -75,39 +81,46 @@ if ($type == "f")
$sql = "SELECT s.rowid, s.nom as name, st.libelle as stcomm";
$sql .= ", p.rowid as cidp, p.name, p.firstname, p.email, p.phone";
$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st,";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
}
$sql .= " ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql .= " WHERE s.fk_stcomm = st.id";
$sql .= " AND p.entity IN (".getEntity('socpeople').")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($type == "c") $sql .= " AND s.client IN (1, 3)";
if ($type == "p") $sql .= " AND s.client IN (2, 3)";
if ($type == "f") $sql .= " AND s.fournisseur = 1";
if ($socid) $sql .= " AND s.rowid = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($type == "c") {
$sql .= " AND s.client IN (1, 3)";
}
if ($type == "p") {
$sql .= " AND s.client IN (2, 3)";
}
if ($type == "f") {
$sql .= " AND s.fournisseur = 1";
}
if ($socid) {
$sql .= " AND s.rowid = ".$socid;
}
if (dol_strlen($stcomm))
{
if (dol_strlen($stcomm)) {
$sql .= " AND s.fk_stcomm=".$db->escape($stcomm);
}
if (!empty($search_lastname))
{
if (!empty($search_lastname)) {
$sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'";
}
if (!empty($search_firstname))
{
if (!empty($search_firstname)) {
$sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'";
}
if (!empty($search_company))
{
if (!empty($search_company)) {
$sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'";
}
if (!empty($contactname)) // acces a partir du module de recherche
{
if (!empty($contactname)) { // acces a partir du module de recherche
$sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') ";
$sortfield = "p.name";
$sortorder = "ASC";
@ -117,8 +130,7 @@ $sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$param = "&type=".$type;
@ -146,8 +158,7 @@ if ($resql)
print "</tr>\n";
$i = 0;
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';

View File

@ -687,8 +687,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$obj = $companystatic;
$s = '';
/*if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
{
/*if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
}
if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))

View File

@ -22,7 +22,9 @@
* \brief Page to define emailing targets
*/
if (!defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1');
if (!defined('NOSTYLECHECK')) {
define('NOSTYLECHECK', '1');
}
require '../../main.inc.php';
@ -41,22 +43,27 @@ if (!empty($conf->categorie->enabled)) {
}
// Security check
if (!$user->rights->mailing->lire || $user->socid > 0)
if (!$user->rights->mailing->lire || $user->socid > 0) {
accessforbidden();
}
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder)
if (!$sortorder) {
$sortorder = "ASC";
if (!$sortfield)
}
if (!$sortfield) {
$sortfield = "email";
}
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
@ -84,8 +91,7 @@ if (empty($template_id)) {
$result = $advTarget->fetch($template_id);
}
if ($result < 0)
{
if ($result < 0) {
setEventMessages($advTarget->error, $advTarget->errors, 'errors');
} else {
if (!empty($advTarget->id)) {
@ -397,16 +403,12 @@ if ($_POST["button_removefilter"]) {
$search_email = '';
}
/*
* View
*/
llxHeader('', $langs->trans("MailAdvTargetRecipients"));
$form = new Form($db);
$formadvtargetemaling = new FormAdvTargetEmailing($db);
$formcompany = new FormCompany($db);

View File

@ -131,7 +131,7 @@ if (empty($reshook)) {
$subject = $object->sujet;
$message = $object->body;
$from = $object->email_from;
$replyto = $object->email_replyto;
$replyto = $object->email_replyto;
$errorsto = $object->email_errorsto;
// Is the message in html
$msgishtml = -1; // Unknown by default

View File

@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("mails");
// Security check
if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden();
if (!$user->rights->mailing->lire || $user->socid > 0) {
accessforbidden();
}
// Load variable for pagination
@ -44,12 +46,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "mc.statut,email";
if (!$sortorder) $sortorder = "DESC,ASC";
if (!$sortfield) {
$sortfield = "mc.statut,email";
}
if (!$sortorder) {
$sortorder = "DESC,ASC";
}
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
@ -71,13 +79,11 @@ $result = $object->fetch($id);
* Actions
*/
if ($action == 'add')
{
if ($action == 'add') {
$module = GETPOST("module", 'alpha');
$result = -1;
foreach ($modulesdir as $dir)
{
foreach ($modulesdir as $dir) {
// Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>";
dol_syslog("Scan directory ".$dir." for modules");
@ -86,8 +92,7 @@ if ($action == 'add')
$file = $dir."/".$module.".modules.php";
$classname = "mailing_".$module;
if (file_exists($file))
{
if (file_exists($file)) {
require_once $file;
// Add targets into database
@ -96,25 +101,21 @@ if ($action == 'add')
$result = $obj->add_to_target($id);
}
}
if ($result > 0)
{
if ($result > 0) {
setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
if ($result == 0)
{
if ($result == 0) {
setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings');
}
if ($result < 0)
{
if ($result < 0) {
setEventMessages($langs->trans("Error").($obj->error ? ' '.$obj->error : ''), null, 'errors');
}
}
if (GETPOST('clearlist', 'int'))
{
if (GETPOST('clearlist', 'int')) {
// Loading Class
$obj = new MailingTargets($db);
$obj->clear_target($id);
@ -124,8 +125,7 @@ if (GETPOST('clearlist', 'int'))
*/
}
if (GETPOST('exportcsv', 'int'))
{
if (GETPOST('exportcsv', 'int')) {
$completefilename = 'targets_emailing'.$object->id.'_'.dol_print_date(dol_now(), 'dayhourlog').'.csv';
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename='.$completefilename);
@ -138,13 +138,11 @@ if (GETPOST('exportcsv', 'int'))
$sql .= $db->order($sortfield, $sortorder);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$sep = ',';
while ($obj = $db->fetch_object($resql))
{
while ($obj = $db->fetch_object($resql)) {
print $obj->rowid.$sep;
print '"'.$obj->lastname.'"'.$sep;
print '"'.$obj->firstname.'"'.$sep;
@ -166,15 +164,12 @@ if (GETPOST('exportcsv', 'int'))
exit;
}
if ($action == 'delete')
{
if ($action == 'delete') {
// Ici, rowid indique le destinataire et id le mailing
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid;
$resql = $db->query($sql);
if ($resql)
{
if (!empty($id))
{
if ($resql) {
if (!empty($id)) {
$obj = new MailingTargets($db);
$obj->update_nb($id);
@ -189,8 +184,7 @@ if ($action == 'delete')
}
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_lastname = '';
$search_firstname = '';
$search_email = '';
@ -209,8 +203,7 @@ llxHeader('', $langs->trans("Mailing"), 'EN:Module_EMailing|FR:Module_Mailing|ES
$form = new Form($db);
$formmailing = new FormMailing($db);
if ($object->fetch($id) >= 0)
{
if ($object->fetch($id) >= 0) {
$head = emailing_prepare_head($object);
print dol_get_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, 'email');
@ -219,14 +212,15 @@ if ($object->fetch($id) >= 0)
$morehtmlright = '';
$nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3)
{
if ($object->statut == 2 || $object->statut == 3) {
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
$nbok = ($nbtry - $nbko);
$morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
if ($nbko) {
$morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
}
$morehtmlright .= ') &nbsp; ';
}
@ -279,21 +273,19 @@ if ($object->fetch($id) >= 0)
print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td colspan="3">';
$nbemail = ($object->nbemail ? $object->nbemail : 0);
if (is_numeric($nbemail))
{
if (is_numeric($nbemail)) {
$text = '';
if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
{
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
{
if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
$text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
} else {
$text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
}
}
if (empty($nbemail)) $nbemail .= ' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
if ($text)
{
if (empty($nbemail)) {
$nbemail .= ' '.img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>';
}
if ($text) {
print $form->textwithpicto($nbemail, $text, 1, 'warning');
} else {
print $nbemail;
@ -313,8 +305,7 @@ if ($object->fetch($id) >= 0)
$allowaddtarget = ($object->statut == 0);
// Show email selectors
if ($allowaddtarget && $user->rights->mailing->creer)
{
if ($allowaddtarget && $user->rights->mailing->creer) {
print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic');
//print '<table class="noborder centpercent">';
@ -335,23 +326,20 @@ if ($object->fetch($id) >= 0)
clearstatcache();
foreach ($modulesdir as $dir)
{
foreach ($modulesdir as $dir) {
$modulenames = array();
// Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>";
dol_syslog("Scan directory ".$dir." for modules");
$handle = @opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
if (preg_match("/(.*)\.modules\.php$/i", $file, $reg))
{
if ($reg[1] == 'example') continue;
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) {
if ($reg[1] == 'example') {
continue;
}
$modulenames[] = $reg[1];
}
}
@ -365,8 +353,7 @@ if ($object->fetch($id) >= 0)
$var = true;
// Loop on each submodule
foreach ($modulenames as $modulename)
{
foreach ($modulenames as $modulename) {
// Loading Class
$file = $dir.$modulename.".modules.php";
$classname = "mailing_".$modulename;
@ -376,10 +363,8 @@ if ($object->fetch($id) >= 0)
// Check dependencies
$qualified = (isset($obj->enabled) ? $obj->enabled : 1);
foreach ($obj->require_module as $key)
{
if (!$conf->$key->enabled || (!$user->admin && $obj->require_admin))
{
foreach ($obj->require_module as $key) {
if (!$conf->$key->enabled || (!$user->admin && $obj->require_admin)) {
$qualified = 0;
//print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
break;
@ -387,12 +372,10 @@ if ($object->fetch($id) >= 0)
}
// Si le module mailing est qualifie
if ($qualified)
{
if ($qualified) {
$var = !$var;
if ($allowaddtarget)
{
if ($allowaddtarget) {
print '<form '.$bctag[$var].' name="'.$modulename.'" action="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.newToken().'">';
} else {
@ -400,7 +383,9 @@ if ($object->fetch($id) >= 0)
}
print '<div class="tagtd">';
if (empty($obj->picto)) $obj->picto = 'generic';
if (empty($obj->picto)) {
$obj->picto = 'generic';
}
print img_object($langs->trans("EmailingTargetSelector").': '.get_class($obj), $obj->picto, 'class="valignmiddle pictomodule"');
print ' ';
print $obj->getDesc();
@ -408,14 +393,12 @@ if ($object->fetch($id) >= 0)
try {
$nbofrecipient = $obj->getNbOfRecipients('');
} catch (Exception $e)
{
} catch (Exception $e) {
dol_syslog($e->getMessage(), LOG_ERR);
}
print '<div class="tagtd center">';
if ($nbofrecipient >= 0)
{
if ($nbofrecipient >= 0) {
print $nbofrecipient;
} else {
print $langs->trans("Error").' '.img_error($obj->error);
@ -423,22 +406,22 @@ if ($object->fetch($id) >= 0)
print '</div>';
print '<div class="tagtd left">';
if ($allowaddtarget)
{
if ($allowaddtarget) {
try {
$filter = $obj->formFilter();
} catch (Exception $e)
{
} catch (Exception $e) {
dol_syslog($e->getMessage(), LOG_ERR);
}
if ($filter) print $filter;
else print $langs->trans("None");
if ($filter) {
print $filter;
} else {
print $langs->trans("None");
}
}
print '</div>';
print '<div class="tagtd right">';
if ($allowaddtarget)
{
if ($allowaddtarget) {
print '<input type="submit" class="button" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
} else {
print '<input type="submit" class="button disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
@ -447,8 +430,11 @@ if ($object->fetch($id) >= 0)
}
print '</div>';
if ($allowaddtarget) print '</form>';
else print '</div>';
if ($allowaddtarget) {
print '</form>';
} else {
print '</div>';
}
}
}
} // End foreach dir
@ -464,7 +450,7 @@ if ($object->fetch($id) >= 0)
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.fk_mailing=".$object->id;
$asearchcriteriahasbeenset = 0;
if ($search_lastname) {
if ($search_lastname) {
$sql .= natural_search("mc.lastname", $search_lastname);
$asearchcriteriahasbeenset++;
}
@ -472,11 +458,11 @@ if ($object->fetch($id) >= 0)
$sql .= natural_search("mc.firstname", $search_firstname);
$asearchcriteriahasbeenset++;
}
if ($search_email) {
if ($search_email) {
$sql .= natural_search("mc.email", $search_email);
$asearchcriteriahasbeenset++;
}
if ($search_other) {
if ($search_other) {
$sql .= natural_search("mc.other", $search_other);
$asearchcriteriahasbeenset++;
}
@ -488,43 +474,51 @@ if ($object->fetch($id) >= 0)
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
// Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
if (empty($asearchcriteriahasbeenset)) {
if ($nbtotalofrecords != $object->nbemail) {
dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
//print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
$resultrefresh = $object->refreshNbOfTargets();
if ($resultrefresh < 0) {
dol_print_error($db, $object->error, $object->errors);
}
}
}
// Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
if (empty($asearchcriteriahasbeenset)) {
if ($nbtotalofrecords != $object->nbemail) {
dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
//print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
$resultrefresh = $object->refreshNbOfTargets();
if ($resultrefresh < 0) {
dol_print_error($db, $object->error, $object->errors);
}
}
}
}
//$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$param = "&id=".$object->id;
//if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname);
if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname);
if ($search_email) $param .= "&search_email=".urlencode($search_email);
if ($search_other) $param .= "&search_other=".urlencode($search_other);
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($search_lastname) {
$param .= "&search_lastname=".urlencode($search_lastname);
}
if ($search_firstname) {
$param .= "&search_firstname=".urlencode($search_firstname);
}
if ($search_email) {
$param .= "&search_email=".urlencode($search_email);
}
if ($search_other) {
$param .= "&search_other=".urlencode($search_other);
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -599,7 +593,9 @@ if ($object->fetch($id) >= 0)
print '</td>';
print '</tr>';
if ($page) $param .= "&page=".urlencode($page);
if ($page) {
$param .= "&page=".urlencode($page);
}
print '<tr class="liste_titre">';
print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder);
@ -617,8 +613,7 @@ if ($object->fetch($id) >= 0)
$i = 0;
if ($num)
{
if ($num) {
include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@ -628,8 +623,7 @@ if ($object->fetch($id) >= 0)
$objectstaticcompany = new Societe($db);
$objectstaticcontact = new Contact($db);
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
@ -638,24 +632,19 @@ if ($object->fetch($id) >= 0)
print '<td>'.$obj->firstname.'</td>';
print '<td>'.$obj->other.'</td>';
print '<td class="center">';
if (empty($obj->source_id) || empty($obj->source_type))
{
if (empty($obj->source_id) || empty($obj->source_type)) {
print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility
} else {
if ($obj->source_type == 'member')
{
if ($obj->source_type == 'member') {
$objectstaticmember->fetch($obj->source_id);
print $objectstaticmember->getNomUrl(1);
} elseif ($obj->source_type == 'user')
{
} elseif ($obj->source_type == 'user') {
$objectstaticuser->fetch($obj->source_id);
print $objectstaticuser->getNomUrl(1);
} elseif ($obj->source_type == 'thirdparty')
{
} elseif ($obj->source_type == 'thirdparty') {
$objectstaticcompany->fetch($obj->source_id);
print $objectstaticcompany->getNomUrl(1);
} elseif ($obj->source_type == 'contact')
{
} elseif ($obj->source_type == 'contact') {
$objectstaticcontact->fetch($obj->source_id);
print $objectstaticcontact->getNomUrl(1);
} else {
@ -670,8 +659,7 @@ if ($object->fetch($id) >= 0)
print '</td>';
// Status of recipient sending email (Warning != status of emailing)
if ($obj->statut == 0)
{
if ($obj->statut == 0) {
// Date sent
print '<td align="center">&nbsp;</td>';
@ -689,8 +677,7 @@ if ($object->fetch($id) >= 0)
// Search Icon
print '<td class="right">';
if ($obj->statut == 0) // Not sent yet
{
if ($obj->statut == 0) { // Not sent yet
if ($user->rights->mailing->creer && $allowaddtarget) {
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.$obj->rowid.$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
}
@ -705,8 +692,7 @@ if ($object->fetch($id) >= 0)
$i++;
}
} else {
if ($object->statut < 2)
{
if ($object->statut < 2) {
print '<tr><td colspan="9" class="opacitymedium">';
print $langs->trans("NoTargetYet");
print '</td></tr>';

View File

@ -131,7 +131,7 @@ class AdvanceTargetingMailing extends CommonObject
/**
* Create object into database
*
* @param User $user User that creates
* @param User $user User that creates
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK
*/

View File

@ -74,8 +74,9 @@ class FormAdvTargetEmailing extends Form
$obj = $this->db->fetch_object($resql);
$level = $langs->trans($obj->code);
if ($level == $obj->code)
if ($level == $obj->code) {
$level = $langs->trans($obj->label);
}
$options_array[$obj->code] = $level;
$i++;
@ -89,9 +90,9 @@ class FormAdvTargetEmailing extends Form
/**
* Return combo list of activated countries, into language of user
*
* @param string $htmlname of html select object
* @param array $selected_array or Code or Label of preselected country
* @return string HTML string with select
* @param string $htmlname of html select object
* @param array $selected_array or Code or Label of preselected country
* @return string HTML string with select
*/
public function multiselectCountry($htmlname = 'country_id', $selected_array = array())
{
@ -131,8 +132,9 @@ class FormAdvTargetEmailing extends Form
foreach ($countryArray as $row) {
$label = dol_trunc($row['label'], $maxlength, 'middle');
if ($row['code_iso'])
if ($row['code_iso']) {
$label .= ' ('.$row['code_iso'].')';
}
$options_array[$row['rowid']] = $label;
}
@ -165,8 +167,9 @@ class FormAdvTargetEmailing extends Form
$sql_usr .= " WHERE u2.entity IN (0,".$conf->entity.")";
$sql_usr .= " AND u2.rowid = sc.fk_user ";
if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX))
if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) {
$sql_usr .= " AND u2.statut<>0 ";
}
$sql_usr .= " ORDER BY name ASC";
// print $sql_usr;exit;
@ -201,8 +204,7 @@ class FormAdvTargetEmailing extends Form
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
foreach ($langs_available as $key => $value)
{
foreach ($langs_available as $key => $value) {
$label = $value;
$options_array[$key] = $label;
}
@ -223,8 +225,7 @@ class FormAdvTargetEmailing extends Form
{
$options_array = array();
if (is_array($sqlqueryparam))
{
if (is_array($sqlqueryparam)) {
$param_list = array_keys($sqlqueryparam);
$InfoFieldList = explode(":", $param_list [0]);
@ -297,14 +298,11 @@ class FormAdvTargetEmailing extends Form
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : ''));
@ -364,8 +362,9 @@ class FormAdvTargetEmailing extends Form
$resql = $this->db->query($sql);
if ($resql) {
$out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($showempty)
if ($showempty) {
$out .= '<option value=""></option>';
}
$num = $this->db->num_rows($resql);
$i = 0;
if ($num) {

View File

@ -252,7 +252,7 @@ class Mailing extends CommonObject
/**
* Update emailing record
*
* @param User $user Object of user making change
* @param User $user Object of user making change
* @return int < 0 if KO, > 0 if OK
*/
public function update($user)

View File

@ -80,16 +80,14 @@ print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("TargetsStatistic
$dir = DOL_DOCUMENT_ROOT."/core/modules/mailings";
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg))
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) {
$modulename = $reg[1];
if ($modulename == 'example') continue;
if ($modulename == 'example') {
continue;
}
// Loading Class
$file = $dir."/".$modulename.".modules.php";
@ -98,10 +96,8 @@ if (is_resource($handle))
$mailmodule = new $classname($db);
$qualified = 1;
foreach ($mailmodule->require_module as $key)
{
if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin))
{
foreach ($mailmodule->require_module as $key) {
if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) {
$qualified = 0;
//print "Les pr<70>requis d'activation du module mailing ne sont pas respect<63>s. Il ne sera pas actif";
break;
@ -109,10 +105,8 @@ if (is_resource($handle))
}
// Si le module mailing est qualifi<66>
if ($qualified)
{
foreach ($mailmodule->getSqlArrayForStats() as $sql)
{
if ($qualified) {
foreach ($mailmodule->getSqlArrayForStats() as $sql) {
print '<tr class="oddeven">';
$result = $db->query($sql);
@ -121,8 +115,7 @@ if (is_resource($handle))
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($result);
print '<td>'.img_object('', $mailmodule->picto).' '.$obj->label.'</td><td class="right">'.$obj->nb.'<td>';
$i++;
@ -169,12 +162,10 @@ if ($result) {
print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td></tr>';
$num = $db->num_rows($result);
if ($num > 0)
{
if ($num > 0) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($result);
$mailstatic = new Mailing($db);
$mailstatic->id = $obj->rowid;

View File

@ -77,7 +77,6 @@ if ($object->fetch($id) >= 0) {
dol_print_object_info($object, 0);
//print '</td></tr></table>';
print dol_get_fiche_end();
}

View File

@ -36,12 +36,18 @@ $sortorder = GETPOST("sortorder", 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$optioncss = GETPOST('optioncss', 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "m.date_creat";
if (!$sortorder) {
$sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "m.date_creat";
}
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha");
@ -70,21 +76,25 @@ $fieldstosearchall = array(
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
/*foreach($object->fields as $key => $val)
{
$search[$key]='';
@ -95,8 +105,7 @@ if (empty($reshook))
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
@ -125,29 +134,43 @@ if ($filteremail) {
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
$sql .= " AND mc.email = '".$db->escape($filteremail)."'";
if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "m.rowid";
if ($search_ref) {
$sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
}
if ($search_all) {
$sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
}
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "m.rowid";
}
} else {
$sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
$sql .= " WHERE m.entity = ".$conf->entity;
if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
if ($search_all) $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "m.rowid";
if ($search_ref) {
$sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
}
if ($search_all) {
$sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
}
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "m.rowid";
}
}
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
@ -158,28 +181,36 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("comm/mailing/list.php", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$title = $langs->trans("ListOfEMailings");
if ($filteremail) $title .= ' ('.$langs->trans("SentTo", $filteremail).')';
if ($filteremail) {
$title .= ' ('.$langs->trans("SentTo", $filteremail).')';
}
$newcardbutton = '';
if ($user->rights->mailing->creer)
{
if ($user->rights->mailing->creer) {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create');
}
$i = 0;
$param = "&search_all=".urlencode($search_all);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($filteremail) $param .= '&filteremail='.urlencode($filteremail);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($filteremail) {
$param .= '&filteremail='.urlencode($filteremail);
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@ -201,7 +232,9 @@ if ($resql)
print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).'">';
print '</td>';
print '<td class="liste_titre">&nbsp;</td>';
if (!$filteremail) print '<td class="liste_titre">&nbsp;</td>';
if (!$filteremail) {
print '<td class="liste_titre">&nbsp;</td>';
}
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre maxwidthsearch">';
@ -214,9 +247,14 @@ if ($resql)
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", $param, "", "", $sortfield, $sortorder);
print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", 'align="center"', $sortfield, $sortorder);
if (!$filteremail) print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder);
if (!$filteremail) print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
else print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
if (!$filteremail) {
print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder);
}
if (!$filteremail) {
print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
} else {
print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
}
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), $param, "", 'class="right"', $sortfield, $sortorder);
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n";
@ -224,8 +262,7 @@ if ($resql)
$email = new Mailing($db);
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
$email->id = $obj->rowid;
@ -246,8 +283,7 @@ if ($resql)
print '</td>';
// Nb of email
if (!$filteremail)
{
if (!$filteremail) {
print '<td class="center">';
$nbemail = $obj->nbemail;
/*if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
@ -269,8 +305,7 @@ if ($resql)
// Status
print '<td class="nowrap right">';
if ($filteremail)
{
if ($filteremail) {
print $email::libStatutDest($obj->sendstatut, 2);
} else {
print $email->LibStatut($obj->statut, 5);
@ -284,7 +319,9 @@ if ($resql)
}
if (empty($num)) {
$colspan = 6;
if (!$filteremail) $colspan++;
if (!$filteremail) {
$colspan++;
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}

View File

@ -33,8 +33,7 @@ $langs->loadLangs(array('orders', 'companies'));
$id = GETPOST('id', 'int');
$_socid = GETPOST("id", 'int');
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
$_socid = $user->socid;
}
@ -43,8 +42,7 @@ if ($user->socid > 0)
* Actions
*/
if ($_POST["action"] == 'setpricelevel')
{
if ($_POST["action"] == 'setpricelevel') {
$soc = new Societe($db);
$soc->fetch($id);
$soc->set_price_level($_POST["price_level"], $user);
@ -62,8 +60,7 @@ llxHeader();
$userstatic = new User($db);
if ($_socid > 0)
{
if ($_socid > 0) {
// We load data of thirdparty
$objsoc = new Societe($db);
$objsoc->id = $_socid;
@ -73,8 +70,12 @@ if ($_socid > 0)
$head = societe_prepare_head($objsoc);
$tabchoice = '';
if ($objsoc->client == 1) $tabchoice = 'customer';
if ($objsoc->client == 2) $tabchoice = 'prospect';
if ($objsoc->client == 1) {
$tabchoice = 'customer';
}
if ($objsoc->client == 2) {
$tabchoice = 'prospect';
}
print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -90,14 +91,16 @@ if ($_socid > 0)
print '<tr><td>';
print $langs->trans("NewValue").'</td><td>';
print '<select name="price_level" class="flat">';
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
print '<option value="'.$i.'"';
if ($i == $objsoc->price_level)
print 'selected';
if ($i == $objsoc->price_level) {
print 'selected';
}
print '>'.$i;
$keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
if (!empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
if (!empty($conf->global->$keyforlabel)) {
print ' - '.$langs->trans($conf->global->$keyforlabel);
}
print '</option>';
}
print '</select>';
@ -125,8 +128,7 @@ if ($_socid > 0)
$sql .= " ORDER BY rc.datec DESC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<table class="noborder centpercent">';
$tag = !$tag;
print '<tr class="liste_titre">';
@ -137,8 +139,7 @@ if ($_socid > 0)
$i = 0;
$num = $db->num_rows($resql);
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';

File diff suppressed because it is too large Load Diff

View File

@ -162,28 +162,37 @@ class Proposals extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id;
}
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $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)
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $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."propal as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $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
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $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('propal').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= " AND t.fk_soc = sc.fk_soc";
}
if ($socids) {
$sql .= " AND t.fk_soc IN (".$socids.")";
}
if ($search_sale > 0) {
$sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
}
// Insert sale filter
if ($search_sale > 0)
{
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (!DolibarrApi::_checkFilters($sqlfilters))
{
if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -192,8 +201,7 @@ class Proposals extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@ -204,13 +212,11 @@ class Proposals extends DolibarrApi
dol_syslog("API Rest request");
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
while ($i < $min)
{
while ($i < $min) {
$obj = $this->db->fetch_object($result);
$proposal_static = new Propal($this->db);
if ($proposal_static->fetch($obj->rowid)) {
@ -247,12 +253,12 @@ class Proposals extends DolibarrApi
$this->propal->$field = $value;
}
/*if (isset($request_data["lines"])) {
$lines = array();
foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line);
}
$this->propal->lines = $lines;
}*/
$lines = array();
foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line);
}
$this->propal->lines = $lines;
}*/
if ($this->propal->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors));
}
@ -304,7 +310,7 @@ class Proposals extends DolibarrApi
public function postLine($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
throw new RestException(401);
}
$result = $this->propal->fetch($id);
@ -319,32 +325,32 @@ class Proposals extends DolibarrApi
$request_data = (object) $request_data;
$updateRes = $this->propal->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
'HT',
0,
$request_data->info_bits,
$request_data->product_type,
$request_data->rang,
$request_data->special_code,
$request_data->fk_parent_line,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->label,
$request_data->date_start,
$request_data->date_end,
$request_data->array_options,
$request_data->fk_unit,
$request_data->origin,
$request_data->origin_id,
$request_data->multicurrency_subprice,
$request_data->fk_remise_except
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
'HT',
0,
$request_data->info_bits,
$request_data->product_type,
$request_data->rang,
$request_data->special_code,
$request_data->fk_parent_line,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->label,
$request_data->date_start,
$request_data->date_end,
$request_data->array_options,
$request_data->fk_unit,
$request_data->origin,
$request_data->origin_id,
$request_data->multicurrency_subprice,
$request_data->fk_remise_except
);
if ($updateRes > 0) {
@ -378,15 +384,15 @@ class Proposals extends DolibarrApi
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
}
$request_data = (object) $request_data;
$request_data = (object) $request_data;
$propalline = new PropaleLigne($this->db);
$result = $propalline->fetch($lineid);
if ($result <= 0) {
throw new RestException(404, 'Proposal line not found');
}
$propalline = new PropaleLigne($this->db);
$result = $propalline->fetch($lineid);
if ($result <= 0) {
throw new RestException(404, 'Proposal line not found');
}
$updateRes = $this->propal->updateline(
$lineid,
@ -572,25 +578,23 @@ class Proposals extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
if ($field == 'id') {
continue;
}
$this->propal->$field = $value;
}
// update end of validity date
if (empty($this->propal->fin_validite) && !empty($this->propal->duree_validite) && !empty($this->propal->date_creation))
{
if (empty($this->propal->fin_validite) && !empty($this->propal->duree_validite) && !empty($this->propal->date_creation)) {
$this->propal->fin_validite = $this->propal->date_creation + ($this->propal->duree_validite * 24 * 3600);
}
if (!empty($this->propal->fin_validite))
{
if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0)
{
if (!empty($this->propal->fin_validite)) {
if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0) {
throw new RestException(500, $this->propal->error);
}
}
if ($this->propal->update(DolibarrApiAccess::$user) > 0)
{
if ($this->propal->update(DolibarrApiAccess::$user) > 0) {
return $this->get($id);
} else {
throw new RestException(500, $this->propal->error);
@ -834,8 +838,9 @@ class Proposals extends DolibarrApi
{
$propal = array();
foreach (Proposals::$FIELDS as $field) {
if (!isset($data[$field]))
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$propal[$field] = $data[$field];
}
return $propal;

File diff suppressed because it is too large Load Diff

View File

@ -69,8 +69,7 @@ class PropaleStats extends Stats
$this->userid = $userid;
$this->join = '';
if ($mode == 'customer')
{
if ($mode == 'customer') {
$object = new Propal($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as p";
@ -81,8 +80,7 @@ class PropaleStats extends Stats
//$this->where .= " p.fk_statut > 0";
}
if ($mode == 'supplier')
{
if ($mode == 'supplier') {
$object = new SupplierProposal($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as p";
@ -95,21 +93,22 @@ class PropaleStats extends Stats
}
//$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity;
$this->where .= ($this->where ? ' AND ' : '')."p.entity IN (".getEntity('propal').")";
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($this->socid)
{
if (!$user->rights->societe->client->voir && !$this->socid) {
$this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($this->socid) {
$this->where .= " AND p.fk_soc = ".$this->socid;
}
if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid;
if ($this->userid > 0) {
$this->where .= ' AND fk_user_author = '.$this->userid;
}
if ($typentid)
{
if ($typentid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
$this->where .= ' AND s.fk_typent = '.$typentid;
}
if ($categid)
{
if ($categid) {
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = p.fk_soc';
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie';
$this->where .= ' AND c.rowid = '.$categid;
@ -130,7 +129,9 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join;
$sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
@ -153,7 +154,9 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm";
@ -175,7 +178,9 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join;
$sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
@ -198,7 +203,9 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join;
$sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
@ -219,7 +226,9 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg";
$sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year";
@ -243,7 +252,9 @@ class PropaleStats extends Stats
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
$sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
$sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid";

View File

@ -41,28 +41,26 @@ $lineid = GETPOST('lineid', 'int');
$action = GETPOST('action', 'aZ09');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'propal', $id);
$object = new Propal($db);
// Load object
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$ret = $object->fetch($id, $ref);
if ($ret == 0)
{
if ($ret == 0) {
$langs->load("errors");
setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
$error++;
} elseif ($ret < 0)
{
} elseif ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
if (!$error)
{
if (!$error) {
$object->fetch_thirdparty();
} else {
header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php');
@ -74,42 +72,34 @@ if (!$error)
* Add a new contact
*/
if ($action == 'addcontact' && $user->rights->propale->creer)
{
if ($object->id > 0)
{
if ($action == 'addcontact' && $user->rights->propale->creer) {
if ($object->id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
}
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
} // Toggle the status of a contact
elseif ($action == 'swapstatut' && $user->rights->propale->creer)
{
if ($object->id > 0)
{
} elseif ($action == 'swapstatut' && $user->rights->propale->creer) {
// Toggle the status of a contact
if ($object->id > 0) {
$result = $object->swapContactStatus(GETPOST('ligne'));
}
} // Deletes a contact
elseif ($action == 'deletecontact' && $user->rights->propale->creer)
{
} elseif ($action == 'deletecontact' && $user->rights->propale->creer) {
// Deletes a contact
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -134,8 +124,7 @@ $form = new Form($db);
$formcompany = new FormCompany($db);
$formother = new FormOther($db);
if ($object->id > 0)
{
if ($object->id > 0) {
$head = propal_prepare_head($object);
print dol_get_fiche_head($head, 'contact', $langs->trans("Proposal"), -1, 'propal');
@ -152,12 +141,10 @@ if ($object->id > 0)
// Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer');
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->propal->creer)
{
if ($user->rights->propal->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : ';
@ -194,10 +181,11 @@ if ($object->id > 0)
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir)
{
foreach ($dirtpls as $reldir) {
$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break;
if ($res) {
break;
}
}
}

View File

@ -39,15 +39,14 @@ if (!empty($conf->projet->enabled)) {
// Load translation files required by the page
$langs->loadLangs(array('compta', 'other', 'companies'));
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
// Security check
$socid = '';
if (!empty($user->socid))
{
if (!empty($user->socid)) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'propal', $id);
@ -57,16 +56,26 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; }
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; }
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
$sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
}
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) {
$sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
}
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new Propal($db);
$object->fetch($id, $ref);
@ -76,8 +85,7 @@ $object->fetch($id, $ref);
* Actions
*/
if ($object->id > 0)
{
if ($object->id > 0) {
$object->fetch_thirdparty();
$upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
@ -92,8 +100,7 @@ llxHeader('', $langs->trans('Proposal'), 'EN:Commercial_Proposals|FR:Proposition
$form = new Form($db);
if ($object->id > 0)
{
if ($object->id > 0) {
$upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$head = propal_prepare_head($object);
@ -102,8 +109,7 @@ if ($object->id > 0)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}
@ -120,12 +126,10 @@ if ($object->id > 0)
// Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer');
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->propal->creer)
{
if ($user->rights->propal->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : ';

View File

@ -20,7 +20,7 @@
*/
/**
* \file htdocs/comm/propal/index.php
* \file htdocs/comm/propal/index.php
* \ingroup propal
* \brief Home page of proposal area
*/

View File

@ -19,9 +19,9 @@
*/
/**
* \file htdocs/comm/propal/info.php
* \ingroup propal
* \brief Page d'affichage des infos d'une proposition commerciale
* \file htdocs/comm/propal/info.php
* \ingroup propal
* \brief Page d'affichage des infos d'une proposition commerciale
*/
require '../../main.inc.php';
@ -40,12 +40,13 @@ $ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
// Security check
if (!empty($user->socid)) $socid = $user->socid;
if (!empty($user->socid)) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'propal', $id);
$object = new Propal($db);
if (!$object->fetch($id, $ref) > 0)
{
if (!$object->fetch($id, $ref) > 0) {
dol_print_error($db);
exit;
}
@ -80,12 +81,10 @@ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_cl
// Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->propal->creer)
{
if ($user->rights->propal->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : ';

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,9 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'propale', $id, 'propal');
$object = new Propal($db);
@ -67,16 +69,15 @@ llxHeader('', $langs->trans('Proposal'), $help_url);
$form = new Form($db);
if ($id > 0 || !empty($ref))
{
if ($mesg) print $mesg;
if ($id > 0 || !empty($ref)) {
if ($mesg) {
print $mesg;
}
$now = dol_now();
if ($object->fetch($id, $ref) > 0)
{
if ($object->fetch_thirdparty() > 0)
{
if ($object->fetch($id, $ref) > 0) {
if ($object->fetch_thirdparty() > 0) {
$head = propal_prepare_head($object);
print dol_get_fiche_head($head, 'note', $langs->trans('Proposal'), -1, 'propal');
@ -97,12 +98,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->propal->creer)
{
if ($user->rights->propal->creer) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : ';

View File

@ -38,8 +38,12 @@ $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer';
if ($mode == 'customer' && !$user->rights->propale->lire) accessforbidden();
if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) accessforbidden();
if ($mode == 'customer' && !$user->rights->propale->lire) {
accessforbidden();
}
if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) {
accessforbidden();
}
$object_status = GETPOST('object_status', 'intcomma');
$typent_id = GETPOST('typent_id', 'int');
@ -48,8 +52,7 @@ $categ_id = GETPOST('categ_id', 'categ_id');
$userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int');
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@ -75,16 +78,14 @@ $formother = new FormOther($db);
$langs->loadLangs(array('propal', 'other', 'companies'));
if ($mode == 'customer')
{
if ($mode == 'customer') {
$picto = 'propal';
$title = $langs->trans("ProposalsStatistics");
$dir = $conf->propale->dir_temp;
$cat_type = Categorie::TYPE_CUSTOMER;
$cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer"));
}
if ($mode == 'supplier')
{
if ($mode == 'supplier') {
$picto = 'supplier_proposal';
$title = $langs->trans("ProposalsStatisticsSuppliers");
$dir = $conf->supplier_proposal->dir_temp;
@ -101,15 +102,16 @@ dol_mkdir($dir);
$stats = new PropaleStats($db, $socid, ($userid > 0 ? $userid : 0), $mode, ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0));
if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND p.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
if ($object_status != '' && $object_status >= 0) {
$stats->where .= ' AND p.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
}
// Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid)
{
if (!$user->rights->societe->client->voir || $user->socid) {
$filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png';
} else {
@ -119,12 +121,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px1->SetData($data);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
while ($i <= $endyear) {
$legend[] = $i;
$i++;
}
@ -146,8 +146,7 @@ if (!$mesg)
$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, 0);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid)
{
if (!$user->rights->societe->client->voir || $user->socid) {
$filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png';
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png';
} else {
@ -157,12 +156,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px2->SetData($data);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
while ($i <= $endyear) {
$legend[] = $i;
$i++;
}
@ -183,25 +180,30 @@ if (!$mesg)
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
$fileurl_avg = '';
if (!$user->rights->societe->client->voir || $user->socid)
{
if (!$user->rights->societe->client->voir || $user->socid) {
$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png';
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') {
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png';
}
if ($mode == 'supplier') {
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png';
}
} else {
$filename_avg = $dir.'/ordersaverage-'.$year.'.png';
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png';
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png';
if ($mode == 'customer') {
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png';
}
if ($mode == 'supplier') {
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png';
}
}
$px3 = new DolGraph();
$mesg = $px3->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px3->SetData($data);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
while ($i <= $endyear) {
$legend[] = $i;
$i++;
}
@ -228,7 +230,9 @@ foreach ($data as $val) {
$arrayyears[$val['year']] = $val['year'];
}
}
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
if (!count($arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
$h = 0;
@ -264,7 +268,9 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
$sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if ($user->admin) {
print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>';
// Category
print '<tr><td>'.$cat_label.'</td><td>';
@ -280,8 +286,12 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print '</td></tr>';
// Year
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
if (!in_array($year, $arrayyears)) {
$arrayyears[$year] = $year;
}
if (!in_array($nowyear, $arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0);
print '</td></tr>';
@ -304,11 +314,9 @@ print '<td class="right">%</td>';
print '</tr>';
$oldyear = 0;
foreach ($data as $val)
{
foreach ($data as $val) {
$year = $val['year'];
while (!empty($year) && $oldyear > $year + 1)
{ // If we have empty year
while (!empty($year) && $oldyear > $year + 1) { // If we have empty year
$oldyear--;
print '<tr class="oddeven" height="24">';
@ -341,7 +349,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs
print '<table class="border centpercent"><tr class="pair nohover"><td align="center">';
if ($mesg) { print $mesg; } else {
if ($mesg) {
print $mesg;
} else {
print $px1->show();
print "<br>\n";
print $px2->show();

View File

@ -44,16 +44,16 @@ $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1)
$total = 0;
$ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink)
{
foreach ($linkedObjectBlock as $key => $objectlink) {
$ilink++;
$trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
$trclass .= ' liste_sub_total';
}
print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
print '<td class="linkedcol-element" >'.$langs->trans("Proposal");
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)
{
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
$url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id;
print '<a class="objectlinked_importbtn" href="'.$url.'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a>';
}
@ -71,8 +71,7 @@ foreach ($linkedObjectBlock as $key => $objectlink)
print '<td class="linkedcol-action right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
print "</tr>\n";
}
if (count($linkedObjectBlock) > 1)
{
if (count($linkedObjectBlock) > 1) {
print '<tr class="liste_total '.(empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : '').'">';
print '<td>'.$langs->trans("Total").'</td>';
print '<td></td>';

View File

@ -36,7 +36,6 @@ if ($user->socid > 0) {
}
/*
* View
*/

View File

@ -28,32 +28,31 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'other'));
if (!empty($conf->facture->enabled)) $langs->load("bills");
if (!empty($conf->facture->enabled)) {
$langs->load("bills");
}
// Security check
$socid = $_GET["socid"];
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
/*
* View
*/
llxHeader();
if ($socid > 0)
{
if ($socid > 0) {
$societe = new Societe($db);
$societe->fetch($socid);
/*
* Affichage onglets
*/
* Affichage onglets
*/
$head = societe_prepare_head($societe);
print dol_get_fiche_head($head, 'prospect', $langs->trans("ThirdParty"), 0, 'company');
@ -68,8 +67,7 @@ if ($socid > 0)
print '<tr><td width="20%">'.$langs->trans("Thirdpary").'</td><td width="80%" colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
// Prefix
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
print ($societe->prefix_comm ? $societe->prefix_comm : '&nbsp;');
print '</td></tr>';
@ -84,7 +82,7 @@ if ($socid > 0)
print $langs->trans("FeatureNotYetAvailable");
} else {
dol_print_error($db);
dol_print_error($db);
}
// End of page

View File

@ -28,12 +28,13 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page
$langs->load("companies");
if (!empty($conf->facture->enabled)) $langs->load("bills");
if (!empty($conf->facture->enabled)) {
$langs->load("bills");
}
// Security check
$socid = $_GET["socid"];
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@ -46,14 +47,13 @@ if ($user->socid > 0)
llxHeader();
if ($socid > 0)
{
if ($socid > 0) {
$societe = new Societe($db);
$societe->fetch($socid);
/*
* Affichage onglets
*/
* Affichage onglets
*/
$head = societe_prepare_head($societe);
print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company');
@ -68,8 +68,7 @@ if ($socid > 0)
print '<tr><td width="20%">'.$langs->trans("ThirdParty").'</td><td width="80%" colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
// Prefix
if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
print ($societe->prefix_comm ? $societe->prefix_comm : '&nbsp;');
print '</td></tr>';
@ -84,7 +83,7 @@ if ($socid > 0)
print $langs->trans("FeatureNotYetAvailable");
} else {
dol_print_error($db);
dol_print_error($db);
}
// End of page

View File

@ -33,8 +33,7 @@ $id = GETPOST("id", 'int');
$socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
$socid = $user->socid;
}
@ -45,14 +44,12 @@ $backtopage = GETPOST('backtopage', 'alpha');
* Actions
*/
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
if (GETPOST('action', 'aZ09') == 'setremise')
{
if (GETPOST('action', 'aZ09') == 'setremise') {
$object = new Societe($db);
$object->fetch($id);
@ -64,10 +61,8 @@ if (GETPOST('action', 'aZ09') == 'setremise')
$result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note", "alphanohtml"), $user);
}
if ($result > 0)
{
if (!empty($backtopage))
{
if ($result > 0) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
} else {
@ -94,8 +89,7 @@ llxHeader();
* Mode fiche
*
*********************************************************************************/
if ($socid > 0)
{
if ($socid > 0) {
// On recupere les donnees societes par l'objet
$object = new Societe($db);
$object->fetch($socid);
@ -154,18 +148,17 @@ if ($socid > 0)
/*if (! ($isCustomer && $isSupplier))
{
if ($isCustomer && ! $isSupplier) {
print '<input type="hidden" name="discount_type" value="0" />';
}
if (! $isCustomer && $isSupplier) {
print '<input type="hidden" name="discount_type" value="1" />';
}
if ($isCustomer && ! $isSupplier) {
print '<input type="hidden" name="discount_type" value="0" />';
}
if (! $isCustomer && $isSupplier) {
print '<input type="hidden" name="discount_type" value="1" />';
}
}*/
print '<table class="border centpercent">';
if ($isCustomer || $isSupplier)
{
if ($isCustomer || $isSupplier) {
// Discount type
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td><td>';
if ($isCustomer) {
@ -193,8 +186,7 @@ if ($socid > 0)
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
if (!empty($backtopage))
{
if (!empty($backtopage)) {
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
}
@ -223,8 +215,7 @@ if ($socid > 0)
$sql .= " ORDER BY rc.datec DESC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<table class="noborder centpercent">';
$tag = !$tag;
print '<tr class="liste_titre">';
@ -234,11 +225,9 @@ if ($socid > 0)
print '<td class="center">'.$langs->trans("User").'</td>';
print '</tr>';
$num = $db->num_rows($resql);
if ($num > 0)
{
if ($num > 0) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), "dayhour").'</td>';
@ -278,8 +267,7 @@ if ($socid > 0)
$sql .= " ORDER BY rc.datec DESC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<table class="noborder centpercent">';
$tag = !$tag;
print '<tr class="liste_titre">';
@ -289,11 +277,9 @@ if ($socid > 0)
print '<td class="center">'.$langs->trans("User").'</td>';
print '</tr>';
$num = $db->num_rows($resql);
if ($num > 0)
{
if ($num > 0) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), "dayhour").'</td>';

View File

@ -40,8 +40,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
// Security check
$socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
if ($user->socid > 0)
{
if ($user->socid > 0) {
$socid = $user->socid;
}
@ -50,14 +49,12 @@ if ($user->socid > 0)
* Actions
*/
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes')
{
if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@ -70,23 +67,19 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes')
$remid = (GETPOST("remid", 'int') ? GETPOST("remid", 'int') : 0);
$discount = new DiscountAbsolute($db);
$res = $discount->fetch($remid);
if (!($res > 0))
{
if (!($res > 0)) {
$error++;
setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors');
}
if (!$error && price2num($amount_ttc_1 + $amount_ttc_2) != $discount->amount_ttc)
{
if (!$error && price2num($amount_ttc_1 + $amount_ttc_2) != $discount->amount_ttc) {
$error++;
setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors');
}
if (!$error && $discount->fk_facture_line)
{
if (!$error && $discount->fk_facture_line) {
$error++;
setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors');
}
if (!$error)
{
if (!$error) {
$newdiscount1 = new DiscountAbsolute($db);
$newdiscount2 = new DiscountAbsolute($db);
$newdiscount1->fk_facture_source = $discount->fk_facture_source;
@ -101,8 +94,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes')
$newdiscount2->fk_invoice_supplier = $discount->fk_invoice_supplier;
$newdiscount1->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
$newdiscount2->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
if ($discount->description == '(CREDIT_NOTE)' || $discount->description == '(DEPOSIT)')
{
if ($discount->description == '(CREDIT_NOTE)' || $discount->description == '(DEPOSIT)') {
$newdiscount1->description = $discount->description;
$newdiscount2->description = $discount->description;
} else {
@ -143,8 +135,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes')
$res = $discount->delete($user);
$newid1 = $newdiscount1->create($user);
$newid2 = $newdiscount2->create($user);
if ($res > 0 && $newid1 > 0 && $newid2 > 0)
{
if ($res > 0 && $newid1 > 0 && $newid2 > 0) {
$db->commit();
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage ? '&backtopage='.urlencode($backtopage) : '')); // To avoid pb whith back
exit;
@ -154,8 +145,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes')
}
}
if ($action == 'setremise' && $user->rights->societe->creer)
{
if ($action == 'setremise' && $user->rights->societe->creer) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@ -164,25 +154,20 @@ if ($action == 'setremise' && $user->rights->societe->creer)
$tva_tx = GETPOST('tva_tx', 'alpha');
$discount_type = !empty($_POST['discount_type']) ?GETPOST('discount_type', 'alpha') : 0;
if ($amount_ht > 0)
{
if ($amount_ht > 0) {
$error = 0;
if (empty($desc))
{
if (empty($desc)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReasonDiscount")), null, 'errors');
$error++;
}
if (!$error)
{
if (!$error) {
$soc = new Societe($db);
$soc->fetch($id);
$discountid = $soc->set_remise_except($amount_ht, $user, $desc, $tva_tx, $discount_type);
if ($discountid > 0)
{
if (!empty($backtopage))
{
if ($discountid > 0) {
if (!empty($backtopage)) {
header("Location: ".$backtopage.'&discountid='.$discountid);
exit;
} else {
@ -199,8 +184,7 @@ if ($action == 'setremise' && $user->rights->societe->creer)
}
}
if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes')
{
if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes') {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@ -209,8 +193,7 @@ if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes'
$discount = new DiscountAbsolute($db);
$result = $discount->fetch(GETPOST("remid"));
$result = $discount->delete($user);
if ($result > 0)
{
if ($result > 0) {
$db->commit();
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back
exit;
@ -231,8 +214,7 @@ $facturefournstatic = new FactureFournisseur($db);
llxHeader('', $langs->trans("GlobalDiscount"));
if ($socid > 0)
{
if ($socid > 0) {
// On recupere les donnees societes par l'objet
$object = new Societe($db);
$object->fetch($socid);
@ -283,11 +265,12 @@ if ($socid > 0)
$sql .= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
$sql .= " GROUP BY rc.fk_user";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $db->fetch_object($resql);
$remise_all += $obj->amount;
if ($obj->fk_user == $user->id) $remise_user += $obj->amount;
if ($obj->fk_user == $user->id) {
$remise_user += $obj->amount;
}
} else {
dol_print_error($db);
}
@ -295,8 +278,7 @@ if ($socid > 0)
print '<tr><td class="titlefield">'.$langs->trans("CustomerAbsoluteDiscountAllUsers").'</td>';
print '<td>'.$remise_all.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>';
if (!empty($user->fk_soc)) // No need to show this for external users
{
if (!empty($user->fk_soc)) { // No need to show this for external users
print '<tr><td>'.$langs->trans("CustomerAbsoluteDiscountMy").'</td>';
print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>';
}
@ -313,11 +295,12 @@ if ($socid > 0)
$sql .= " AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)";
$sql .= " GROUP BY rc.fk_user";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $db->fetch_object($resql);
$remise_all += $obj->amount;
if ($obj->fk_user == $user->id) $remise_user += $obj->amount;
if ($obj->fk_user == $user->id) {
$remise_user += $obj->amount;
}
} else {
dol_print_error($db);
}
@ -325,8 +308,7 @@ if ($socid > 0)
print '<tr><td class="titlefield">'.$langs->trans("SupplierAbsoluteDiscountAllUsers").'</td>';
print '<td>'.$remise_all.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>';
if (!empty($user->fk_soc)) // No need to show this for external users
{
if (!empty($user->fk_soc)) { // No need to show this for external users
print '<tr><td>'.$langs->trans("SupplierAbsoluteDiscountMy").'</td>';
print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>';
}
@ -339,8 +321,7 @@ if ($socid > 0)
print dol_get_fiche_end();
if ($user->rights->societe->creer)
{
if ($user->rights->societe->creer) {
print '<br>';
print load_fiche_titre($langs->trans("NewGlobalDiscount"), '', '');
@ -378,12 +359,10 @@ if ($socid > 0)
print dol_get_fiche_end();
}
if ($user->rights->societe->creer)
{
if ($user->rights->societe->creer) {
print '<div class="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("AddGlobalDiscount").'">';
if (!empty($backtopage))
{
if (!empty($backtopage)) {
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
}
@ -395,8 +374,7 @@ if ($socid > 0)
print '<br>';
if ($_GET['action'] == 'remove')
{
if ($_GET['action'] == 'remove') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.GETPOST('remid'), $langs->trans('RemoveDiscount'), $langs->trans('ConfirmRemoveDiscount'), 'confirm_remove', '', 0, 1);
}
@ -430,8 +408,7 @@ if ($socid > 0)
$sql .= " ORDER BY rc.datec DESC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<div class="div-table-responsive-no-min">';
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
@ -439,14 +416,12 @@ if ($socid > 0)
print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td class="right">'.$langs->trans("AmountHT").'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.$langs->trans("MulticurrencyAmountHT").'</td>';
}
print '<td class="right">'.$langs->trans("VATRate").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.$langs->trans("MulticurrencyAmountTTC").'</td>';
}
print '<td width="100" class="center">'.$langs->trans("DiscountOfferedBy").'</td>';
@ -457,32 +432,27 @@ if ($socid > 0)
$i = 0;
$num = $db->num_rows($resql);
if ($num > 0)
{
while ($i < $num)
{
if ($num > 0) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), 'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/', $obj->description))
{
if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref;
$facturestatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description))
{
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref;
$facturestatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
} elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description))
{
} elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref;
@ -496,30 +466,28 @@ if ($socid > 0)
}
print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>';
print '<td class="right">'.price($obj->amount_ht).'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>';
}
print '<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.price($obj->multicurrency_amount_ttc).'</td>';
}
print '<td class="center">';
print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'</a>';
print '</td>';
if ($user->rights->societe->creer || $user->rights->facture->creer)
{
if ($user->rights->societe->creer || $user->rights->facture->creer) {
print '<td class="center nowrap">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=split&remid='.$obj->rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).'</a>';
print '<a class="reposition marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&remid='.$obj->rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
print '</td>';
} else print '<td>&nbsp;</td>';
} else {
print '<td>&nbsp;</td>';
}
print '</tr>';
if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid)
{
if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) {
$showconfirminfo['rowid'] = $obj->rowid;
$showconfirminfo['amount_ttc'] = $obj->amount_ttc;
}
@ -527,15 +495,16 @@ if ($socid > 0)
}
} else {
$colspan = 8;
if (!empty($conf->multicurrency->enabled)) $colspan += 2;
if (!empty($conf->multicurrency->enabled)) {
$colspan += 2;
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$db->free($resql);
print "</table>";
print '</div>';
if (count($showconfirminfo))
{
if (count($showconfirminfo)) {
$amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT');
$amount2 = ($showconfirminfo['amount_ttc'] - $amount1);
$formquestion = array(
@ -578,8 +547,7 @@ if ($socid > 0)
$sql .= " ORDER BY rc.datec DESC";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
print '<div class="div-table-responsive-no-min">';
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
@ -587,14 +555,12 @@ if ($socid > 0)
print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td class="right">'.$langs->trans("AmountHT").'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.$langs->trans("MulticurrencyAmountHT").'</td>';
}
print '<td class="right">'.$langs->trans("VATRate").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.$langs->trans("MulticurrencyAmountTTC").'</td>';
}
print '<td width="100" class="center">'.$langs->trans("DiscountOfferedBy").'</td>';
@ -605,32 +571,27 @@ if ($socid > 0)
$i = 0;
$num = $db->num_rows($resql);
if ($num > 0)
{
while ($i < $num)
{
if ($num > 0) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), 'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/', $obj->description))
{
if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref;
$facturefournstatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>';
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description))
{
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref;
$facturefournstatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>';
} elseif (preg_match('/\(EXCESS PAID\)/', $obj->description))
{
} elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref;
@ -644,30 +605,28 @@ if ($socid > 0)
}
print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>';
print '<td class="right">'.price($obj->amount_ht).'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>';
}
print '<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.price($obj->multicurrency_amount_ttc).'</td>';
}
print '<td class="center">';
print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'</a>';
print '</td>';
if ($user->rights->societe->creer || $user->rights->facture->creer)
{
if ($user->rights->societe->creer || $user->rights->facture->creer) {
print '<td class="center nowrap">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=split&remid='.$obj->rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).'</a>';
print '<a class="reposition marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&remid='.$obj->rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
print '</td>';
} else print '<td>&nbsp;</td>';
} else {
print '<td>&nbsp;</td>';
}
print '</tr>';
if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid)
{
if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) {
$showconfirminfo['rowid'] = $obj->rowid;
$showconfirminfo['amount_ttc'] = $obj->amount_ttc;
}
@ -675,15 +634,16 @@ if ($socid > 0)
}
} else {
$colspan = 8;
if (!empty($conf->multicurrency->enabled)) $colspan += 2;
if (!empty($conf->multicurrency->enabled)) {
$colspan += 2;
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$db->free($resql);
print "</table>";
print '</div>';
if (count($showconfirminfo))
{
if (count($showconfirminfo)) {
$amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT');
$amount2 = ($showconfirminfo['amount_ttc'] - $amount1);
$formquestion = array(
@ -758,9 +718,10 @@ if ($socid > 0)
$resql = $db->query($sql);
$resql2 = null;
if ($resql) $resql2 = $db->query($sql2);
if ($resql2)
{
if ($resql) {
$resql2 = $db->query($sql2);
}
if ($resql2) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
@ -768,14 +729,12 @@ if ($socid > 0)
print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td class="right">'.$langs->trans("AmountHT").'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.$langs->trans("MulticurrencyAmountHT").'</td>';
}
print '<td class="right">'.$langs->trans("VATRate").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.$langs->trans("MulticurrencyAmountTTC").'</td>';
}
print '<td width="100" class="center">'.$langs->trans("Author").'</td>';
@ -785,10 +744,8 @@ if ($socid > 0)
$tab_sqlobj = array();
$tab_sqlobjOrder = array();
$num = $db->num_rows($resql);
if ($num > 0)
{
for ($i = 0; $i < $num; $i++)
{
if ($num > 0) {
for ($i = 0; $i < $num; $i++) {
$sqlobj = $db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
@ -797,8 +754,7 @@ if ($socid > 0)
$db->free($resql);
$num = $db->num_rows($resql2);
for ($i = 0; $i < $num; $i++)
{
for ($i = 0; $i < $num; $i++) {
$sqlobj = $db->fetch_object($resql2);
$tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
@ -807,32 +763,27 @@ if ($socid > 0)
array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj);
$num = count($tab_sqlobj);
if ($num > 0)
{
if ($num > 0) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = array_shift($tab_sqlobj);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), 'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/', $obj->description))
{
if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->invoice_source_ref;
$facturestatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description))
{
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->invoice_source_ref;
$facturestatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
} elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description))
{
} elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->invoice_source_ref;
@ -845,20 +796,17 @@ if ($socid > 0)
print '</td>';
}
print '<td class="left nowrap">';
if ($obj->invoiceid)
{
if ($obj->invoiceid) {
print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->invoiceid.'">'.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.'</a>';
}
print '</td>';
print '<td class="right">'.price($obj->amount_ht).'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>';
}
print '<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.price($obj->multicurrency_amount_ttc).'</td>';
}
print '<td class="center">';
@ -870,7 +818,9 @@ if ($socid > 0)
}
} else {
$colspan = 8;
if (!empty($conf->multicurrency->enabled)) $colspan += 2;
if (!empty($conf->multicurrency->enabled)) {
$colspan += 2;
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
@ -928,9 +878,10 @@ if ($socid > 0)
$resql = $db->query($sql);
$resql2 = null;
if ($resql) $resql2 = $db->query($sql2);
if ($resql2)
{
if ($resql) {
$resql2 = $db->query($sql2);
}
if ($resql2) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
@ -938,14 +889,12 @@ if ($socid > 0)
print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td class="right">'.$langs->trans("AmountHT").'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.$langs->trans("MulticurrencyAmountHT").'</td>';
}
print '<td class="right">'.$langs->trans("VATRate").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.$langs->trans("MulticurrencyAmountTTC").'</td>';
}
print '<td width="100" class="center">'.$langs->trans("Author").'</td>';
@ -955,10 +904,8 @@ if ($socid > 0)
$tab_sqlobj = array();
$tab_sqlobjOrder = array();
$num = $db->num_rows($resql);
if ($num > 0)
{
for ($i = 0; $i < $num; $i++)
{
if ($num > 0) {
for ($i = 0; $i < $num; $i++) {
$sqlobj = $db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
@ -967,8 +914,7 @@ if ($socid > 0)
$db->free($resql);
$num = $db->num_rows($resql2);
for ($i = 0; $i < $num; $i++)
{
for ($i = 0; $i < $num; $i++) {
$sqlobj = $db->fetch_object($resql2);
$tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
@ -977,32 +923,27 @@ if ($socid > 0)
array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj);
$num = count($tab_sqlobj);
if ($num > 0)
{
if ($num > 0) {
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = array_shift($tab_sqlobj);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), 'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/', $obj->description))
{
if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->invoice_source_ref;
$facturefournstatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>';
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description))
{
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->invoice_source_ref;
$facturefournstatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>';
} elseif (preg_match('/\(EXCESS PAID\)/', $obj->description))
{
} elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) {
print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->invoice_source_ref;
@ -1020,14 +961,12 @@ if ($socid > 0)
}
print '</td>';
print '<td class="right">'.price($obj->amount_ht).'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>';
}
print '<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>';
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right">'.price($obj->multicurrency_amount_ttc).'</td>';
}
print '<td class="center">';
@ -1039,7 +978,9 @@ if ($socid > 0)
}
} else {
$colspan = 8;
if (!empty($conf->multicurrency->enabled)) $colspan += 2;
if (!empty($conf->multicurrency->enabled)) {
$colspan += 2;
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}

View File

@ -30,14 +30,19 @@
* \brief File that include conf.php file and commons lib like functions.lib.php
*/
if (!defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE', 'Dolibarr');
if (!defined('DOL_VERSION')) define('DOL_VERSION', '14.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
if (!defined('DOL_APPLICATION_TITLE')) {
define('DOL_APPLICATION_TITLE', 'Dolibarr');
}
if (!defined('DOL_VERSION')) {
define('DOL_VERSION', '14.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
}
if (!defined('EURO')) define('EURO', chr(128));
if (!defined('EURO')) {
define('EURO', chr(128));
}
// Define syslog constants
if (!defined('LOG_DEBUG'))
{
if (!defined('LOG_DEBUG')) {
if (!function_exists("syslog")) {
// For PHP versions without syslog (like running on Windows OS)
define('LOG_EMERG', 0);
@ -52,7 +57,9 @@ if (!defined('LOG_DEBUG'))
}
// End of common declaration part
if (defined('DOL_INC_FOR_VERSION_ERROR')) return;
if (defined('DOL_INC_FOR_VERSION_ERROR')) {
return;
}
// Define vars
@ -73,15 +80,13 @@ $conffiletoshow = "htdocs/conf/conf.php";
// Include configuration
$result = @include_once $conffile; // Keep @ because with some error reporting this break the redirect done when file not found
if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done and we are in a web session
{
if (!empty($_SERVER["CONTEXT_PREFIX"])) // CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT are not defined on all apache versions
{
if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) { // If install not done and we are in a web session
if (!empty($_SERVER["CONTEXT_PREFIX"])) { // CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT are not defined on all apache versions
$path = $_SERVER["CONTEXT_PREFIX"]; // example '/dolibarr/' when using an apache alias.
if (!preg_match('/\/$/', $path)) $path .= '/';
}
elseif (preg_match('/index\.php/', $_SERVER['PHP_SELF']))
{
if (!preg_match('/\/$/', $path)) {
$path .= '/';
}
} elseif (preg_match('/index\.php/', $_SERVER['PHP_SELF'])) {
// When we ask index.php, we MUST BE SURE that $path is '' at the end. This is required to make install process
// when using apache alias like '/dolibarr/' that point to htdocs.
// Note: If calling page was an index.php not into htdocs (ie comm/index.php, ...), then this redirect will fails,
@ -94,11 +99,16 @@ if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done
$TDir = explode('/', $_SERVER['PHP_SELF']);
$path = '';
$i = count($TDir);
while ($i--)
{
if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') break;
if ($TDir[$i] == 'dolibarr') break;
if (substr($TDir[$i], -4, 4) == '.php') continue;
while ($i--) {
if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') {
break;
}
if ($TDir[$i] == 'dolibarr') {
break;
}
if (substr($TDir[$i], -4, 4) == '.php') {
continue;
}
$path .= '../';
}
@ -109,15 +119,16 @@ if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done
}
// Force PHP error_reporting setup (Dolibarr may report warning without this)
if (!empty($dolibarr_strict_mode))
{
if (!empty($dolibarr_strict_mode)) {
error_reporting(E_ALL | E_STRICT);
} else {
error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
}
// Disable php display errors
if (!empty($dolibarr_main_prod)) ini_set('display_errors', 'Off');
if (!empty($dolibarr_main_prod)) {
ini_set('display_errors', 'Off');
}
// Clean parameters
$dolibarr_main_data_root = trim($dolibarr_main_data_root);
@ -126,39 +137,63 @@ $dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ? '' : trim($d
$dolibarr_main_document_root = trim($dolibarr_main_document_root);
$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ? '' : trim($dolibarr_main_document_root_alt));
if (empty($dolibarr_main_db_port)) $dolibarr_main_db_port = 3306; // For compatibility with old configs, if not defined, we take 'mysql' type
if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type = 'mysqli'; // For compatibility with old configs, if not defined, we take 'mysql' type
if (empty($dolibarr_main_db_port)) {
$dolibarr_main_db_port = 3306; // For compatibility with old configs, if not defined, we take 'mysql' type
}
if (empty($dolibarr_main_db_type)) {
$dolibarr_main_db_type = 'mysqli'; // For compatibility with old configs, if not defined, we take 'mysql' type
}
// Mysql driver support has been removed in favor of mysqli
if ($dolibarr_main_db_type == 'mysql') $dolibarr_main_db_type = 'mysqli';
if (empty($dolibarr_main_db_prefix)) $dolibarr_main_db_prefix = 'llx_';
if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set = ($dolibarr_main_db_type == 'mysqli' ? 'utf8' : ''); // Old installation
if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation = ($dolibarr_main_db_type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0;
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = '';
if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users = 0;
if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb = 0;
if (empty($dolibarr_mailing_limit_sendbycli)) $dolibarr_mailing_limit_sendbycli = 0;
if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode = 0; // For debug in php strict mode
if ($dolibarr_main_db_type == 'mysql') {
$dolibarr_main_db_type = 'mysqli';
}
if (empty($dolibarr_main_db_prefix)) {
$dolibarr_main_db_prefix = 'llx_';
}
if (empty($dolibarr_main_db_character_set)) {
$dolibarr_main_db_character_set = ($dolibarr_main_db_type == 'mysqli' ? 'utf8' : ''); // Old installation
}
if (empty($dolibarr_main_db_collation)) {
$dolibarr_main_db_collation = ($dolibarr_main_db_type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation
}
if (empty($dolibarr_main_db_encryption)) {
$dolibarr_main_db_encryption = 0;
}
if (empty($dolibarr_main_db_cryptkey)) {
$dolibarr_main_db_cryptkey = '';
}
if (empty($dolibarr_main_limit_users)) {
$dolibarr_main_limit_users = 0;
}
if (empty($dolibarr_mailing_limit_sendbyweb)) {
$dolibarr_mailing_limit_sendbyweb = 0;
}
if (empty($dolibarr_mailing_limit_sendbycli)) {
$dolibarr_mailing_limit_sendbycli = 0;
}
if (empty($dolibarr_strict_mode)) {
$dolibarr_strict_mode = 0; // For debug in php strict mode
}
// Security: CSRF protection
// This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST'])
// when we post forms (we allow GET to allow direct link to access a particular page).
// Note about $_SERVER[HTTP_HOST/SERVER_NAME]: http://shiflett.org/blog/2006/mar/server-name-versus-http-host
// See also option $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN for a stronger CSRF protection.
if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck))
{
if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST']))
{
if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck)) {
if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST'])) {
$csrfattack = false;
if (empty($_SERVER['HTTP_REFERER'])) $csrfattack = true; // An evil browser was used
else {
if (empty($_SERVER['HTTP_REFERER'])) {
$csrfattack = true; // An evil browser was used
} else {
$tmpa = parse_url($_SERVER['HTTP_HOST']);
$tmpb = parse_url($_SERVER['HTTP_REFERER']);
if ((empty($tmpa['host']) ? $tmpa['path'] : $tmpa['host']) != (empty($tmpb['host']) ? $tmpb['path'] : $tmpb['host'])) $csrfattack = true;
if ((empty($tmpa['host']) ? $tmpa['path'] : $tmpa['host']) != (empty($tmpb['host']) ? $tmpb['path'] : $tmpb['host'])) {
$csrfattack = true;
}
}
if ($csrfattack)
{
if ($csrfattack) {
//print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
// Note: We can't use dol_escape_htmltag here to escape output because lib functions.lib.ph is not yet loaded.
print "Access refused by CSRF protection in main.inc.php. Referer of form (".htmlentities($_SERVER['HTTP_REFERER'], ENT_COMPAT, 'UTF-8').") is outside the server that serve this page (with method = ".htmlentities($_SERVER['REQUEST_METHOD'], ENT_COMPAT, 'UTF-8').").\n";
@ -168,20 +203,17 @@ if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck))
}
// Another test is done later on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
}
if (empty($dolibarr_main_db_host))
{
if (empty($dolibarr_main_db_host)) {
print '<div class="center">Dolibarr setup is not yet complete.<br><br>'."\n";
print '<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'."\n";
die;
}
if (empty($dolibarr_main_url_root))
{
if (empty($dolibarr_main_url_root)) {
print 'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'."\n";
print 'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'."\n";
die;
}
if (empty($dolibarr_main_data_root))
{
if (empty($dolibarr_main_data_root)) {
// Si repertoire documents non defini, on utilise celui par defaut
$dolibarr_main_data_root = str_replace("/htdocs", "", $dolibarr_main_document_root);
$dolibarr_main_data_root .= "/documents";
@ -204,14 +236,14 @@ if (!empty($_SERVER["DOCUMENT_ROOT"])) {
$paths = explode('/', str_replace('\\', '/', $_SERVER["SCRIPT_NAME"])); // C) Value reported by web server, to say full path on filesystem of a file. Ex: /dolibarr/htdocs/admin/system/phpinfo.php
// Try to detect if $_SERVER["DOCUMENT_ROOT"]+start of $_SERVER["SCRIPT_NAME"] is $dolibarr_main_document_root. If yes, relative url to add before dol files is this start part.
$concatpath = '';
foreach ($paths as $tmppath) // We check to find (B+start of C)=A
{
if (empty($tmppath)) continue;
foreach ($paths as $tmppath) { // We check to find (B+start of C)=A
if (empty($tmppath)) {
continue;
}
$concatpath .= '/'.$tmppath;
//if ($tmppath) $concatpath.='/'.$tmppath;
//print $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).'<br>';
if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) // @ avoid warning when safe_mode is on.
{
if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) { // @ avoid warning when safe_mode is on.
//print "Found relative url = ".$concatpath;
$tmp3 = $concatpath;
$found = 1;
@ -220,14 +252,21 @@ foreach ($paths as $tmppath) // We check to find (B+start of C)=A
//else print "Not found yet for concatpath=".$concatpath."<br>\n";
}
//print "found=".$found." dolibarr_main_url_root=".$dolibarr_main_url_root."\n";
if (!$found) $tmp = $dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
else $tmp = 'http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : '');
if (!$found) {
$tmp = $dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
} else {
$tmp = 'http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : '');
}
//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp."\n";
if (!empty($dolibarr_main_force_https)) $tmp = preg_replace('/^http:/i', 'https:', $tmp);
if (!empty($dolibarr_main_force_https)) {
$tmp = preg_replace('/^http:/i', 'https:', $tmp);
}
define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...)
$uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain:port
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
if ($suburi == '/') {
$suburi = ''; // If $suburi is /, it is now ''
}
define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
//print DOL_MAIN_URL_ROOT.'-'.DOL_URL_ROOT."\n";
@ -241,29 +280,54 @@ define('MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
* To use other version than embeded libraries, define here constant to path. Use '' to use include class path autodetect.
*/
// Path to root libraries
if (!defined('ADODB_PATH')) { define('ADODB_PATH', (!isset($dolibarr_lib_ADODB_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/adodbtime/' : (empty($dolibarr_lib_ADODB_PATH) ? '' : $dolibarr_lib_ADODB_PATH.'/')); }
if (!defined('TCPDF_PATH')) { define('TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.'/'); }
if (!defined('TCPDI_PATH')) { define('TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.'/'); }
if (!defined('NUSOAP_PATH')) { define('NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ? '' : $dolibarr_lib_NUSOAP_PATH.'/')); }
if (!defined('PHPEXCELNEW_PATH')) { define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/')); }
if (!defined('ODTPHP_PATH')) { define('ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ? '' : $dolibarr_lib_ODTPHP_PATH.'/')); }
if (!defined('ODTPHP_PATHTOPCLZIP')) { define('ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ? '' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.'/')); }
if (!defined('JS_CKEDITOR')) { define('JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ? '' : (empty($dolibarr_js_CKEDITOR) ? '' : $dolibarr_js_CKEDITOR.'/')); }
if (!defined('JS_JQUERY')) { define('JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ? '' : (empty($dolibarr_js_JQUERY) ? '' : $dolibarr_js_JQUERY.'/')); }
if (!defined('JS_JQUERY_UI')) { define('JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ? '' : (empty($dolibarr_js_JQUERY_UI) ? '' : $dolibarr_js_JQUERY_UI.'/')); }
if (!defined('ADODB_PATH')) {
define('ADODB_PATH', (!isset($dolibarr_lib_ADODB_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/adodbtime/' : (empty($dolibarr_lib_ADODB_PATH) ? '' : $dolibarr_lib_ADODB_PATH.'/'));
}
if (!defined('TCPDF_PATH')) {
define('TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.'/');
}
if (!defined('TCPDI_PATH')) {
define('TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.'/');
}
if (!defined('NUSOAP_PATH')) {
define('NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ? '' : $dolibarr_lib_NUSOAP_PATH.'/'));
}
if (!defined('PHPEXCELNEW_PATH')) {
define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/'));
}
if (!defined('ODTPHP_PATH')) {
define('ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ? '' : $dolibarr_lib_ODTPHP_PATH.'/'));
}
if (!defined('ODTPHP_PATHTOPCLZIP')) {
define('ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ? '' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.'/'));
}
if (!defined('JS_CKEDITOR')) {
define('JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ? '' : (empty($dolibarr_js_CKEDITOR) ? '' : $dolibarr_js_CKEDITOR.'/'));
}
if (!defined('JS_JQUERY')) {
define('JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ? '' : (empty($dolibarr_js_JQUERY) ? '' : $dolibarr_js_JQUERY.'/'));
}
if (!defined('JS_JQUERY_UI')) {
define('JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ? '' : (empty($dolibarr_js_JQUERY_UI) ? '' : $dolibarr_js_JQUERY_UI.'/'));
}
// Other required path
if (!defined('DOL_DEFAULT_TTF')) { define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/Aerial.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF) ? '' : $dolibarr_font_DOL_DEFAULT_TTF)); }
if (!defined('DOL_DEFAULT_TTF_BOLD')) { define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/AerialBd.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD) ? '' : $dolibarr_font_DOL_DEFAULT_TTF_BOLD)); }
if (!defined('DOL_DEFAULT_TTF')) {
define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/Aerial.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF) ? '' : $dolibarr_font_DOL_DEFAULT_TTF));
}
if (!defined('DOL_DEFAULT_TTF_BOLD')) {
define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/AerialBd.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD) ? '' : $dolibarr_font_DOL_DEFAULT_TTF_BOLD));
}
/*
* Include functions
*/
if (!defined('ADODB_DATE_VERSION')) include_once ADODB_PATH.'adodb-time.inc.php';
if (!defined('ADODB_DATE_VERSION')) {
include_once ADODB_PATH.'adodb-time.inc.php';
}
if (!file_exists(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php"))
{
if (!file_exists(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php")) {
print "Error: Dolibarr config file content seems to be not correctly defined.<br>\n";
print "Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
exit;

File diff suppressed because it is too large Load Diff

View File

@ -45,18 +45,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php';
$conf = new Conf();
// Set properties specific to database
$conf->db->host = $dolibarr_main_db_host;
$conf->db->port = $dolibarr_main_db_port;
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = empty($dolibarr_main_db_pass) ? '' : $dolibarr_main_db_pass;
$conf->db->type = $dolibarr_main_db_type;
$conf->db->host = $dolibarr_main_db_host;
$conf->db->port = $dolibarr_main_db_port;
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = empty($dolibarr_main_db_pass) ? '' : $dolibarr_main_db_pass;
$conf->db->type = $dolibarr_main_db_type;
$conf->db->prefix = $dolibarr_main_db_prefix;
$conf->db->character_set = $dolibarr_main_db_character_set;
$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type = constant('TEST_DB_FORCE_TYPE'); // Force db type (for test purpose, by PHP unit for example)
if (defined('TEST_DB_FORCE_TYPE')) {
$conf->db->type = constant('TEST_DB_FORCE_TYPE'); // Force db type (for test purpose, by PHP unit for example)
}
// Set properties specific to conf file
$conf->file->main_limit_users = $dolibarr_main_limit_users;
@ -68,18 +70,17 @@ $conf->file->strict_mode = empty($dolibarr_strict_mode) ? '' : $dolibarr_strict_
$conf->file->instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id; // Unique id of instance
$conf->file->dol_document_root = array('main' => (string) DOL_DOCUMENT_ROOT); // Define array of document root directories ('/home/htdocs')
$conf->file->dol_url_root = array('main' => (string) DOL_URL_ROOT); // Define array of url root path ('' or '/dolibarr')
if (!empty($dolibarr_main_document_root_alt))
{
if (!empty($dolibarr_main_document_root_alt)) {
// dolibarr_main_document_root_alt can contains several directories
$values = preg_split('/[;,]/', $dolibarr_main_document_root_alt);
$i = 0;
foreach ($values as $value) $conf->file->dol_document_root['alt'.($i++)] = (string) $value;
foreach ($values as $value) {
$conf->file->dol_document_root['alt'.($i++)] = (string) $value;
}
$values = preg_split('/[;,]/', $dolibarr_main_url_root_alt);
$i = 0;
foreach ($values as $value)
{
if (preg_match('/^http(s)?:/', $value))
{
foreach ($values as $value) {
if (preg_match('/^http(s)?:/', $value)) {
// Show error message
$correct_value = str_replace($dolibarr_main_url_root, '', $value);
print '<b>Error:</b><br>'."\n";
@ -99,36 +100,39 @@ if (!empty($dolibarr_main_document_root_alt))
}
// Chargement des includes principaux de librairies communes
if (!defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Need 500ko memory
if (!defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
if (!defined('NOREQUIRESOC')) require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
if (!defined('NOREQUIREUSER')) {
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Need 500ko memory
}
if (!defined('NOREQUIRETRAN')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
}
if (!defined('NOREQUIRESOC')) {
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
}
/*
* Creation objet $langs (must be before all other code)
*/
if (!defined('NOREQUIRETRAN'))
{
if (!defined('NOREQUIRETRAN')) {
$langs = new Translate('', $conf); // Must be after reading conf
}
/*
* Object $db
*/
if (!defined('NOREQUIREDB'))
{
if (!defined('NOREQUIREDB')) {
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
if ($db->error)
{
if ($db->error) {
// If we were into a website context
if (!defined('USEDOLIBARREDITOR') && !defined('USEDOLIBARRSERVER') && !empty($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], DOL_DATA_ROOT.'/website') === 0))
{
if (!defined('USEDOLIBARREDITOR') && !defined('USEDOLIBARRSERVER') && !empty($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], DOL_DATA_ROOT.'/website') === 0)) {
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) != 'cgi') http_response_code(503); // To tel search engine this is a temporary error
if (substr($sapi_type, 0, 3) != 'cgi') {
http_response_code(503); // To tel search engine this is a temporary error
}
print '<div class="center" style="text-align: center; margin: 100px;">';
if (is_object($langs))
{
if (is_object($langs)) {
$langs->setDefaultLang('auto');
$langs->load("website");
print $langs->trans("SorryWebsiteIsCurrentlyOffLine");
@ -175,10 +179,11 @@ if (session_id() && !empty($_SESSION["dol_entity"])) {
}
// Sanitize entity
if (!is_numeric($conf->entity)) $conf->entity = 1;
if (!is_numeric($conf->entity)) {
$conf->entity = 1;
}
if (!defined('NOREQUIREDB'))
{
if (!defined('NOREQUIREDB')) {
//print "Will work with data into entity instance number '".$conf->entity."'";
// Here we read database (llx_const table) and define $conf->global->XXX var.
@ -197,23 +202,25 @@ if (!empty($conf->file->mailing_limit_sendbycli)) {
}
// Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr.
if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC'))
{
if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) {
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$mysoc = new Societe($db);
$mysoc->setMysoc($conf);
// For some countries, we need to invert our address with customer address
if ($mysoc->country_code == 'DE' && !isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
if ($mysoc->country_code == 'DE' && !isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
$conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1;
}
}
// Set default language (must be after the setValues setting global $conf->global->MAIN_LANG_DEFAULT. Page main.inc.php will overwrite langs->defaultlang with user value later)
if (!defined('NOREQUIRETRAN'))
{
if (!defined('NOREQUIRETRAN')) {
$langcode = (GETPOST('lang', 'aZ09') ? GETPOST('lang', 'aZ09', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
if (defined('MAIN_LANG_DEFAULT')) $langcode = constant('MAIN_LANG_DEFAULT');
if (defined('MAIN_LANG_DEFAULT')) {
$langcode = constant('MAIN_LANG_DEFAULT');
}
$langs->setDefaultLang($langcode);
}
@ -223,5 +230,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
if (!defined('MAIN_LABEL_MENTION_NPR')) define('MAIN_LABEL_MENTION_NPR', 'NPR');
if (!defined('MAIN_LABEL_MENTION_NPR')) {
define('MAIN_LABEL_MENTION_NPR', 'NPR');
}
//if (! defined('PCLZIP_TEMPORARY_DIR')) define('PCLZIP_TEMPORARY_DIR', $conf->user->dir_temp);

View File

@ -28,48 +28,84 @@
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
// Some value of modulepart can be used to get resources that are public so no login are required.
// Note that only directory logo is free to access without login.
if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file']))
{
if (!defined("NOLOGIN")) define("NOLOGIN", 1);
if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
if (!defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file'])) {
if (!defined("NOLOGIN")) {
define("NOLOGIN", 1);
}
if (!defined("NOCSRFCHECK")) {
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
}
if (!defined("NOIPCHECK")) {
define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
}
// For direct external download link, we don't need to load/check we are into a login session
if (isset($_GET["hashp"]) && !defined("NOLOGIN"))
{
if (!defined("NOLOGIN")) define("NOLOGIN", 1);
if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
if (!defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
if (isset($_GET["hashp"]) && !defined("NOLOGIN")) {
if (!defined("NOLOGIN")) {
define("NOLOGIN", 1);
}
if (!defined("NOCSRFCHECK")) {
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
}
if (!defined("NOIPCHECK")) {
define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
}
// Some value of modulepart can be used to get resources that are public so no login are required.
if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')
{
if (!defined("NOLOGIN")) define("NOLOGIN", 1);
if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
if (!defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias') {
if (!defined("NOLOGIN")) {
define("NOLOGIN", 1);
}
if (!defined("NOCSRFCHECK")) {
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
}
if (!defined("NOIPCHECK")) {
define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
}
// Used by TakePOS Auto Order
if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'product' && isset($_GET["publictakepos"]))
{
if (!defined("NOLOGIN")) define("NOLOGIN", 1);
if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
if (!defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'product' && isset($_GET["publictakepos"])) {
if (!defined("NOLOGIN")) {
define("NOLOGIN", 1);
}
if (!defined("NOCSRFCHECK")) {
define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
}
if (!defined("NOIPCHECK")) {
define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
}
// For multicompany
$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) define("DOLENTITY", $entity);
if (is_numeric($entity)) {
define("DOLENTITY", $entity);
}
/**
* Header empty
@ -101,9 +137,15 @@ $urlsource = GETPOST('urlsource', 'alpha');
$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity;
// Security check
if (empty($modulepart) && empty($hashp)) accessforbidden('Bad link. Bad value for parameter modulepart', 0, 0, 1);
if (empty($original_file) && empty($hashp) && $modulepart != 'barcode') accessforbidden('Bad link. Missing identification to find file (param file or hashp)', 0, 0, 1);
if ($modulepart == 'fckeditor') $modulepart = 'medias'; // For backward compatibility
if (empty($modulepart) && empty($hashp)) {
accessforbidden('Bad link. Bad value for parameter modulepart', 0, 0, 1);
}
if (empty($original_file) && empty($hashp) && $modulepart != 'barcode') {
accessforbidden('Bad link. Missing identification to find file (param file or hashp)', 0, 0, 1);
}
if ($modulepart == 'fckeditor') {
$modulepart = 'medias'; // For backward compatibility
}
@ -119,38 +161,33 @@ if ($modulepart == 'fckeditor') $modulepart = 'medias'; // For backward compatib
* View
*/
if (GETPOST("cache", 'alpha'))
{
if (GETPOST("cache", 'alpha')) {
// Important: Following code is to avoid page request by browser and PHP CPU at
// each Dolibarr page access.
if (empty($dolibarr_nocache))
{
if (empty($dolibarr_nocache)) {
header('Cache-Control: max-age=3600, public, must-revalidate');
header('Pragma: cache'); // This is to avoid having Pragma: no-cache
} else header('Cache-Control: no-cache');
} else {
header('Cache-Control: no-cache');
}
//print $dolibarr_nocache; exit;
}
// If we have a hash public (hashp), we guess the original_file.
if (!empty($hashp))
{
if (!empty($hashp)) {
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile = new EcmFiles($db);
$result = $ecmfile->fetch(0, '', '', '', $hashp);
if ($result > 0)
{
if ($result > 0) {
$tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory
// filepath can be 'users/X' or 'X/propale/PR11111'
if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part.
{
if (is_numeric($tmp[0])) { // If first tmp is numeric, it is subdir of company for multicompany, we take next part.
$tmp = explode('/', $tmp[1], 2);
}
$moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path
if ($modulepart) // Not required, so often not defined, for link using public hashp parameter.
{
if ($moduleparttocheck == $modulepart)
{
if ($modulepart) { // Not required, so often not defined, for link using public hashp parameter.
if ($moduleparttocheck == $modulepart) {
// We remove first level of directory
$original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir
//var_dump($original_file); exit;
@ -169,13 +206,20 @@ if (!empty($hashp))
// Define mime type
$type = 'application/octet-stream';
if (GETPOST('type', 'alpha')) $type = GETPOST('type', 'alpha');
else $type = dol_mimetype($original_file);
if (GETPOST('type', 'alpha')) {
$type = GETPOST('type', 'alpha');
} else {
$type = dol_mimetype($original_file);
}
// Security: This wrapper is for images. We do not allow type/html
if (preg_match('/html/i', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 0, 0, 1);
if (preg_match('/html/i', $type)) {
accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 0, 0, 1);
}
// Security: This wrapper is for images. We do not allow files ending with .noexe
if (preg_match('/\.noexe$/i', $original_file)) accessforbidden('Error: Using the image wrapper to output a file ending with .noexe is not allowed.', 0, 0, 1);
if (preg_match('/\.noexe$/i', $original_file)) {
accessforbidden('Error: Using the image wrapper to output a file ending with .noexe is not allowed.', 0, 0, 1);
}
// Security: Delete string ../ into $original_file
$original_file = str_replace("../", "/", $original_file);
@ -184,7 +228,9 @@ $original_file = str_replace("../", "/", $original_file);
$refname = basename(dirname($original_file)."/");
// Security check
if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart', 0, 0, 1);
if (empty($modulepart)) {
accessforbidden('Bad value for parameter modulepart', 0, 0, 1);
}
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname);
$accessallowed = $check_access['accessallowed'];
@ -200,20 +246,15 @@ if (!empty($hashp)) {
}
} else {
// Basic protection (against external users only)
if ($user->socid > 0)
{
if ($sqlprotectagainstexternals)
{
if ($user->socid > 0) {
if ($sqlprotectagainstexternals) {
$resql = $db->query($sqlprotectagainstexternals);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($user->socid != $obj->fk_soc)
{
if ($user->socid != $obj->fk_soc) {
$accessallowed = 0;
break;
}
@ -226,15 +267,13 @@ if (!empty($hashp)) {
// Security:
// Limit access if permissions are wrong
if (!$accessallowed)
{
if (!$accessallowed) {
accessforbidden();
}
// Security:
// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $fullpath_original_file))
{
if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $fullpath_original_file)) {
dol_syslog("Refused to deliver file ".$fullpath_original_file);
print "ErrorFileNameInvalid: ".dol_escape_htmltag($original_file);
exit;
@ -242,15 +281,13 @@ if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $full
if ($modulepart == 'barcode')
{
if ($modulepart == 'barcode') {
$generator = GETPOST("generator", "alpha");
$code = GETPOST("code", 'none'); // This can be rich content (qrcode, datamatrix, ...)
$encoding = GETPOST("encoding", "alpha");
$readable = GETPOST("readable", 'alpha') ?GETPOST("readable", "alpha") : "Y";
if (empty($generator) || empty($encoding))
{
if (empty($generator) || empty($encoding)) {
print 'Error: Parameter "generator" or "encoding" not defined';
exit;
}
@ -259,23 +296,25 @@ if ($modulepart == 'barcode')
$result = 0;
foreach ($dirbarcode as $reldir)
{
foreach ($dirbarcode as $reldir) {
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) continue;
if (!is_dir($newdir)) {
continue;
}
$result = @include_once $newdir.$generator.'.modules.php';
if ($result) break;
if ($result) {
break;
}
}
// Load barcode class
$classname = "mod".ucfirst($generator);
$module = new $classname($db);
if ($module->encodingIsSupported($encoding))
{
if ($module->encodingIsSupported($encoding)) {
$result = $module->buildBarCode($code, $encoding, $readable);
}
} else {
@ -288,17 +327,15 @@ if ($modulepart == 'barcode')
dol_syslog("viewimage.php return file $fullpath_original_file filename=$filename content-type=$type");
// This test is to avoid error images when image is not available (for example thumbs).
if (!dol_is_file($fullpath_original_file) && empty($_GET["noalt"]))
{
if (!dol_is_file($fullpath_original_file) && empty($_GET["noalt"])) {
$fullpath_original_file = DOL_DOCUMENT_ROOT.'/public/theme/common/nophoto.png';
/*$error='Error: File '.$_GET["file"].' does not exists or filesystems permissions are not allowed';
print $error;
exit;*/
print $error;
exit;*/
}
// Permissions are ok and file found, so we return it
if ($type)
{
if ($type) {
top_httphead($type);
header('Content-Disposition: inline; filename="'.basename($fullpath_original_file).'"');
} else {
@ -312,4 +349,6 @@ if ($modulepart == 'barcode')
}
if (is_object($db)) $db->close();
if (is_object($db)) {
$db->close();
}