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; $this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; $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; global $langs;
$labelStatus = $langs->trans('ToDo'); $labelStatus = $langs->trans('ToDo');
if ($status == 1) $labelStatus = $langs->trans('Done'); if ($status == 1) {
elseif ($status == -1) $labelStatus = $langs->trans('Error'); $labelStatus = $langs->trans('Done');
} elseif ($status == -1) {
$labelStatus = $langs->trans('Error');
}
$labelStatusShort = $langs->trans('ToDo'); $labelStatusShort = $langs->trans('ToDo');
if ($status == 1) $labelStatus = $langs->trans('Done'); if ($status == 1) {
elseif ($status == -1) $labelStatus = $langs->trans('Error'); $labelStatus = $langs->trans('Done');
} elseif ($status == -1) {
$labelStatus = $langs->trans('Error');
}
$statusType = 'status5'; $statusType = 'status5';
if ($status == 1) $statusType = 'status4'; if ($status == 1) {
elseif ($status == -1) $statusType = 'status8'; $statusType = 'status4';
} elseif ($status == -1) {
$statusType = 'status8';
}
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
} }

View File

@ -114,34 +114,50 @@ class AgendaEvents extends DolibarrApi
// case of external user // case of external user
$socid = 0; $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 // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) {
if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists $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"; $sql = "SELECT t.id as rowid";
if (!empty($conf->societe->enabled)) if (!empty($conf->societe->enabled)) {
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) 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"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
if (!empty($conf->societe->enabled)) 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 ((!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').')'; $sql .= ' WHERE t.entity IN ('.getEntity('agenda').')';
if (!empty($conf->societe->enabled)) 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 ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
if ($user_ids) $sql .= " AND t.fk_user_action IN (".$user_ids.")"; $sql .= " AND t.fk_soc = sc.fk_soc";
if ($socid > 0) $sql .= " AND t.fk_soc = ".$socid; }
}
if ($user_ids) {
$sql .= " AND t.fk_user_action IN (".$user_ids.")";
}
if ($socid > 0) {
$sql .= " AND t.fk_soc = ".$socid;
}
// Insert sale filter // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0) {
{
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -150,8 +166,7 @@ class AgendaEvents extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0) {
{
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
@ -161,13 +176,11 @@ class AgendaEvents extends DolibarrApi
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$i = 0; $i = 0;
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min) while ($i < $min) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$actioncomm_static = new ActionComm($this->db); $actioncomm_static = new ActionComm($this->db);
if ($actioncomm_static->fetch($obj->rowid)) { if ($actioncomm_static->fetch($obj->rowid)) {
@ -206,12 +219,12 @@ class AgendaEvents extends DolibarrApi
$this->actioncomm->$field = $value; $this->actioncomm->$field = $value;
} }
/*if (isset($request_data["lines"])) { /*if (isset($request_data["lines"])) {
$lines = array(); $lines = array();
foreach ($request_data["lines"] as $line) { foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line); array_push($lines, (object) $line);
} }
$this->expensereport->lines = $lines; $this->expensereport->lines = $lines;
}*/ }*/
if ($this->actioncomm->create(DolibarrApiAccess::$user) < 0) { if ($this->actioncomm->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating event", array_merge(array($this->actioncomm->error), $this->actioncomm->errors)); 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); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') {
continue;
}
$this->actioncomm->$field = $value; $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 $this->get($id);
}
return false; return false;
} }
@ -316,8 +332,9 @@ class AgendaEvents extends DolibarrApi
{ {
$event = array(); $event = array();
foreach (AgendaEvents::$FIELDS as $field) { foreach (AgendaEvents::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field])) {
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
}
$event[$field] = $data[$field]; $event[$field] = $data[$field];
} }
return $event; return $event;

View File

@ -106,15 +106,16 @@ class CActionComm
{ {
$sql = "SELECT id, code, type, libelle as label, color, active, picto"; $sql = "SELECT id, code, type, libelle as label, color, active, picto";
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
if (is_numeric($id)) $sql .= " WHERE id=".(int) $id; if (is_numeric($id)) {
else $sql .= " WHERE code='".$this->db->escape($id)."'"; $sql .= " WHERE id=".(int) $id;
} else {
$sql .= " WHERE code='".$this->db->escape($id)."'";
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->num_rows($resql)) {
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->id; $this->id = $obj->id;
@ -165,62 +166,76 @@ class CActionComm
if ($active != '') { if ($active != '') {
$sql .= " AND active=".(int) $active; $sql .= " AND active=".(int) $active;
} }
if (!empty($excludetype)) $sql .= " AND type <> '".$this->db->escape($excludetype)."'"; if (!empty($excludetype)) {
if ($morefilter) $sql .= " AND ".$morefilter; $sql .= " AND type <> '".$this->db->escape($excludetype)."'";
}
if ($morefilter) {
$sql .= " AND ".$morefilter;
}
$sql .= " ORDER BY type, position, module"; $sql .= " ORDER BY type, position, module";
dol_syslog(get_class($this)."::liste_array", LOG_DEBUG); dol_syslog(get_class($this)."::liste_array", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$nump = $this->db->num_rows($resql); $nump = $this->db->num_rows($resql);
if ($nump) if ($nump) {
{
$idforallfornewmodule = 97; $idforallfornewmodule = 97;
$i = 0; $i = 0;
while ($i < $nump) while ($i < $nump) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$qualified = 1; $qualified = 1;
// $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto // $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 && $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) 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 = ''; $keyfortrans = '';
$transcode = ''; $transcode = '';
$code = $obj->code; $code = $obj->code;
$typecalendar = $obj->type; $typecalendar = $obj->type;
if ($onlyautoornot > 0 && $typecalendar == 'system') $code = 'AC_MANUAL'; if ($onlyautoornot > 0 && $typecalendar == 'system') {
elseif ($onlyautoornot > 0 && $typecalendar == 'systemauto') $code = 'AC_AUTO'; $code = 'AC_MANUAL';
elseif ($onlyautoornot > 0) $code = 'AC_'.strtoupper($obj->module); } elseif ($onlyautoornot > 0 && $typecalendar == 'systemauto') {
$code = 'AC_AUTO';
} elseif ($onlyautoornot > 0) {
$code = 'AC_'.strtoupper($obj->module);
}
if ($shortlabel) if ($shortlabel) {
{
$keyfortrans = "Action".$code.'Short'; $keyfortrans = "Action".$code.'Short';
$transcode = $langs->trans($keyfortrans); $transcode = $langs->trans($keyfortrans);
} }
if (empty($keyfortrans) || $keyfortrans == $transcode) if (empty($keyfortrans) || $keyfortrans == $transcode) {
{
$keyfortrans = "Action".$code; $keyfortrans = "Action".$code;
$transcode = $langs->trans($keyfortrans); $transcode = $langs->trans($keyfortrans);
} }
$label = (($transcode != $keyfortrans) ? $transcode : $langs->trans($obj->label)); $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') { if ($typecalendar == 'system') {
$label = '&nbsp;&nbsp; '.$label; $label = '&nbsp;&nbsp; '.$label;
$repid[-99] = $langs->trans("ActionAC_MANUAL"); $repid[-99] = $langs->trans("ActionAC_MANUAL");
@ -252,9 +267,13 @@ class CActionComm
} }
} }
if ($idorcode == 'id') $this->liste_array = $repid; if ($idorcode == 'id') {
elseif ($idorcode == 'code') $this->liste_array = $repcode; $this->liste_array = $repid;
else $this->liste_array = $repall; } elseif ($idorcode == 'code') {
$this->liste_array = $repcode;
} else {
$this->liste_array = $repall;
}
return $this->liste_array; return $this->liste_array;
} else { } else {
@ -276,6 +295,8 @@ class CActionComm
// Check if translation available // Check if translation available
$transcode = $langs->trans("Action".$this->code); $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 = ''; $file_text = '';
$tmparray = file($file); $tmparray = file($file);
if (is_array($tmparray)) if (is_array($tmparray)) {
{
$file_text = join("", $tmparray); //load file $file_text = join("", $tmparray); //load file
$file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text);
} }
@ -112,21 +111,20 @@ class ICal
$this->file_text = preg_split("[\n]", $this->file_text); $this->file_text = preg_split("[\n]", $this->file_text);
// is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR // 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; $insidealarm = 0;
$tmpkey = ''; $tmpvalue = ''; $type = ''; $tmpkey = ''; $tmpvalue = ''; $type = '';
foreach ($this->file_text as $text) foreach ($this->file_text as $text) {
{
$text = trim($text); // trim one line $text = trim($text); // trim one line
if (!empty($text)) if (!empty($text)) {
{
// get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin
list($key, $value) = $this->retun_key_value($text); list($key, $value) = $this->retun_key_value($text);
//var_dump($text.' -> '.$key.' - '.$value); //var_dump($text.' -> '.$key.' - '.$value);
switch ($text) // search special string switch ($text) { // search special string
{
case "BEGIN:VTODO": case "BEGIN:VTODO":
$this->todo_count = $this->todo_count + 1; // new to do begin $this->todo_count = $this->todo_count + 1; // new to do begin
$type = "VTODO"; $type = "VTODO";
@ -152,7 +150,6 @@ class ICal
case "END:VTODO": // end special text - goto VCALENDAR key case "END:VTODO": // end special text - goto VCALENDAR key
case "END:VEVENT": case "END:VEVENT":
case "END:VFREEBUSY": case "END:VFREEBUSY":
case "END:VCALENDAR": case "END:VCALENDAR":
case "END:DAYLIGHT": case "END:DAYLIGHT":
case "END:VTIMEZONE": case "END:VTIMEZONE":
@ -169,27 +166,25 @@ class ICal
break; break;
default: // no special string (SUMMARY, DESCRIPTION, ...) default: // no special string (SUMMARY, DESCRIPTION, ...)
if ($tmpvalue) if ($tmpvalue) {
{
$tmpvalue .= $text; $tmpvalue .= $text;
if (!preg_match('/=$/', $text)) // No more lines if (!preg_match('/=$/', $text)) { // No more lines
{
$key = $tmpkey; $key = $tmpkey;
$value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue)); $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue));
$tmpkey = ''; $tmpkey = '';
$tmpvalue = ''; $tmpvalue = '';
} }
} elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) } elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) {
{ if (preg_match('/=$/', $value)) {
if (preg_match('/=$/', $value))
{
$tmpkey = $key; $tmpkey = $key;
$tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message
} else { } else {
$value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value));
} }
} //$value=quotedPrintDecode($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; break;
} }
} }
@ -214,32 +209,35 @@ class ICal
//print 'type='.$type.' key='.$key.' value='.$value.'<br>'."\n"; //print 'type='.$type.' key='.$key.' value='.$value.'<br>'."\n";
if (empty($key)) if (empty($key)) {
{
$key = $this->last_key; $key = $this->last_key;
switch ($type) switch ($type) {
{ case 'VEVENT':
case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break; $value = $this->cal[$type][$this->event_count][$key].$value;
case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; break;
case 'VTODO': $value = $this->cal[$type][$this->todo_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 ($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") || 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;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE"))
{
list($key, $value) = array($key, $value); list($key, $value) = array($key, $value);
} else { } else {
list($key, $value) = $this->ical_dt_date($key, $value); list($key, $value) = $this->ical_dt_date($key, $value);
} }
} }
switch ($type) switch ($type) {
{
case "VTODO": case "VTODO":
$this->cal[$type][$this->todo_count][$key] = $value; $this->cal[$type][$this->todo_count][$key] = $value;
break; break;
@ -270,17 +268,17 @@ class ICal
{ {
// phpcs:enable // phpcs:enable
/* /*
preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches); preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches);
if (empty($matches)) if (empty($matches))
{ {
return array(false,$text); return array(false,$text);
} }
else else
{ {
$matches = array_splice($matches, 1, 2); $matches = array_splice($matches, 1, 2);
return $matches; return $matches;
}*/ }*/
return explode(':', $text, 2); return explode(':', $text, 2);
} }
@ -296,8 +294,7 @@ class ICal
// phpcs:enable // phpcs:enable
$result = array(); $result = array();
$rrule = explode(';', $value); $rrule = explode(';', $value);
foreach ($rrule as $line) foreach ($rrule as $line) {
{
$rcontent = explode('=', $line); $rcontent = explode('=', $line);
$result[$rcontent[0]] = $rcontent[1]; $result[$rcontent[0]] = $rcontent[1];
} }
@ -319,8 +316,9 @@ class ICal
$ntime = 0; $ntime = 0;
// TIME LIMITED EVENT // 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); $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]; //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1];
//print dol_print_date($ntime,'dayhour');exit; //print dol_print_date($ntime,'dayhour');exit;
@ -344,8 +342,7 @@ class ICal
// Analyse TZID // Analyse TZID
$temp = explode(";", $key); $temp = explode(";", $key);
if (empty($temp[1])) // not TZID if (empty($temp[1])) { // not TZID
{
$value = str_replace('T', '', $value); $value = str_replace('T', '', $value);
return array($key, $value); return array($key, $value);
} }
@ -368,8 +365,7 @@ class ICal
{ {
// phpcs:enable // phpcs:enable
$temp = $this->get_event_list(); $temp = $this->get_event_list();
if (!empty($temp)) if (!empty($temp)) {
{
usort($temp, array(&$this, "ical_dtstart_compare")); usort($temp, array(&$this, "ical_dtstart_compare"));
return $temp; return $temp;
} else { } 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/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.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 // Load translation files required by the page
$langs->loadLangs(array('companies', 'commercial', 'other', 'bills')); $langs->loadLangs(array('companies', 'commercial', 'other', 'bills'));
@ -45,9 +47,10 @@ $confirm = GETPOST('confirm', 'alpha');
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
if ($user->socid > 0) $socid = $user->socid;
{ }
if ($user->socid > 0) {
unset($_GET["action"]); unset($_GET["action"]);
$action = ''; $action = '';
} }
@ -55,8 +58,7 @@ $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|
$object = new ActionComm($db); $object = new ActionComm($db);
if ($id > 0) if ($id > 0) {
{
$ret = $object->fetch($id); $ret = $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
} }
@ -66,12 +68,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
$modulepart = 'actions'; $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); llxHeader('', $langs->trans("Agenda"), $help_url);
if ($object->id > 0) if ($object->id > 0) {
{
$result1 = $object->fetch($id); $result1 = $object->fetch($id);
$result2 = $object->fetch_thirdparty(); $result2 = $object->fetch_thirdparty();
$result3 = $object->fetch_contact(); $result3 = $object->fetch_contact();
$result4 = $object->fetch_userassigned(); $result4 = $object->fetch_userassigned();
$result5 = $object->fetch_optionals(); $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); dol_print_error($db, $object->error);
exit; exit;
} }
if ($object->authorid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser; } if ($object->authorid > 0) {
if ($object->usermodid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser; } $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 = new User($db);
$author->fetch($object->author->id); $author->fetch($object->author->id);
@ -142,8 +152,7 @@ if ($object->id > 0)
// Thirdparty // Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' '; //$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref .= $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 .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref .= '</a>'; $morehtmlref .= '</a>';
if ($proj->title) $morehtmlref .= ' - '.$proj->title; if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';
} }
@ -170,8 +181,7 @@ if ($object->id > 0)
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
// Type // 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>'; 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 // Date start
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); if (!$object->fulldayevent) {
else print dol_print_date($object->datep, 'day'); print dol_print_date($object->datep, 'dayhour');
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); } 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 '</td>';
print '</tr>'; print '</tr>';
// Date end // Date end
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); if (!$object->fulldayevent) {
else print dol_print_date($object->datef, 'day'); print dol_print_date($object->datef, 'dayhour');
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); } 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>'; print '</td></tr>';
// Location // 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>'; print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>';
} }
// Assigned to // Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">'; print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
$listofuserid = array(); $listofuserid = array();
if (empty($donotclearsession)) if (empty($donotclearsession)) {
{ if ($object->userownerid > 0) {
if ($object->userownerid > 0) $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first
if (!empty($object->userassigned)) // Now concat assigned users }
{ if (!empty($object->userassigned)) { // Now concat assigned users
// Restore array with key with same value than param 'id' // Restore array with key with same value than param 'id'
$tmplist1 = $object->userassigned; $tmplist1 = $object->userassigned;
foreach ($tmplist1 as $key => $val) foreach ($tmplist1 as $key => $val) {
{ if ($val['id'] && $val['id'] != $object->userownerid) {
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val; $listofuserid[$val['id']] = $val;
}
} }
} }
$_SESSION['assignedtouser'] = json_encode($listofuserid); $_SESSION['assignedtouser'] = json_encode($listofuserid);
} else { } else {
if (!empty($_SESSION['assignedtouser'])) if (!empty($_SESSION['assignedtouser'])) {
{
$listofuserid = json_decode($_SESSION['assignedtouser'], true); $listofuserid = json_decode($_SESSION['assignedtouser'], true);
} }
} }
@ -241,8 +260,7 @@ if ($object->id > 0)
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0; $totalsize = 0;
foreach ($filearray as $key => $file) foreach ($filearray as $key => $file) {
{
$totalsize += $file['size']; $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'); $id = GETPOST('id', 'int');
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
{
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
@ -84,8 +83,7 @@ $morehtmlref = '<div class="refidno">';
// Thirdparty // Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' '; //$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref .= $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 .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref .= $proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref .= '</a>'; $morehtmlref .= '</a>';
if ($proj->title) $morehtmlref .= ' - '.$proj->title; if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';
} }

View File

@ -27,7 +27,9 @@
* \brief Page to list actions * \brief Page to list actions
*/ */
if (!defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); if (!defined("NOREDIRECTBYMAINTOLOGIN")) {
define('NOREDIRECTBYMAINTOLOGIN', 1);
}
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@ -55,14 +57,17 @@ $toselect = GETPOST('toselect', 'array');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) // 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); $actioncode = GETPOST('search_actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0'; if (!count($actioncode)) {
$actioncode = '0';
}
} else { } 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)); $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_id = GETPOST('search_id', 'alpha');
$search_title = GETPOST('search_title', 'alpha'); $search_title = GETPOST('search_title', 'alpha');
$search_note = GETPOST('search_note', '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'); $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'); $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'); $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 ($search_status == '' && !GETPOSTISSET('search_status')) {
if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); $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); $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); $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_'); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// If not choice done on calendar owner, we filter on user. // 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; $filtert = $user->id;
} }
@ -98,30 +106,41 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if ($page == -1 || $page == null) { $page = 0; } if ($page == -1 || $page == null) {
$offset = $limit * $page; $page = 0;
if (!$sortorder)
{
$sortorder = "DESC,DESC";
if ($search_status == 'todo') $sortorder = "DESC,DESC";
} }
if (!$sortfield) $offset = $limit * $page;
{ if (!$sortorder) {
$sortorder = "DESC,DESC";
if ($search_status == 'todo') {
$sortorder = "DESC,DESC";
}
}
if (!$sortfield) {
$sortfield = "a.datep,a.id"; $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 // Security check
$socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); $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'); $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
if ($socid < 0) $socid = ''; if ($socid < 0) {
$socid = '';
}
$canedit = 1; $canedit = 1;
if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->myactions->read) {
if (!$user->rights->agenda->allactions->read) $canedit = 0; accessforbidden();
if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me }
{ 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; $filtert = $user->id;
} }
@ -152,18 +171,14 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) if (GETPOST('cancel', 'alpha')) {
{
$action = 'list'; $massaction = ''; $action = 'list'; $massaction = '';
} }
if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) {
{
$param = ''; $param = '';
if (is_array($_POST)) if (is_array($_POST)) {
{ foreach ($_POST as $key => $val) {
foreach ($_POST as $key => $val)
{
$param .= '&'.$key.'='.urlencode($val); $param .= '&'.$key.'='.urlencode($val);
} }
} }
@ -174,13 +189,14 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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 // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // 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=''; //$actioncode='';
$search_id = ''; $search_id = '';
$search_title = ''; $search_title = '';
@ -192,12 +208,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_array_options = array(); $search_array_options = array();
} }
if (empty($reshook) && !empty($massaction)) if (empty($reshook) && !empty($massaction)) {
{
unset($percent); unset($percent);
switch ($massaction) switch ($massaction) {
{
case 'set_all_events_to_todo': case 'set_all_events_to_todo':
$percent = ActionComm::EVENT_TODO; $percent = ActionComm::EVENT_TODO;
break; break;
@ -211,13 +225,10 @@ if (empty($reshook) && !empty($massaction))
break; break;
} }
if (isset($percent)) if (isset($percent)) {
{ foreach ($toselect as $toselectid) {
foreach ($toselect as $toselectid)
{
$result = $object->updatePercent($toselectid, $percent); $result = $object->updatePercent($toselectid, $percent);
if ($result < 0) if ($result < 0) {
{
dol_print_error($db); dol_print_error($db);
break; 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). // 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'; $objectclass = 'ActionComm';
$objectlabel = 'Events'; $objectlabel = 'Events';
$uploaddir = true; $uploaddir = true;
@ -258,32 +268,78 @@ llxHeader('', $langs->trans("Agenda"), $help_url);
$listofextcals = array(); $listofextcals = array();
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($actioncode != '') { if ($actioncode != '') {
if (is_array($actioncode)) { if (is_array($actioncode)) {
foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); foreach ($actioncode as $str_action) {
} else $param .= "&search_actioncode=".urlencode($actioncode); $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 // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; 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_in_progress' => $langs->trans("SetAllEventsToInProgress"),
'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"), '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"); $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 ($user->rights->agenda->myactions->create) {
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); $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); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$sql = "SELECT"; $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 .= " 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.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,'; $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 // Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) { 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 // Add fields from hooks
@ -325,34 +388,47 @@ $sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; $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."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 .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c"; $sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c";
// We must filter on resource table // 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 // We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; if ($filtert > 0 || $usergroup > 0) {
if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $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 .= " WHERE c.id = a.fk_action";
$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
// Condition on actioncode // Condition on actioncode
if (!empty($actioncode)) if (!empty($actioncode)) {
{ if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) if ($actioncode == 'AC_NON_AUTO') {
{ $sql .= " AND c.type != 'systemauto'";
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; } elseif ($actioncode == 'AC_ALL_AUTO') {
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; $sql .= " AND c.type = 'systemauto'";
else { } else {
if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; if ($actioncode == 'AC_OTH') {
if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; $sql .= " AND c.type != 'systemauto'";
}
if ($actioncode == 'AC_OTH_AUTO') {
$sql .= " AND c.type = 'systemauto'";
}
} }
} else { } else {
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; if ($actioncode == 'AC_NON_AUTO') {
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; $sql .= " AND c.type != 'systemauto'";
else { } elseif ($actioncode == 'AC_ALL_AUTO') {
if (is_array($actioncode)) $sql .= " AND c.type = 'systemauto'";
{ } else {
if (is_array($actioncode)) {
$sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; $sql .= " AND c.code IN ('".implode("','", $actioncode)."')";
} else { } else {
$sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; $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 ($resourceid > 0) {
if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
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 ($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 // We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($filtert > 0 || $usergroup > 0) {
if ($type) $sql .= " AND c.id = ".(int) $type; $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($search_status == '0') { $sql .= " AND a.percent = 0"; } }
if ($search_status == 'na') { $sql .= " AND a.percent = -1"; } // Not applicable if ($type) {
if ($search_status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started $sql .= " AND c.id = ".(int) $type;
if ($search_status == '100') { $sql .= " AND a.percent = 100"; } }
if ($search_status == 'done') { $sql .= " AND (a.percent = 100)"; } if ($search_status == '0') {
if ($search_status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } $sql .= " AND a.percent = 0";
if ($search_id) $sql .= natural_search("a.id", $search_id, 1); }
if ($search_title) $sql .= natural_search("a.label", $search_title); if ($search_status == 'na') {
if ($search_note) $sql .= natural_search('a.note', $search_note); $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 // We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) if ($filtert > 0 || $usergroup > 0) {
{
$sql .= " AND ("; $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 ($filtert > 0) {
if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; $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 .= ")"; $sql .= ")";
} }
// The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) // 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 ($dateselect > 0) {
if ($datestart > 0) $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; $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 ($dateend > 0) $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 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 // Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -401,12 +516,10 @@ $sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $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; $page = 0;
$offset = 0; $offset = 0;
} }
@ -417,8 +530,7 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("comm/action/list.php", LOG_DEBUG); dol_syslog("comm/action/list.php", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$actionstatic = new ActionComm($db); $actionstatic = new ActionComm($db);
$societestatic = new Societe($db); $societestatic = new Societe($db);
@ -438,7 +550,9 @@ if ($resql)
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n"; 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="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@ -446,8 +560,12 @@ if ($resql)
print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="hidden" name="type" value="'.$type.'">';
$nav = ''; $nav = '';
if ($filter) $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">'; if ($filter) {
if ($showbirthday) $nav .= '<input type="hidden" name="search_showbirthday" value="1">'; $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
}
if ($showbirthday) {
$nav .= '<input type="hidden" name="search_showbirthday" value="1">';
}
print $nav; print $nav;
//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
@ -457,19 +575,19 @@ if ($resql)
// Add link to show birthdays // Add link to show birthdays
$link = ''; $link = '';
/* /*
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax))
{ {
$newparam=$param; // newparam is for birthday links $newparam=$param; // newparam is for birthday links
$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam); $newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1'; if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
$link='<a href="'.$_SERVER['PHP_SELF']; $link='<a href="'.$_SERVER['PHP_SELF'];
$link.='?'.$newparam; $link.='?'.$newparam;
$link.='">'; $link.='">';
if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents"); if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
else $link.=$langs->trans("AgendaHideBirthdayEvents"); else $link.=$langs->trans("AgendaHideBirthdayEvents");
$link.='</a>'; $link.='</a>';
} }
*/ */
$s = $newtitle; $s = $newtitle;
@ -550,7 +668,9 @@ if ($resql)
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $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; $i = 0;
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
@ -561,11 +681,21 @@ if ($resql)
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">'; 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['a.id']['checked'])) {
if (!empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>'; print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></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['owner']['checked'])) {
if (!empty($arrayfields['a.note']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>'; 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'])) { if (!empty($arrayfields['a.datep']['checked'])) {
print '<td class="liste_titre nowraponall" align="center">'; print '<td class="liste_titre nowraponall" align="center">';
print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); 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'])) { if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
if (!empty($arrayfields['a.fk_contact']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['a.fk_contact']['checked'])) {
if (!empty($arrayfields['a.fk_element']['checked'])) print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['a.fk_element']['checked'])) {
print '<td class="liste_titre"></td>';
}
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; 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 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (!empty($arrayfields['a.datec']['checked'])) print '<td class="liste_titre"></td>'; if (!empty($arrayfields['a.datec']['checked'])) {
if (!empty($arrayfields['a.tms']['checked'])) print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['a.tms']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['a.percent']['checked'])) { if (!empty($arrayfields['a.percent']['checked'])) {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
$formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); $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>\n";
print '<tr class="liste_titre">'; 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['a.id']['checked'])) {
if (!empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $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['owner']['checked'])) {
if (!empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); 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($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.datep']['checked'])) {
if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $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.datep2']['checked'])) {
if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); 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 // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; 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 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; 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.datec']['checked'])) {
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); 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_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n"; 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); $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
$contactListCache = array(); $contactListCache = array();
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
// Discard auto action if option is on // 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++; $i++;
continue; continue;
} }
@ -676,29 +838,34 @@ if ($resql)
} }
// User owner // 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. 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); $userstatic->fetch($obj->fk_user_action);
print $userstatic->getNomUrl(-1); print $userstatic->getNomUrl(-1);
} else print '&nbsp;'; } else {
print '&nbsp;';
}
print '</td>'; print '</td>';
} }
// Type // Type
if (!empty($arrayfields['c.libelle']['checked'])) if (!empty($arrayfields['c.libelle']['checked'])) {
{
print '<td class="nowraponall">'; print '<td class="nowraponall">';
print $actionstatic->getTypePicto(); print $actionstatic->getTypePicto();
$labeltype = $obj->type_code; $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') { if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') {
$labeltype = $langs->trans("Message"); $labeltype = $langs->trans("Message");
} else { } else {
if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; if (!empty($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 $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 dol_trunc($labeltype, 28);
print '</td>'; print '</td>';
@ -726,11 +893,21 @@ if ($resql)
print '<td class="center nowraponall">'; print '<td class="center nowraponall">';
print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser');
$late = 0; $late = 0;
if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; $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 ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) {
if ($late) print img_warning($langs->trans("Late")).' '; $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>'; print '</td>';
} }
@ -744,15 +921,16 @@ if ($resql)
// Third party // Third party
if (!empty($arrayfields['s.nom']['checked'])) { if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="tdoverflowmax150">'; print '<td class="tdoverflowmax150">';
if ($obj->socid > 0) if ($obj->socid > 0) {
{
$societestatic->id = $obj->socid; $societestatic->id = $obj->socid;
$societestatic->client = $obj->client; $societestatic->client = $obj->client;
$societestatic->name = $obj->societe; $societestatic->name = $obj->societe;
$societestatic->email = $obj->socemail; $societestatic->email = $obj->socemail;
print $societestatic->getNomUrl(1, '', 28); print $societestatic->getNomUrl(1, '', 28);
} else print '&nbsp;'; } else {
print '&nbsp;';
}
print '</td>'; print '</td>';
} }
@ -760,17 +938,13 @@ if ($resql)
if (!empty($arrayfields['a.fk_contact']['checked'])) { if (!empty($arrayfields['a.fk_contact']['checked'])) {
print '<td class="tdoverflowmax100">'; print '<td class="tdoverflowmax100">';
if (!empty($actionstatic->socpeopleassigned)) if (!empty($actionstatic->socpeopleassigned)) {
{
$contactList = array(); $contactList = array();
foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) {
{ if (!isset($contactListCache[$socpeopleassigned['id']])) {
if (!isset($contactListCache[$socpeopleassigned['id']]))
{
// if no cache found we fetch it // if no cache found we fetch it
$contact = new Contact($db); $contact = new Contact($db);
if ($contact->fetch($socpeopleassigned['id']) > 0) if ($contact->fetch($socpeopleassigned['id']) > 0) {
{
$contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0);
$contactList[] = $contact->getNomUrl(1, '', 0); $contactList[] = $contact->getNomUrl(1, '', 0);
} }
@ -782,8 +956,7 @@ if ($resql)
if (!empty($contactList)) { if (!empty($contactList)) {
print implode(', ', $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->id = $obj->fk_contact;
$contactstatic->email = $obj->email; $contactstatic->email = $obj->email;
$contactstatic->lastname = $obj->lastname; $contactstatic->lastname = $obj->lastname;
@ -835,10 +1008,11 @@ if ($resql)
} }
// Action column // Action column
print '<td class="nowrap center">'; 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; $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 '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
} }
print '</td>'; 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'; 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); $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); $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; $showbirthday = 0;
// If not choice done on calendar owner, we filter on user. // 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; $filtert = $user->id;
} }
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page; $offset = $limit * $page;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "a.datec"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "a.datec";
}
// Security check // Security check
$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); $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'); $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
if ($socid < 0) $socid = ''; if ($socid < 0) {
$socid = '';
}
$canedit = 1; $canedit = 1;
if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->myactions->read) {
if (!$user->rights->agenda->allactions->read) $canedit = 0; accessforbidden();
if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me }
{ 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; $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); $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') $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) // 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); $actioncode = GETPOST('search_actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0'; if (!count($actioncode)) {
$actioncode = '0';
}
} else { } 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)); $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')); $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'); $day = GETPOST('dateselectday', 'int');
$month = GETPOST('dateselectmonth', 'int'); $month = GETPOST('dateselectmonth', 'int');
$year = GETPOST('dateselectyear', 'int'); $year = GETPOST('dateselectyear', 'int');
@ -112,9 +128,15 @@ $tmp = str_replace(' ', '', $tmp); // FIX 7533
$tmparray = explode('-', $tmp); $tmparray = explode('-', $tmp);
$begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); $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); $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 ($begin_h < 0 || $begin_h > 23) {
if ($end_h < 1 || $end_h > 24) $end_h = 18; $begin_h = 9;
if ($end_h <= $begin_h) $end_h = $begin_h + 1; }
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 = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS;
$tmp = str_replace(' ', '', $tmp); // FIX 7533 $tmp = str_replace(' ', '', $tmp); // FIX 7533
@ -122,8 +144,12 @@ $tmparray = explode('-', $tmp);
$begin_d = 1; $begin_d = 1;
$end_d = 53; $end_d = 53;
if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); if ($status == '' && !GETPOSTISSET('status')) {
if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); $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') { if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') {
$action = 'show_month'; $day = ''; $action = 'show_month'; $day = '';
@ -149,8 +175,7 @@ $hookmanager->initHooks(array('agenda'));
* Actions * Actions
*/ */
if ($action == 'delete_action') if ($action == 'delete_action') {
{
$event = new ActionComm($db); $event = new ActionComm($db);
$event->fetch($actionid); $event->fetch($actionid);
$event->fetch_optionals(); $event->fetch_optionals();
@ -185,7 +210,9 @@ $parameters = array(
'usergroup' => $usergroup, 'usergroup' => $usergroup,
); );
$reshook = $hookmanager->executeHooks('beforeAgendaPerType', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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); $form = new Form($db);
$companystatic = new Societe($db); $companystatic = new Societe($db);
@ -223,29 +250,65 @@ $tmpday = $first_day;
//print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
$title = $langs->trans("DoneAndToDoActions"); $title = $langs->trans("DoneAndToDoActions");
if ($status == 'done') $title = $langs->trans("DoneActions"); if ($status == 'done') {
if ($status == 'todo') $title = $langs->trans("ToDoActions"); $title = $langs->trans("DoneActions");
}
if ($status == 'todo') {
$title = $langs->trans("ToDoActions");
}
$param = ''; $param = '';
if ($actioncode || GETPOSTISSET('search_actioncode')) { if ($actioncode || GETPOSTISSET('search_actioncode')) {
if (is_array($actioncode)) { if (is_array($actioncode)) {
foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); foreach ($actioncode as $str_action) {
} else $param .= "&search_actioncode=".urlencode($actioncode); $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); $param .= "&maxprint=".urlencode($maxprint);
$paramnoactionodate = $param; $paramnoactionodate = $param;
@ -301,28 +364,23 @@ print '<form method="POST" id="searchFormList" class="listactionsfilter" action=
$showextcals = $listofextcals; $showextcals = $listofextcals;
// Legend // Legend
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
$s = ''; $s = '';
$s .= '<script type="text/javascript">'."\n"; $s .= '<script type="text/javascript">'."\n";
$s .= 'jQuery(document).ready(function () {'."\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_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("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'."\n";
$s .= '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 .= '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 .= '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"; $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>'; $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) if (is_array($showextcals) && count($showextcals) > 0) {
{ foreach ($showextcals as $val) {
foreach ($showextcals as $val)
{
$htmlname = md5($val['name']); $htmlname = md5($val['name']);
$s .= '<script type="text/javascript">'."\n"; $s .= '<script type="text/javascript">'."\n";
$s .= 'jQuery(document).ready(function () {'."\n"; $s .= 'jQuery(document).ready(function () {'."\n";
@ -341,11 +399,9 @@ if ($conf->use_javascript_ajax)
// Calendars from hooks // Calendars from hooks
$parameters = array(); $object = null; $parameters = array(); $object = null;
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
if (empty($reshook)) if (empty($reshook)) {
{
$s .= $hookmanager->resPrint; $s .= $hookmanager->resPrint;
} elseif ($reshook > 1) } elseif ($reshook > 1) {
{
$s = $hookmanager->resPrint; $s = $hookmanager->resPrint;
} }
} }
@ -397,8 +453,7 @@ if (empty($reshook)) {
$newcardbutton = ''; $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); $tmpforcreatebutton = dol_getdate(dol_now(), true);
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; $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 // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR
$sql = 'SELECT'; $sql = 'SELECT';
if ($usergroup > 0) $sql .= " DISTINCT"; if ($usergroup > 0) {
$sql .= " DISTINCT";
}
$sql .= ' a.id, a.label,'; $sql .= ' a.id, a.label,';
$sql .= ' a.datep,'; $sql .= ' a.datep,';
$sql .= ' a.datep2,'; $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 .= ' 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 .= ' 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"; $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 // 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 // We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; if ($filtert > 0 || $usergroup > 0) {
if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $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 .= ' WHERE a.fk_action = ca.id';
$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
// Condition on actioncode // Condition on actioncode
if (!empty($actioncode)) if (!empty($actioncode)) {
{ if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) if ($actioncode == 'AC_NON_AUTO') {
{ $sql .= " AND ca.type != 'systemauto'";
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; } elseif ($actioncode == 'AC_ALL_AUTO') {
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; $sql .= " AND ca.type = 'systemauto'";
else { } else {
if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; if ($actioncode == 'AC_OTH') {
if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; $sql .= " AND ca.type != 'systemauto'";
}
if ($actioncode == 'AC_OTH_AUTO') {
$sql .= " AND ca.type = 'systemauto'";
}
} }
} else { } else {
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; if ($actioncode == 'AC_NON_AUTO') {
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; $sql .= " AND ca.type != 'systemauto'";
else { } elseif ($actioncode == 'AC_ALL_AUTO') {
if (is_array($actioncode)) $sql .= " AND ca.type = 'systemauto'";
{ } else {
if (is_array($actioncode)) {
$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
} else { } else {
$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; $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 ($resourceid > 0) {
if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
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 ($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 // We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($filtert > 0 || $usergroup > 0) {
if ($action == 'show_day') $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
{ }
if ($action == 'show_day') {
$sql .= " AND ("; $sql .= " AND (";
$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; $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))."')"; $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 .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')";
$sql .= ')'; $sql .= ')';
} }
if ($type) $sql .= " AND ca.id = ".$type; if ($type) {
if ($status == '0') { $sql .= " AND a.percent = 0"; } $sql .= " AND ca.id = ".$type;
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 == '0') {
if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } $sql .= " AND a.percent = 0";
if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } }
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 // We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) if ($filtert > 0 || $usergroup > 0) {
{
$sql .= " AND ("; $sql .= " AND (";
if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; if ($filtert > 0) {
if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; $sql .= "ar.fk_element = ".$filtert;
}
if ($usergroup > 0) {
$sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
}
$sql .= ")"; $sql .= ")";
} }
// Sort on date // 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); dol_syslog("comm/action/pertype.php", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
// Discard auto action if option is on // 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++; $i++;
continue; continue;
} }
@ -572,34 +663,41 @@ if ($resql)
// Defined date_start_in_calendar and date_end_in_calendar property // 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. // 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; $event->date_start_in_calendar = $datep;
if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; if ($datep2 != '' && $datep2 >= $datep) {
else $event->date_end_in_calendar = $datep; $event->date_end_in_calendar = $datep2;
} else {
$event->date_end_in_calendar = $datep;
}
} else { } else {
$event->date_start_in_calendar = $datep; $event->date_start_in_calendar = $datep;
if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; if ($datep2 != '' && $datep2 >= $datep) {
else $event->date_end_in_calendar = $datep; $event->date_end_in_calendar = $datep2;
} else {
$event->date_end_in_calendar = $datep;
}
} }
// Define ponctual property // 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; $event->ponctuel = 1;
} }
// Check values // Check values
if ($event->date_end_in_calendar < $firstdaytoshow || 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 // This record is out of visible range
unset($event); unset($event);
} else { } else {
//print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; //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 $event->fetch_userassigned(); // This load $event->userassigned
if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; if ($event->date_start_in_calendar < $firstdaytoshow) {
if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); $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 // Add an entry in actionarray for each day
$daycursor = $event->date_start_in_calendar; $daycursor = $event->date_start_in_calendar;
@ -617,7 +715,9 @@ if ($resql)
$j++; $j++;
$daykey += 60 * 60 * 24; $daykey += 60 * 60 * 24;
if ($daykey > $event->date_end_in_calendar) $loop = false; if ($daykey > $event->date_end_in_calendar) {
$loop = false;
}
} while ($loop); } while ($loop);
//print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); //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 // Define theme_datacolor array
$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; $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; 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 $newparam = $param; // newparam is for birthday links
@ -681,8 +782,7 @@ echo "</tr>\n";
echo '<tr class="liste_titre">'; echo '<tr class="liste_titre">';
echo '<td></td>'; echo '<td></td>';
$i = 0; $i = 0;
for ($h = $begin_d; $h < $end_d; $h++) for ($h = $begin_d; $h < $end_d; $h++) {
{
echo '<td class="center">'; echo '<td class="center">';
print '<small style="font-family: courier">'.sprintf("%02d", $h).'</small>'; print '<small style="font-family: courier">'.sprintf("%02d", $h).'</small>';
print "</td>"; print "</td>";
@ -698,8 +798,7 @@ $colorsbytype = array();
$labelbytype = array(); $labelbytype = array();
$sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; $sql = "SELECT code, color, libelle as label FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position";
$resql = $db->query($sql); $resql = $db->query($sql);
while ($obj = $db->fetch_object($resql)) while ($obj = $db->fetch_object($resql)) {
{
$typeofevents[$obj->code] = $obj->code; $typeofevents[$obj->code] = $obj->code;
$colorsbytype[$obj->code] = $obj->color; $colorsbytype[$obj->code] = $obj->color;
$labelbytype[$obj->code] = $obj->label; $labelbytype[$obj->code] = $obj->label;
@ -710,8 +809,7 @@ $todayarray = dol_getdate($now, 'fast');
$sav = $tmpday; $sav = $tmpday;
$showheader = true; $showheader = true;
$var = false; $var = false;
foreach ($typeofevents as $typeofevent) foreach ($typeofevents as $typeofevent) {
{
$var = !$var; $var = !$var;
echo "<tr>"; echo "<tr>";
echo '<td class="cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">'.$typeofevent.'</td>'; 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 // Lopp on each day of week
$i = 0; $i = 0;
for ($iter_day = 0; $iter_day < 8; $iter_day++) for ($iter_day = 0; $iter_day < 8; $iter_day++) {
{ if (($i + 1) < $begin_d || ($i + 1) > $end_d) {
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
{
$i++; $i++;
continue; continue;
} }
@ -735,10 +831,16 @@ foreach ($typeofevents as $typeofevent)
$tmpyear = $tmparray['year']; $tmpyear = $tmparray['year'];
$style = 'cal_current_month'; $style = 'cal_current_month';
if ($iter_day == 6) $style .= ' cal_other_month'; if ($iter_day == 6) {
$style .= ' cal_other_month';
}
$today = 0; $today = 0;
if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) {
if ($today) $style = 'cal_today_peruser'; $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); 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 "</table>\n";
echo "<br>"; echo "<br>";
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
{
$langs->load("commercial"); $langs->load("commercial");
print '<br>'.$langs->trans("Legend").': <br>'; print '<br>'.$langs->trans("Legend").': <br>';
foreach ($colorsbytype as $code => $color) foreach ($colorsbytype as $code => $color) {
{ if ($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 '<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 $langs->trans("Action".$code) != "Action".$code ? $langs->trans("Action".$code) : $labelbytype[$code];
//print $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); //if ($username->id && $day==1) var_dump($eventarray);
// We are in a particular day for $username, now we scan all events // 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'); $annee = dol_print_date($daykey, '%Y');
$mois = dol_print_date($daykey, '%m'); $mois = dol_print_date($daykey, '%m');
$jour = dol_print_date($daykey, '%d'); $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 // 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"; //print $daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."<br>\n";
//var_dump($event); //var_dump($event);
$keysofuserassigned = array_keys($event->userassigned); $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 //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks $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); $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar);
// Define $color (Hex string like '0088FF') and $cssclass of event // Define $color (Hex string like '0088FF') and $cssclass of event
$color = -1; $cssclass = ''; $colorindex = -1; $color = -1; $cssclass = ''; $colorindex = -1;
if (in_array($user->id, $keysofuserassigned)) if (in_array($user->id, $keysofuserassigned)) {
{
$nummytasks++; $cssclass = 'family_mytasks'; $nummytasks++; $cssclass = 'family_mytasks';
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
} elseif ($event->type_code == 'ICALEVENT') $color = $event->type_color;
{ }
} elseif ($event->type_code == 'ICALEVENT') {
$numical++; $numical++;
if (!empty($event->icalname)) if (!empty($event->icalname)) {
{
if (!isset($numicals[dol_string_nospecial($event->icalname)])) { if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
$numicals[dol_string_nospecial($event->icalname)] = 0; $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; $color = $event->icalcolor;
$cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable'); $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]); $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 { } else {
$numother++; $cssclass = 'family_other'; $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 // Define color index if not yet defined
$idusertouse = ($event->userownerid ? $event->userownerid : 0); $idusertouse = ($event->userownerid ? $event->userownerid : 0);
if (isset($colorindexused[$idusertouse])) if (isset($colorindexused[$idusertouse])) {
{
$colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user
} else { } else {
$colorindex = $nextindextouse; $colorindex = $nextindextouse;
$colorindexused[$idusertouse] = $colorindex; $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 // Define color
$color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); $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; //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd;
// Define all rects with event (cases1 is first half hour, cases2 is second half hour) // 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; //if ($username->id == 1 && $day==1) print 'h='.$h;
$newcolor = ''; //init $newcolor = ''; //init
if (empty($event->fulldayevent)) if (empty($event->fulldayevent)) {
{
$a = dol_mktime((int) $h, 0, 0, $month, $day, $year, 'tzuserrel', 0); $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, 'tzuserrel', 0);
$b = dol_mktime((int) $h, 30, 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); $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, 'tzuserrel', 0);
$dateendtouse = $event->date_end_in_calendar; $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>'; //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; $busy = $event->transparency;
$cases1[$h][$event->id]['busy'] = $busy; $cases1[$h][$event->id]['busy'] = $busy;
$cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel'); $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); $tmpa = dol_getdate($event->date_start_in_calendar, true);
$tmpb = dol_getdate($event->date_end_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'); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); $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]['typecode'] = $event->type_code;
$cases1[$h][$event->id]['color'] = $color; $cases1[$h][$event->id]['color'] = $color;
if ($event->fk_project > 0) if ($event->fk_project > 0) {
{ if (empty($cacheprojects[$event->fk_project])) {
if (empty($cacheprojects[$event->fk_project]))
{
$tmpproj = new Project($db); $tmpproj = new Project($db);
$tmpproj->fetch($event->fk_project); $tmpproj->fetch($event->fk_project);
$cacheprojects[$event->fk_project] = $tmpproj; $cacheprojects[$event->fk_project] = $tmpproj;
} }
$cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; $cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
} }
if ($event->socid > 0) if ($event->socid > 0) {
{ if (empty($cachethirdparties[$event->socid])) {
if (empty($cachethirdparties[$event->socid]))
{
$tmpthirdparty = new Societe($db); $tmpthirdparty = new Societe($db);
$tmpthirdparty->fetch($event->socid); $tmpthirdparty->fetch($event->socid);
$cachethirdparties[$event->socid] = $tmpthirdparty; $cachethirdparties[$event->socid] = $tmpthirdparty;
} }
$cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name; $cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
} }
if ($event->contact_id > 0) if ($event->contact_id > 0) {
{ if (empty($cachecontacts[$event->contact_id])) {
if (empty($cachecontacts[$event->contact_id]))
{
$tmpcontact = new Contact($db); $tmpcontact = new Contact($db);
$tmpcontact->fetch($event->contact_id); $tmpcontact->fetch($event->contact_id);
$cachecontacts[$event->contact_id] = $tmpcontact; $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); $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; $busy = $event->transparency;
$cases2[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['busy'] = $busy;
$cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel'); $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); $tmpa = dol_getdate($event->date_start_in_calendar, true);
$tmpb = dol_getdate($event->date_end_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'); if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); $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]['typecode'] = $event->type_code;
$cases2[$h][$event->id]['color'] = $color; $cases2[$h][$event->id]['color'] = $color;
if ($event->fk_project > 0) if ($event->fk_project > 0) {
{ if (empty($cacheprojects[$event->fk_project])) {
if (empty($cacheprojects[$event->fk_project]))
{
$tmpproj = new Project($db); $tmpproj = new Project($db);
$tmpproj->fetch($event->fk_project); $tmpproj->fetch($event->fk_project);
$cacheprojects[$event->fk_project] = $tmpproj; $cacheprojects[$event->fk_project] = $tmpproj;
} }
$cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; $cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title;
} }
if ($event->socid > 0) if ($event->socid > 0) {
{ if (empty($cachethirdparties[$event->socid])) {
if (empty($cachethirdparties[$event->socid]))
{
$tmpthirdparty = new Societe($db); $tmpthirdparty = new Societe($db);
$tmpthirdparty->fetch($event->socid); $tmpthirdparty->fetch($event->socid);
$cachethirdparties[$event->socid] = $tmpthirdparty; $cachethirdparties[$event->socid] = $tmpthirdparty;
} }
$cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name; $cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name;
} }
if ($event->contact_id > 0) if ($event->contact_id > 0) {
{ if (empty($cachecontacts[$event->contact_id])) {
if (empty($cachecontacts[$event->contact_id]))
{
$tmpcontact = new Contact($db); $tmpcontact = new Contact($db);
$tmpcontact->fetch($event->contact_id); $tmpcontact->fetch($event->contact_id);
$cachecontacts[$event->contact_id] = $tmpcontact; $cachecontacts[$event->contact_id] = $tmpcontact;
@ -1056,63 +1150,83 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s
} }
// Now output $casesX // Now output $casesX
for ($h = $begin_h; $h < $end_h; $h++) for ($h = $begin_h; $h < $end_h; $h++) {
{
$color1 = ''; $color2 = ''; $color1 = ''; $color2 = '';
$style1 = ''; $style2 = ''; $style1 = ''; $style2 = '';
$string1 = '&nbsp;'; $string2 = '&nbsp;'; $string1 = '&nbsp;'; $string2 = '&nbsp;';
$title1 = ''; $title2 = ''; $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")); //$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;'; $string1 = '&nbsp;';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 = 'peruser_notbusy'; if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
else $style1 = 'peruser_busy'; $style1 = 'peruser_notbusy';
foreach ($cases1[$h] as $id => $ev) } else {
{ $style1 = 'peruser_busy';
if ($ev['busy']) $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")); //$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;'; $string2 = '&nbsp;';
if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 = 'peruser_notbusy'; if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
else $style2 = 'peruser_busy'; $style2 = 'peruser_notbusy';
foreach ($cases2[$h] as $id => $ev) } else {
{ $style2 = 'peruser_busy';
if ($ev['busy']) $style2 = 'peruser_busy'; }
foreach ($cases2[$h] as $id => $ev) {
if ($ev['busy']) {
$style2 = 'peruser_busy';
}
} }
} }
$ids1 = ''; $ids2 = ''; $ids1 = ''; $ids2 = '';
if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); if (count($cases1[$h]) && array_keys($cases1[$h])) {
if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$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' : '').'">'; if ($h == $begin_h) {
else echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">';
if (count($cases1[$h]) == 1) // only 1 event } 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); $output = array_slice($cases1[$h], 0, 1);
$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; if ($output[0]['string']) {
if ($output[0]['color']) $color1 = $output[0]['color']; $title1 .= ($title1 ? ' - ' : '').$output[0]['string'];
} elseif (count($cases1[$h]) > 1) }
{ if ($output[0]['color']) {
$color1 = $output[0]['color'];
}
} elseif (count($cases1[$h]) > 1) {
$title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : '');
$color1 = '222222'; $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); $output = array_slice($cases2[$h], 0, 1);
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; if ($output[0]['string']) {
if ($output[0]['color']) $color2 = $output[0]['color']; $title2 .= ($title2 ? ' - ' : '').$output[0]['string'];
} elseif (count($cases2[$h]) > 1) }
{ if ($output[0]['color']) {
$color2 = $output[0]['color'];
}
} elseif (count($cases2[$h]) > 1) {
$title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : '');
$color2 = '222222'; $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'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "a.datep"; $sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "a.datep";
}
// Security check // Security check
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'agenda', $socid, '', 'myactions'); $result = restrictedArea($user, 'agenda', $socid, '', 'myactions');
@ -57,12 +65,10 @@ $result = restrictedArea($user, 'agenda', $socid, '', 'myactions');
* Actions * Actions
*/ */
if ($action == 'builddoc') if ($action == 'builddoc') {
{
$cat = new CommActionRapport($db, $month, $year); $cat = new CommActionRapport($db, $month, $year);
$result = $cat->write_file(GETPOST('id', 'int')); $result = $cat->write_file(GETPOST('id', 'int'));
if ($result < 0) if ($result < 0) {
{
setEventMessages($cat->error, $cat->errors, 'errors'); 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"; $sql .= " ORDER BY year DESC, month DESC, df DESC";
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $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; $page = 0;
$offset = 0; $offset = 0;
} }
@ -105,15 +109,18 @@ $sql .= $db->plimit($limit + 1, $offset);
//print $sql; //print $sql;
dol_syslog("select", LOG_DEBUG); dol_syslog("select", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$param = ''; $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"].'">'; 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="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" 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 '<td class="center">'.$langs->trans("Size").'</td>';
print "</tr>\n"; print "</tr>\n";
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) if ($obj) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Date // Date
@ -161,10 +166,11 @@ if ($resql)
$file = $conf->agenda->dir_temp."/".$name; $file = $conf->agenda->dir_temp."/".$name;
$modulepart = 'actionsreport'; $modulepart = 'actionsreport';
$documenturl = DOL_URL_ROOT.'/document.php'; $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 '<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>'; //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 // Show file name with link to download
$out .= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param ? '&'.$param : '').'"'; $out .= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
$mime = dol_mimetype($relativepath, '', 0); $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 .= ' target="_blank">';
$out .= img_mime($filearray["name"], $langs->trans("File").': '.$filearray["name"]); $out .= img_mime($filearray["name"], $langs->trans("File").': '.$filearray["name"]);
$out .= $filearray["name"]; $out .= $filearray["name"];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -77,7 +77,6 @@ if ($object->fetch($id) >= 0) {
dol_print_object_info($object, 0); dol_print_object_info($object, 0);
//print '</td></tr></table>'; //print '</td></tr></table>';
print dol_get_fiche_end(); 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; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "m.date_creat"; $sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "m.date_creat";
}
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $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"); $search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha");
@ -70,21 +76,25 @@ $fieldstosearchall = array(
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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 // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // 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) /*foreach($object->fields as $key => $val)
{ {
$search[$key]=''; $search[$key]='';
@ -95,8 +105,7 @@ if (empty($reshook))
$search_array_options = array(); $search_array_options = array();
} }
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') 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 $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 .= " 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 .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
$sql .= " AND mc.email = '".$db->escape($filteremail)."'"; $sql .= " AND mc.email = '".$db->escape($filteremail)."'";
if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; if ($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)."%')"; $sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
if (!$sortorder) $sortorder = "ASC"; }
if (!$sortfield) $sortfield = "m.rowid"; 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 { } 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 = "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 .= " FROM ".MAIN_DB_PREFIX."mailing as m";
$sql .= " WHERE m.entity = ".$conf->entity; $sql .= " WHERE m.entity = ".$conf->entity;
if ($search_ref) $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; if ($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)."%')"; $sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
if (!$sortorder) $sortorder = "ASC"; }
if (!$sortfield) $sortfield = "m.rowid"; 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); $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $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; $page = 0;
$offset = 0; $offset = 0;
} }
@ -158,28 +181,36 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("comm/mailing/list.php", LOG_DEBUG); dol_syslog("comm/mailing/list.php", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$title = $langs->trans("ListOfEMailings"); $title = $langs->trans("ListOfEMailings");
if ($filteremail) $title .= ' ('.$langs->trans("SentTo", $filteremail).')'; if ($filteremail) {
$title .= ' ('.$langs->trans("SentTo", $filteremail).')';
}
$newcardbutton = ''; $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'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create');
} }
$i = 0; $i = 0;
$param = "&search_all=".urlencode($search_all); $param = "&search_all=".urlencode($search_all);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($filteremail) $param .= '&filteremail='.urlencode($filteremail); }
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"].'">'; 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="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; 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 '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).'">';
print '</td>'; print '</td>';
print '<td class="liste_titre">&nbsp;</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">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre maxwidthsearch">'; 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("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("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); 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) {
if (!$filteremail) print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $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("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("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_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
@ -224,8 +262,7 @@ if ($resql)
$email = new Mailing($db); $email = new Mailing($db);
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$email->id = $obj->rowid; $email->id = $obj->rowid;
@ -246,8 +283,7 @@ if ($resql)
print '</td>'; print '</td>';
// Nb of email // Nb of email
if (!$filteremail) if (!$filteremail) {
{
print '<td class="center">'; print '<td class="center">';
$nbemail = $obj->nbemail; $nbemail = $obj->nbemail;
/*if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) /*if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
@ -269,8 +305,7 @@ if ($resql)
// Status // Status
print '<td class="nowrap right">'; print '<td class="nowrap right">';
if ($filteremail) if ($filteremail) {
{
print $email::libStatutDest($obj->sendstatut, 2); print $email::libStatutDest($obj->sendstatut, 2);
} else { } else {
print $email->LibStatut($obj->statut, 5); print $email->LibStatut($obj->statut, 5);
@ -284,7 +319,9 @@ if ($resql)
} }
if (empty($num)) { if (empty($num)) {
$colspan = 6; $colspan = 6;
if (!$filteremail) $colspan++; if (!$filteremail) {
$colspan++;
}
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; 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'); $id = GETPOST('id', 'int');
$_socid = GETPOST("id", 'int'); $_socid = GETPOST("id", 'int');
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
{
$_socid = $user->socid; $_socid = $user->socid;
} }
@ -43,8 +42,7 @@ if ($user->socid > 0)
* Actions * Actions
*/ */
if ($_POST["action"] == 'setpricelevel') if ($_POST["action"] == 'setpricelevel') {
{
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($id); $soc->fetch($id);
$soc->set_price_level($_POST["price_level"], $user); $soc->set_price_level($_POST["price_level"], $user);
@ -62,8 +60,7 @@ llxHeader();
$userstatic = new User($db); $userstatic = new User($db);
if ($_socid > 0) if ($_socid > 0) {
{
// We load data of thirdparty // We load data of thirdparty
$objsoc = new Societe($db); $objsoc = new Societe($db);
$objsoc->id = $_socid; $objsoc->id = $_socid;
@ -73,8 +70,12 @@ if ($_socid > 0)
$head = societe_prepare_head($objsoc); $head = societe_prepare_head($objsoc);
$tabchoice = ''; $tabchoice = '';
if ($objsoc->client == 1) $tabchoice = 'customer'; if ($objsoc->client == 1) {
if ($objsoc->client == 2) $tabchoice = 'prospect'; $tabchoice = 'customer';
}
if ($objsoc->client == 2) {
$tabchoice = 'prospect';
}
print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">'; print '<form method="POST" action="multiprix.php?id='.$objsoc->id.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
@ -90,14 +91,16 @@ if ($_socid > 0)
print '<tr><td>'; print '<tr><td>';
print $langs->trans("NewValue").'</td><td>'; print $langs->trans("NewValue").'</td><td>';
print '<select name="price_level" class="flat">'; 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.'"'; print '<option value="'.$i.'"';
if ($i == $objsoc->price_level) if ($i == $objsoc->price_level) {
print 'selected'; print 'selected';
}
print '>'.$i; print '>'.$i;
$keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$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 '</option>';
} }
print '</select>'; print '</select>';
@ -125,8 +128,7 @@ if ($_socid > 0)
$sql .= " ORDER BY rc.datec DESC"; $sql .= " ORDER BY rc.datec DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
$tag = !$tag; $tag = !$tag;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -137,8 +139,7 @@ if ($_socid > 0)
$i = 0; $i = 0;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; 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 // If the internal user must only see his customers, force searching by him
$search_sale = 0; $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"; $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"; $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').')'; $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 ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; $sql .= " AND t.fk_soc = sc.fk_soc";
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale }
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 // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0) {
{
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters) {
{ if (!DolibarrApi::_checkFilters($sqlfilters)) {
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@ -192,8 +201,7 @@ class Proposals extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0) {
{
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
@ -204,13 +212,11 @@ class Proposals extends DolibarrApi
dol_syslog("API Rest request"); dol_syslog("API Rest request");
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0; $i = 0;
while ($i < $min) while ($i < $min) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$proposal_static = new Propal($this->db); $proposal_static = new Propal($this->db);
if ($proposal_static->fetch($obj->rowid)) { if ($proposal_static->fetch($obj->rowid)) {
@ -247,12 +253,12 @@ class Proposals extends DolibarrApi
$this->propal->$field = $value; $this->propal->$field = $value;
} }
/*if (isset($request_data["lines"])) { /*if (isset($request_data["lines"])) {
$lines = array(); $lines = array();
foreach ($request_data["lines"] as $line) { foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line); array_push($lines, (object) $line);
} }
$this->propal->lines = $lines; $this->propal->lines = $lines;
}*/ }*/
if ($this->propal->create(DolibarrApiAccess::$user) < 0) { if ($this->propal->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors)); 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) public function postLine($id, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->propal->creer) { if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->propal->fetch($id); $result = $this->propal->fetch($id);
@ -319,32 +325,32 @@ class Proposals extends DolibarrApi
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->propal->addline( $updateRes = $this->propal->addline(
$request_data->desc, $request_data->desc,
$request_data->subprice, $request_data->subprice,
$request_data->qty, $request_data->qty,
$request_data->tva_tx, $request_data->tva_tx,
$request_data->localtax1_tx, $request_data->localtax1_tx,
$request_data->localtax2_tx, $request_data->localtax2_tx,
$request_data->fk_product, $request_data->fk_product,
$request_data->remise_percent, $request_data->remise_percent,
'HT', 'HT',
0, 0,
$request_data->info_bits, $request_data->info_bits,
$request_data->product_type, $request_data->product_type,
$request_data->rang, $request_data->rang,
$request_data->special_code, $request_data->special_code,
$request_data->fk_parent_line, $request_data->fk_parent_line,
$request_data->fk_fournprice, $request_data->fk_fournprice,
$request_data->pa_ht, $request_data->pa_ht,
$request_data->label, $request_data->label,
$request_data->date_start, $request_data->date_start,
$request_data->date_end, $request_data->date_end,
$request_data->array_options, $request_data->array_options,
$request_data->fk_unit, $request_data->fk_unit,
$request_data->origin, $request_data->origin,
$request_data->origin_id, $request_data->origin_id,
$request_data->multicurrency_subprice, $request_data->multicurrency_subprice,
$request_data->fk_remise_except $request_data->fk_remise_except
); );
if ($updateRes > 0) { if ($updateRes > 0) {
@ -378,15 +384,15 @@ class Proposals extends DolibarrApi
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); 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); $propalline = new PropaleLigne($this->db);
$result = $propalline->fetch($lineid); $result = $propalline->fetch($lineid);
if ($result <= 0) { if ($result <= 0) {
throw new RestException(404, 'Proposal line not found'); throw new RestException(404, 'Proposal line not found');
} }
$updateRes = $this->propal->updateline( $updateRes = $this->propal->updateline(
$lineid, $lineid,
@ -572,25 +578,23 @@ class Proposals extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') {
continue;
}
$this->propal->$field = $value; $this->propal->$field = $value;
} }
// update end of validity date // 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); $this->propal->fin_validite = $this->propal->date_creation + ($this->propal->duree_validite * 24 * 3600);
} }
if (!empty($this->propal->fin_validite)) if (!empty($this->propal->fin_validite)) {
{ if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0) {
if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0)
{
throw new RestException(500, $this->propal->error); 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); return $this->get($id);
} else { } else {
throw new RestException(500, $this->propal->error); throw new RestException(500, $this->propal->error);
@ -834,8 +838,9 @@ class Proposals extends DolibarrApi
{ {
$propal = array(); $propal = array();
foreach (Proposals::$FIELDS as $field) { foreach (Proposals::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field])) {
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
}
$propal[$field] = $data[$field]; $propal[$field] = $data[$field];
} }
return $propal; 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->userid = $userid;
$this->join = ''; $this->join = '';
if ($mode == 'customer') if ($mode == 'customer') {
{
$object = new Propal($this->db); $object = new Propal($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from = MAIN_DB_PREFIX.$object->table_element." as p";
@ -81,8 +80,7 @@ class PropaleStats extends Stats
//$this->where .= " p.fk_statut > 0"; //$this->where .= " p.fk_statut > 0";
} }
if ($mode == 'supplier') if ($mode == 'supplier') {
{
$object = new SupplierProposal($this->db); $object = new SupplierProposal($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $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.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity;
$this->where .= ($this->where ? ' AND ' : '')."p.entity IN (".getEntity('propal').")"; $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 (!$user->rights->societe->client->voir && !$this->socid) {
if ($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; $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->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
$this->where .= ' AND s.fk_typent = '.$typentid; $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_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->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie';
$this->where .= ' AND c.rowid = '.$categid; $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 = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from; $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 .= $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 .= " 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; $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 = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from; $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 .= $this->join;
$sql .= " WHERE ".$this->where; $sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm"; $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 = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")";
$sql .= " FROM ".$this->from; $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 .= $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 .= " 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; $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 = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")";
$sql .= " FROM ".$this->from; $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 .= $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 .= " 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; $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 = "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; $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 .= $this->join;
$sql .= " WHERE ".$this->where; $sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year"; $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 = "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"; $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 .= $this->join;
$sql .= " WHERE ".$this->where; $sql .= " WHERE ".$this->where;
$sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; $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'); $action = GETPOST('action', 'aZ09');
// Security check // Security check
if ($user->socid) $socid = $user->socid; if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'propal', $id); $result = restrictedArea($user, 'propal', $id);
$object = new Propal($db); $object = new Propal($db);
// Load object // Load object
if ($id > 0 || !empty($ref)) if ($id > 0 || !empty($ref)) {
{
$ret = $object->fetch($id, $ref); $ret = $object->fetch($id, $ref);
if ($ret == 0) if ($ret == 0) {
{
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
$error++; $error++;
} elseif ($ret < 0) } elseif ($ret < 0) {
{
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }
if (!$error) if (!$error) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
} else { } else {
header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php');
@ -74,42 +72,34 @@ if (!$error)
* Add a new contact * Add a new contact
*/ */
if ($action == 'addcontact' && $user->rights->propale->creer) if ($action == 'addcontact' && $user->rights->propale->creer) {
{ if ($object->id > 0) {
if ($object->id > 0)
{
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
} }
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
{
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} // Toggle the status of a contact } elseif ($action == 'swapstatut' && $user->rights->propale->creer) {
elseif ($action == 'swapstatut' && $user->rights->propale->creer) // Toggle the status of a contact
{ if ($object->id > 0) {
if ($object->id > 0)
{
$result = $object->swapContactStatus(GETPOST('ligne')); $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); $result = $object->delete_contact($lineid);
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
@ -134,8 +124,7 @@ $form = new Form($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
$formother = new FormOther($db); $formother = new FormOther($db);
if ($object->id > 0) if ($object->id > 0) {
{
$head = propal_prepare_head($object); $head = propal_prepare_head($object);
print dol_get_fiche_head($head, 'contact', $langs->trans("Proposal"), -1, 'propal'); print dol_get_fiche_head($head, 'contact', $langs->trans("Proposal"), -1, 'propal');
@ -152,12 +141,10 @@ if ($object->id > 0)
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer');
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->propal->creer) if ($user->rights->propal->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
@ -194,10 +181,11 @@ if ($object->id > 0)
// Contacts lines (modules that overwrite templates must declare this into descriptor) // Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); $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'); $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 // Load translation files required by the page
$langs->loadLangs(array('compta', 'other', 'companies')); $langs->loadLangs(array('compta', 'other', 'companies'));
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
// Security check // Security check
$socid = ''; $socid = '';
if (!empty($user->socid)) if (!empty($user->socid)) {
{
$socid = $user->socid; $socid = $user->socid;
} }
$result = restrictedArea($user, 'propal', $id); $result = restrictedArea($user, 'propal', $id);
@ -57,16 +56,26 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $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_FIELD)) {
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; } $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 (!$sortorder) {
if (!$sortfield) $sortfield = "name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new Propal($db); $object = new Propal($db);
$object->fetch($id, $ref); $object->fetch($id, $ref);
@ -76,8 +85,7 @@ $object->fetch($id, $ref);
* Actions * Actions
*/ */
if ($object->id > 0) if ($object->id > 0) {
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; 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); $form = new Form($db);
if ($object->id > 0) if ($object->id > 0) {
{
$upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$head = propal_prepare_head($object); $head = propal_prepare_head($object);
@ -102,8 +109,7 @@ if ($object->id > 0)
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0; $totalsize = 0;
foreach ($filearray as $key => $file) foreach ($filearray as $key => $file) {
{
$totalsize += $file['size']; $totalsize += $file['size'];
} }
@ -120,12 +126,10 @@ if ($object->id > 0)
// Thirdparty // Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer');
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->propal->creer) if ($user->rights->propal->creer) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

View File

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

View File

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

View File

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

View File

@ -44,16 +44,16 @@ $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1)
$total = 0; $total = 0;
$ilink = 0; $ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink) foreach ($linkedObjectBlock as $key => $objectlink) {
{
$ilink++; $ilink++;
$trclass = 'oddeven'; $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 '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
print '<td class="linkedcol-element" >'.$langs->trans("Proposal"); 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; $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>'; 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 '<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"; print "</tr>\n";
} }
if (count($linkedObjectBlock) > 1) if (count($linkedObjectBlock) > 1) {
{
print '<tr class="liste_total '.(empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : '').'">'; print '<tr class="liste_total '.(empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : '').'">';
print '<td>'.$langs->trans("Total").'</td>'; print '<td>'.$langs->trans("Total").'</td>';
print '<td></td>'; print '<td></td>';

View File

@ -36,7 +36,6 @@ if ($user->socid > 0) {
} }
/* /*
* View * 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 // Load translation files required by the page
$langs->loadLangs(array('companies', 'other')); $langs->loadLangs(array('companies', 'other'));
if (!empty($conf->facture->enabled)) $langs->load("bills"); if (!empty($conf->facture->enabled)) {
$langs->load("bills");
}
// Security check // Security check
$socid = $_GET["socid"]; $socid = $_GET["socid"];
if ($user->socid > 0) if ($user->socid > 0) {
{
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
/* /*
* View * View
*/ */
llxHeader(); llxHeader();
if ($socid > 0) if ($socid > 0) {
{
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($socid); $societe->fetch($socid);
/* /*
* Affichage onglets * Affichage onglets
*/ */
$head = societe_prepare_head($societe); $head = societe_prepare_head($societe);
print dol_get_fiche_head($head, 'prospect', $langs->trans("ThirdParty"), 0, 'company'); 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>'; print '<tr><td width="20%">'.$langs->trans("Thirdpary").'</td><td width="80%" colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
// Prefix // 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 '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
print ($societe->prefix_comm ? $societe->prefix_comm : '&nbsp;'); print ($societe->prefix_comm ? $societe->prefix_comm : '&nbsp;');
print '</td></tr>'; print '</td></tr>';
@ -84,7 +82,7 @@ if ($socid > 0)
print $langs->trans("FeatureNotYetAvailable"); print $langs->trans("FeatureNotYetAvailable");
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
// End of page // 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 // Load translation files required by the page
$langs->load("companies"); $langs->load("companies");
if (!empty($conf->facture->enabled)) $langs->load("bills"); if (!empty($conf->facture->enabled)) {
$langs->load("bills");
}
// Security check // Security check
$socid = $_GET["socid"]; $socid = $_GET["socid"];
if ($user->socid > 0) if ($user->socid > 0) {
{
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
@ -46,14 +47,13 @@ if ($user->socid > 0)
llxHeader(); llxHeader();
if ($socid > 0) if ($socid > 0) {
{
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($socid); $societe->fetch($socid);
/* /*
* Affichage onglets * Affichage onglets
*/ */
$head = societe_prepare_head($societe); $head = societe_prepare_head($societe);
print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); 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>'; print '<tr><td width="20%">'.$langs->trans("ThirdParty").'</td><td width="80%" colspan="3">'.$societe->getNomUrl(1).'</td></tr>';
// Prefix // 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 '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
print ($societe->prefix_comm ? $societe->prefix_comm : '&nbsp;'); print ($societe->prefix_comm ? $societe->prefix_comm : '&nbsp;');
print '</td></tr>'; print '</td></tr>';
@ -84,7 +83,7 @@ if ($socid > 0)
print $langs->trans("FeatureNotYetAvailable"); print $langs->trans("FeatureNotYetAvailable");
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
// End of page // End of page

View File

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

View File

@ -40,8 +40,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
// Security check // Security check
$socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); $socid = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int');
if ($user->socid > 0) if ($user->socid > 0) {
{
$socid = $user->socid; $socid = $user->socid;
} }
@ -50,14 +49,12 @@ if ($user->socid > 0)
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
{
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; 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->societe->creer)
//if ($user->rights->facture->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); $remid = (GETPOST("remid", 'int') ? GETPOST("remid", 'int') : 0);
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$res = $discount->fetch($remid); $res = $discount->fetch($remid);
if (!($res > 0)) if (!($res > 0)) {
{
$error++; $error++;
setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); 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++; $error++;
setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors');
} }
if (!$error && $discount->fk_facture_line) if (!$error && $discount->fk_facture_line) {
{
$error++; $error++;
setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors'); setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors');
} }
if (!$error) if (!$error) {
{
$newdiscount1 = new DiscountAbsolute($db); $newdiscount1 = new DiscountAbsolute($db);
$newdiscount2 = new DiscountAbsolute($db); $newdiscount2 = new DiscountAbsolute($db);
$newdiscount1->fk_facture_source = $discount->fk_facture_source; $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; $newdiscount2->fk_invoice_supplier = $discount->fk_invoice_supplier;
$newdiscount1->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line; $newdiscount1->fk_invoice_supplier_line = $discount->fk_invoice_supplier_line;
$newdiscount2->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; $newdiscount1->description = $discount->description;
$newdiscount2->description = $discount->description; $newdiscount2->description = $discount->description;
} else { } else {
@ -143,8 +135,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes')
$res = $discount->delete($user); $res = $discount->delete($user);
$newid1 = $newdiscount1->create($user); $newid1 = $newdiscount1->create($user);
$newid2 = $newdiscount2->create($user); $newid2 = $newdiscount2->create($user);
if ($res > 0 && $newid1 > 0 && $newid2 > 0) if ($res > 0 && $newid1 > 0 && $newid2 > 0) {
{
$db->commit(); $db->commit();
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage ? '&backtopage='.urlencode($backtopage) : '')); // To avoid pb whith back header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage ? '&backtopage='.urlencode($backtopage) : '')); // To avoid pb whith back
exit; 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->societe->creer)
//if ($user->rights->facture->creer) //if ($user->rights->facture->creer)
@ -164,25 +154,20 @@ if ($action == 'setremise' && $user->rights->societe->creer)
$tva_tx = GETPOST('tva_tx', 'alpha'); $tva_tx = GETPOST('tva_tx', 'alpha');
$discount_type = !empty($_POST['discount_type']) ?GETPOST('discount_type', 'alpha') : 0; $discount_type = !empty($_POST['discount_type']) ?GETPOST('discount_type', 'alpha') : 0;
if ($amount_ht > 0) if ($amount_ht > 0) {
{
$error = 0; $error = 0;
if (empty($desc)) if (empty($desc)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReasonDiscount")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReasonDiscount")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($id); $soc->fetch($id);
$discountid = $soc->set_remise_except($amount_ht, $user, $desc, $tva_tx, $discount_type); $discountid = $soc->set_remise_except($amount_ht, $user, $desc, $tva_tx, $discount_type);
if ($discountid > 0) if ($discountid > 0) {
{ if (!empty($backtopage)) {
if (!empty($backtopage))
{
header("Location: ".$backtopage.'&discountid='.$discountid); header("Location: ".$backtopage.'&discountid='.$discountid);
exit; exit;
} else { } 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->societe->creer)
//if ($user->rights->facture->creer) //if ($user->rights->facture->creer)
@ -209,8 +193,7 @@ if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes'
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$result = $discount->fetch(GETPOST("remid")); $result = $discount->fetch(GETPOST("remid"));
$result = $discount->delete($user); $result = $discount->delete($user);
if ($result > 0) if ($result > 0) {
{
$db->commit(); $db->commit();
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back
exit; exit;
@ -231,8 +214,7 @@ $facturefournstatic = new FactureFournisseur($db);
llxHeader('', $langs->trans("GlobalDiscount")); llxHeader('', $langs->trans("GlobalDiscount"));
if ($socid > 0) if ($socid > 0) {
{
// On recupere les donnees societes par l'objet // On recupere les donnees societes par l'objet
$object = new Societe($db); $object = new Societe($db);
$object->fetch($socid); $object->fetch($socid);
@ -283,11 +265,12 @@ if ($socid > 0)
$sql .= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)"; $sql .= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
$sql .= " GROUP BY rc.fk_user"; $sql .= " GROUP BY rc.fk_user";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$remise_all += $obj->amount; $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 { } else {
dol_print_error($db); dol_print_error($db);
} }
@ -295,8 +278,7 @@ if ($socid > 0)
print '<tr><td class="titlefield">'.$langs->trans("CustomerAbsoluteDiscountAllUsers").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("CustomerAbsoluteDiscountAllUsers").'</td>';
print '<td>'.$remise_all.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>'; 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 '<tr><td>'.$langs->trans("CustomerAbsoluteDiscountMy").'</td>';
print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>'; 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 .= " AND (fk_invoice_supplier_line IS NULL AND fk_invoice_supplier IS NULL)";
$sql .= " GROUP BY rc.fk_user"; $sql .= " GROUP BY rc.fk_user";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$remise_all += $obj->amount; $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 { } else {
dol_print_error($db); dol_print_error($db);
} }
@ -325,8 +308,7 @@ if ($socid > 0)
print '<tr><td class="titlefield">'.$langs->trans("SupplierAbsoluteDiscountAllUsers").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("SupplierAbsoluteDiscountAllUsers").'</td>';
print '<td>'.$remise_all.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>'; 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 '<tr><td>'.$langs->trans("SupplierAbsoluteDiscountMy").'</td>';
print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>'; 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(); print dol_get_fiche_end();
if ($user->rights->societe->creer) if ($user->rights->societe->creer) {
{
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("NewGlobalDiscount"), '', ''); print load_fiche_titre($langs->trans("NewGlobalDiscount"), '', '');
@ -378,12 +359,10 @@ if ($socid > 0)
print dol_get_fiche_end(); print dol_get_fiche_end();
} }
if ($user->rights->societe->creer) if ($user->rights->societe->creer) {
{
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("AddGlobalDiscount").'">'; 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 '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
} }
@ -395,8 +374,7 @@ if ($socid > 0)
print '<br>'; 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); 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"; $sql .= " ORDER BY rc.datec DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -439,14 +416,12 @@ if ($socid > 0)
print '<td>'.$langs->trans("ReasonDiscount").'</td>'; print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>'; print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td class="right">'.$langs->trans("AmountHT").'</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("MulticurrencyAmountHT").'</td>';
} }
print '<td class="right">'.$langs->trans("VATRate").'</td>'; print '<td class="right">'.$langs->trans("VATRate").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</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 class="right">'.$langs->trans("MulticurrencyAmountTTC").'</td>';
} }
print '<td width="100" class="center">'.$langs->trans("DiscountOfferedBy").'</td>'; print '<td width="100" class="center">'.$langs->trans("DiscountOfferedBy").'</td>';
@ -457,32 +432,27 @@ if ($socid > 0)
$i = 0; $i = 0;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0) {
{ while ($i < $num) {
while ($i < $num)
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), 'dayhour').'</td>'; 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">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref; $facturestatic->ref = $obj->ref;
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>'; print '</td>';
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) {
{
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref; $facturestatic->ref = $obj->ref;
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>'; print '</td>';
} elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) {
{
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref; $facturestatic->ref = $obj->ref;
@ -496,30 +466,28 @@ if ($socid > 0)
} }
print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>'; print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>';
print '<td class="right">'.price($obj->amount_ht).'</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">'.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">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</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="right">'.price($obj->multicurrency_amount_ttc).'</td>';
} }
print '<td class="center">'; 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 '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'</a>';
print '</td>'; 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 '<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" 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 '<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>'; print '</td>';
} else print '<td>&nbsp;</td>'; } else {
print '<td>&nbsp;</td>';
}
print '</tr>'; print '</tr>';
if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) {
{
$showconfirminfo['rowid'] = $obj->rowid; $showconfirminfo['rowid'] = $obj->rowid;
$showconfirminfo['amount_ttc'] = $obj->amount_ttc; $showconfirminfo['amount_ttc'] = $obj->amount_ttc;
} }
@ -527,15 +495,16 @@ if ($socid > 0)
} }
} else { } else {
$colspan = 8; $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>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
} }
$db->free($resql); $db->free($resql);
print "</table>"; print "</table>";
print '</div>'; print '</div>';
if (count($showconfirminfo)) if (count($showconfirminfo)) {
{
$amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT');
$amount2 = ($showconfirminfo['amount_ttc'] - $amount1); $amount2 = ($showconfirminfo['amount_ttc'] - $amount1);
$formquestion = array( $formquestion = array(
@ -578,8 +547,7 @@ if ($socid > 0)
$sql .= " ORDER BY rc.datec DESC"; $sql .= " ORDER BY rc.datec DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -587,14 +555,12 @@ if ($socid > 0)
print '<td>'.$langs->trans("ReasonDiscount").'</td>'; print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>'; print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td class="right">'.$langs->trans("AmountHT").'</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("MulticurrencyAmountHT").'</td>';
} }
print '<td class="right">'.$langs->trans("VATRate").'</td>'; print '<td class="right">'.$langs->trans("VATRate").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</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 class="right">'.$langs->trans("MulticurrencyAmountTTC").'</td>';
} }
print '<td width="100" class="center">'.$langs->trans("DiscountOfferedBy").'</td>'; print '<td width="100" class="center">'.$langs->trans("DiscountOfferedBy").'</td>';
@ -605,32 +571,27 @@ if ($socid > 0)
$i = 0; $i = 0;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0) {
{ while ($i < $num) {
while ($i < $num)
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), 'dayhour').'</td>'; 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">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref; $facturefournstatic->ref = $obj->ref;
$facturefournstatic->type = $obj->type; $facturefournstatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>'; print '</td>';
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) {
{
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref; $facturefournstatic->ref = $obj->ref;
$facturefournstatic->type = $obj->type; $facturefournstatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>'; print '</td>';
} elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) } elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) {
{
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref; $facturefournstatic->ref = $obj->ref;
@ -644,30 +605,28 @@ if ($socid > 0)
} }
print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>'; print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>';
print '<td class="right">'.price($obj->amount_ht).'</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">'.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">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</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="right">'.price($obj->multicurrency_amount_ttc).'</td>';
} }
print '<td class="center">'; 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 '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'</a>';
print '</td>'; 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 '<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" 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 '<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>'; print '</td>';
} else print '<td>&nbsp;</td>'; } else {
print '<td>&nbsp;</td>';
}
print '</tr>'; print '</tr>';
if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) {
{
$showconfirminfo['rowid'] = $obj->rowid; $showconfirminfo['rowid'] = $obj->rowid;
$showconfirminfo['amount_ttc'] = $obj->amount_ttc; $showconfirminfo['amount_ttc'] = $obj->amount_ttc;
} }
@ -675,15 +634,16 @@ if ($socid > 0)
} }
} else { } else {
$colspan = 8; $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>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
} }
$db->free($resql); $db->free($resql);
print "</table>"; print "</table>";
print '</div>'; print '</div>';
if (count($showconfirminfo)) if (count($showconfirminfo)) {
{
$amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT');
$amount2 = ($showconfirminfo['amount_ttc'] - $amount1); $amount2 = ($showconfirminfo['amount_ttc'] - $amount1);
$formquestion = array( $formquestion = array(
@ -758,9 +718,10 @@ if ($socid > 0)
$resql = $db->query($sql); $resql = $db->query($sql);
$resql2 = null; $resql2 = null;
if ($resql) $resql2 = $db->query($sql2); if ($resql) {
if ($resql2) $resql2 = $db->query($sql2);
{ }
if ($resql2) {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -768,14 +729,12 @@ if ($socid > 0)
print '<td>'.$langs->trans("ReasonDiscount").'</td>'; print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>'; print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td class="right">'.$langs->trans("AmountHT").'</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("MulticurrencyAmountHT").'</td>';
} }
print '<td class="right">'.$langs->trans("VATRate").'</td>'; print '<td class="right">'.$langs->trans("VATRate").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</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 class="right">'.$langs->trans("MulticurrencyAmountTTC").'</td>';
} }
print '<td width="100" class="center">'.$langs->trans("Author").'</td>'; print '<td width="100" class="center">'.$langs->trans("Author").'</td>';
@ -785,10 +744,8 @@ if ($socid > 0)
$tab_sqlobj = array(); $tab_sqlobj = array();
$tab_sqlobjOrder = array(); $tab_sqlobjOrder = array();
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0) {
{ for ($i = 0; $i < $num; $i++) {
for ($i = 0; $i < $num; $i++)
{
$sqlobj = $db->fetch_object($resql); $sqlobj = $db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj; $tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
@ -797,8 +754,7 @@ if ($socid > 0)
$db->free($resql); $db->free($resql);
$num = $db->num_rows($resql2); $num = $db->num_rows($resql2);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++) {
{
$sqlobj = $db->fetch_object($resql2); $sqlobj = $db->fetch_object($resql2);
$tab_sqlobj[] = $sqlobj; $tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
@ -807,32 +763,27 @@ if ($socid > 0)
array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj); array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj);
$num = count($tab_sqlobj); $num = count($tab_sqlobj);
if ($num > 0) if ($num > 0) {
{
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = array_shift($tab_sqlobj); $obj = array_shift($tab_sqlobj);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), 'dayhour').'</td>'; 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">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->invoice_source_ref; $facturestatic->ref = $obj->invoice_source_ref;
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>'; print '</td>';
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) {
{
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->invoice_source_ref; $facturestatic->ref = $obj->invoice_source_ref;
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>'; print '</td>';
} elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) {
{
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->invoice_source_ref; $facturestatic->ref = $obj->invoice_source_ref;
@ -845,20 +796,17 @@ if ($socid > 0)
print '</td>'; print '</td>';
} }
print '<td class="left nowrap">'; 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 '<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>';
print '<td class="right">'.price($obj->amount_ht).'</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">'.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">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</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="right">'.price($obj->multicurrency_amount_ttc).'</td>';
} }
print '<td class="center">'; print '<td class="center">';
@ -870,7 +818,9 @@ if ($socid > 0)
} }
} else { } else {
$colspan = 8; $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>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
} }
@ -928,9 +878,10 @@ if ($socid > 0)
$resql = $db->query($sql); $resql = $db->query($sql);
$resql2 = null; $resql2 = null;
if ($resql) $resql2 = $db->query($sql2); if ($resql) {
if ($resql2) $resql2 = $db->query($sql2);
{ }
if ($resql2) {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -938,14 +889,12 @@ if ($socid > 0)
print '<td>'.$langs->trans("ReasonDiscount").'</td>'; print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>'; print '<td class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td class="right">'.$langs->trans("AmountHT").'</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("MulticurrencyAmountHT").'</td>';
} }
print '<td class="right">'.$langs->trans("VATRate").'</td>'; print '<td class="right">'.$langs->trans("VATRate").'</td>';
print '<td class="right">'.$langs->trans("AmountTTC").'</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 class="right">'.$langs->trans("MulticurrencyAmountTTC").'</td>';
} }
print '<td width="100" class="center">'.$langs->trans("Author").'</td>'; print '<td width="100" class="center">'.$langs->trans("Author").'</td>';
@ -955,10 +904,8 @@ if ($socid > 0)
$tab_sqlobj = array(); $tab_sqlobj = array();
$tab_sqlobjOrder = array(); $tab_sqlobjOrder = array();
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0) {
{ for ($i = 0; $i < $num; $i++) {
for ($i = 0; $i < $num; $i++)
{
$sqlobj = $db->fetch_object($resql); $sqlobj = $db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj; $tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
@ -967,8 +914,7 @@ if ($socid > 0)
$db->free($resql); $db->free($resql);
$num = $db->num_rows($resql2); $num = $db->num_rows($resql2);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++) {
{
$sqlobj = $db->fetch_object($resql2); $sqlobj = $db->fetch_object($resql2);
$tab_sqlobj[] = $sqlobj; $tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc);
@ -977,32 +923,27 @@ if ($socid > 0)
array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj); array_multisort($tab_sqlobjOrder, SORT_DESC, $tab_sqlobj);
$num = count($tab_sqlobj); $num = count($tab_sqlobj);
if ($num > 0) if ($num > 0) {
{
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = array_shift($tab_sqlobj); $obj = array_shift($tab_sqlobj);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc), 'dayhour').'</td>'; 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">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->invoice_source_ref; $facturefournstatic->ref = $obj->invoice_source_ref;
$facturefournstatic->type = $obj->type; $facturefournstatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>'; print '</td>';
} elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) {
{
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->invoice_source_ref; $facturefournstatic->ref = $obj->invoice_source_ref;
$facturefournstatic->type = $obj->type; $facturefournstatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>'; print '</td>';
} elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) } elseif (preg_match('/\(EXCESS PAID\)/', $obj->description)) {
{
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->invoice_source_ref; $facturefournstatic->ref = $obj->invoice_source_ref;
@ -1020,14 +961,12 @@ if ($socid > 0)
} }
print '</td>'; print '</td>';
print '<td class="right">'.price($obj->amount_ht).'</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">'.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">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</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="right">'.price($obj->multicurrency_amount_ttc).'</td>';
} }
print '<td class="center">'; print '<td class="center">';
@ -1039,7 +978,9 @@ if ($socid > 0)
} }
} else { } else {
$colspan = 8; $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>'; 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 * \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_APPLICATION_TITLE')) {
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 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 // Define syslog constants
if (!defined('LOG_DEBUG')) if (!defined('LOG_DEBUG')) {
{
if (!function_exists("syslog")) { if (!function_exists("syslog")) {
// For PHP versions without syslog (like running on Windows OS) // For PHP versions without syslog (like running on Windows OS)
define('LOG_EMERG', 0); define('LOG_EMERG', 0);
@ -52,7 +57,9 @@ if (!defined('LOG_DEBUG'))
} }
// End of common declaration part // End of common declaration part
if (defined('DOL_INC_FOR_VERSION_ERROR')) return; if (defined('DOL_INC_FOR_VERSION_ERROR')) {
return;
}
// Define vars // Define vars
@ -73,15 +80,13 @@ $conffiletoshow = "htdocs/conf/conf.php";
// Include configuration // Include configuration
$result = @include_once $conffile; // Keep @ because with some error reporting this break the redirect done when file not found $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 (!$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 (!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. $path = $_SERVER["CONTEXT_PREFIX"]; // example '/dolibarr/' when using an apache alias.
if (!preg_match('/\/$/', $path)) $path .= '/'; if (!preg_match('/\/$/', $path)) {
} $path .= '/';
elseif (preg_match('/index\.php/', $_SERVER['PHP_SELF'])) }
{ } 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 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. // 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, // 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']); $TDir = explode('/', $_SERVER['PHP_SELF']);
$path = ''; $path = '';
$i = count($TDir); $i = count($TDir);
while ($i--) while ($i--) {
{ if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') {
if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') break; break;
if ($TDir[$i] == 'dolibarr') break; }
if (substr($TDir[$i], -4, 4) == '.php') continue; if ($TDir[$i] == 'dolibarr') {
break;
}
if (substr($TDir[$i], -4, 4) == '.php') {
continue;
}
$path .= '../'; $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) // 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); error_reporting(E_ALL | E_STRICT);
} else { } else {
error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED)); error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
} }
// Disable php display errors // 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 // Clean parameters
$dolibarr_main_data_root = trim($dolibarr_main_data_root); $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 = trim($dolibarr_main_document_root);
$dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ? '' : trim($dolibarr_main_document_root_alt)); $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_port)) {
if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type = 'mysqli'; // For compatibility with old configs, if not defined, we take 'mysql' type $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 // Mysql driver support has been removed in favor of mysqli
if ($dolibarr_main_db_type == 'mysql') $dolibarr_main_db_type = 'mysqli'; if ($dolibarr_main_db_type == 'mysql') {
if (empty($dolibarr_main_db_prefix)) $dolibarr_main_db_prefix = 'llx_'; $dolibarr_main_db_type = 'mysqli';
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_prefix)) {
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; $dolibarr_main_db_prefix = 'llx_';
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; }
if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users = 0; if (empty($dolibarr_main_db_character_set)) {
if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb = 0; $dolibarr_main_db_character_set = ($dolibarr_main_db_type == 'mysqli' ? 'utf8' : ''); // Old installation
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 (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 // Security: CSRF protection
// This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST']) // 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). // 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 // 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. // See also option $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN for a stronger CSRF protection.
if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck)) if (!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck)) {
{ if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST'])) {
if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST']))
{
$csrfattack = false; $csrfattack = false;
if (empty($_SERVER['HTTP_REFERER'])) $csrfattack = true; // An evil browser was used if (empty($_SERVER['HTTP_REFERER'])) {
else { $csrfattack = true; // An evil browser was used
} else {
$tmpa = parse_url($_SERVER['HTTP_HOST']); $tmpa = parse_url($_SERVER['HTTP_HOST']);
$tmpb = parse_url($_SERVER['HTTP_REFERER']); $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']; //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. // 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"; 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. // 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 '<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"; print '<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'."\n";
die; 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 '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"; print 'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'."\n";
die; die;
} }
if (empty($dolibarr_main_data_root)) if (empty($dolibarr_main_data_root)) {
{
// Si repertoire documents non defini, on utilise celui par defaut // 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 = str_replace("/htdocs", "", $dolibarr_main_document_root);
$dolibarr_main_data_root .= "/documents"; $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 $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. // 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 = ''; $concatpath = '';
foreach ($paths as $tmppath) // We check to find (B+start of C)=A foreach ($paths as $tmppath) { // We check to find (B+start of C)=A
{ if (empty($tmppath)) {
if (empty($tmppath)) continue; continue;
}
$concatpath .= '/'.$tmppath; $concatpath .= '/'.$tmppath;
//if ($tmppath) $concatpath.='/'.$tmppath; //if ($tmppath) $concatpath.='/'.$tmppath;
//print $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).'<br>'; //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; //print "Found relative url = ".$concatpath;
$tmp3 = $concatpath; $tmp3 = $concatpath;
$found = 1; $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"; //else print "Not found yet for concatpath=".$concatpath."<br>\n";
} }
//print "found=".$found." dolibarr_main_url_root=".$dolibarr_main_url_root."\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). if (!$found) {
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 : ''); $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"; //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, ...) 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* $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 $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', ...) define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
//print DOL_MAIN_URL_ROOT.'-'.DOL_URL_ROOT."\n"; //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. * To use other version than embeded libraries, define here constant to path. Use '' to use include class path autodetect.
*/ */
// Path to root libraries // 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('ADODB_PATH')) {
if (!defined('TCPDF_PATH')) { define('TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_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('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('TCPDF_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.'/')); } define('TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_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('TCPDI_PATH')) {
if (!defined('JS_CKEDITOR')) { define('JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ? '' : (empty($dolibarr_js_CKEDITOR) ? '' : $dolibarr_js_CKEDITOR.'/')); } define('TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.'/');
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('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 // 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')) {
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)); } 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 * 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 "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"; print "Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
exit; 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(); $conf = new Conf();
// Set properties specific to database // Set properties specific to database
$conf->db->host = $dolibarr_main_db_host; $conf->db->host = $dolibarr_main_db_host;
$conf->db->port = $dolibarr_main_db_port; $conf->db->port = $dolibarr_main_db_port;
$conf->db->name = $dolibarr_main_db_name; $conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user; $conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = empty($dolibarr_main_db_pass) ? '' : $dolibarr_main_db_pass; $conf->db->pass = empty($dolibarr_main_db_pass) ? '' : $dolibarr_main_db_pass;
$conf->db->type = $dolibarr_main_db_type; $conf->db->type = $dolibarr_main_db_type;
$conf->db->prefix = $dolibarr_main_db_prefix; $conf->db->prefix = $dolibarr_main_db_prefix;
$conf->db->character_set = $dolibarr_main_db_character_set; $conf->db->character_set = $dolibarr_main_db_character_set;
$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; $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_encryption = $dolibarr_main_db_encryption;
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; $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 // Set properties specific to conf file
$conf->file->main_limit_users = $dolibarr_main_limit_users; $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->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_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') $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 // dolibarr_main_document_root_alt can contains several directories
$values = preg_split('/[;,]/', $dolibarr_main_document_root_alt); $values = preg_split('/[;,]/', $dolibarr_main_document_root_alt);
$i = 0; $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); $values = preg_split('/[;,]/', $dolibarr_main_url_root_alt);
$i = 0; $i = 0;
foreach ($values as $value) foreach ($values as $value) {
{ if (preg_match('/^http(s)?:/', $value)) {
if (preg_match('/^http(s)?:/', $value))
{
// Show error message // Show error message
$correct_value = str_replace($dolibarr_main_url_root, '', $value); $correct_value = str_replace($dolibarr_main_url_root, '', $value);
print '<b>Error:</b><br>'."\n"; print '<b>Error:</b><br>'."\n";
@ -99,36 +100,39 @@ if (!empty($dolibarr_main_document_root_alt))
} }
// Chargement des includes principaux de librairies communes // 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('NOREQUIREUSER')) {
if (!defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Need 500ko memory
if (!defined('NOREQUIRESOC')) require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; }
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) * Creation objet $langs (must be before all other code)
*/ */
if (!defined('NOREQUIRETRAN')) if (!defined('NOREQUIRETRAN')) {
{
$langs = new Translate('', $conf); // Must be after reading conf $langs = new Translate('', $conf); // Must be after reading conf
} }
/* /*
* Object $db * 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); $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 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(); $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;">'; print '<div class="center" style="text-align: center; margin: 100px;">';
if (is_object($langs)) if (is_object($langs)) {
{
$langs->setDefaultLang('auto'); $langs->setDefaultLang('auto');
$langs->load("website"); $langs->load("website");
print $langs->trans("SorryWebsiteIsCurrentlyOffLine"); print $langs->trans("SorryWebsiteIsCurrentlyOffLine");
@ -175,10 +179,11 @@ if (session_id() && !empty($_SESSION["dol_entity"])) {
} }
// Sanitize 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."'"; //print "Will work with data into entity instance number '".$conf->entity."'";
// Here we read database (llx_const table) and define $conf->global->XXX var. // 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. // 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'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$mysoc = new Societe($db); $mysoc = new Societe($db);
$mysoc->setMysoc($conf); $mysoc->setMysoc($conf);
// For some countries, we need to invert our address with customer address // 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) // 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)); $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); $langs->setDefaultLang($langcode);
} }
@ -223,5 +230,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db); $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); //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('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('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIRESOC')) {
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); define('NOREQUIRESOC', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); }
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); if (!defined('NOREQUIRETRAN')) {
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); define('NOREQUIRETRAN', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); }
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '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. // 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. // Note that only directory logo is free to access without login.
if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file'])) if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file'])) {
{ if (!defined("NOLOGIN")) {
if (!defined("NOLOGIN")) define("NOLOGIN", 1); 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 (!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 // 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 (isset($_GET["hashp"]) && !defined("NOLOGIN")) {
{ if (!defined("NOLOGIN")) {
if (!defined("NOLOGIN")) define("NOLOGIN", 1); 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 (!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. // 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 (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias') {
{ if (!defined("NOLOGIN")) {
if (!defined("NOLOGIN")) define("NOLOGIN", 1); 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 (!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 // Used by TakePOS Auto Order
if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'product' && isset($_GET["publictakepos"])) if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'product' && isset($_GET["publictakepos"])) {
{ if (!defined("NOLOGIN")) {
if (!defined("NOLOGIN")) define("NOLOGIN", 1); 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 (!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 // For multicompany
$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); $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 * Header empty
@ -101,9 +137,15 @@ $urlsource = GETPOST('urlsource', 'alpha');
$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; $entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity;
// Security check // Security check
if (empty($modulepart) && empty($hashp)) accessforbidden('Bad link. Bad value for parameter modulepart', 0, 0, 1); if (empty($modulepart) && empty($hashp)) {
if (empty($original_file) && empty($hashp) && $modulepart != 'barcode') accessforbidden('Bad link. Missing identification to find file (param file or hashp)', 0, 0, 1); accessforbidden('Bad link. Bad value for parameter modulepart', 0, 0, 1);
if ($modulepart == 'fckeditor') $modulepart = 'medias'; // For backward compatibility }
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 * View
*/ */
if (GETPOST("cache", 'alpha')) if (GETPOST("cache", 'alpha')) {
{
// Important: Following code is to avoid page request by browser and PHP CPU at // Important: Following code is to avoid page request by browser and PHP CPU at
// each Dolibarr page access. // each Dolibarr page access.
if (empty($dolibarr_nocache)) if (empty($dolibarr_nocache)) {
{
header('Cache-Control: max-age=3600, public, must-revalidate'); header('Cache-Control: max-age=3600, public, must-revalidate');
header('Pragma: cache'); // This is to avoid having Pragma: no-cache 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; //print $dolibarr_nocache; exit;
} }
// If we have a hash public (hashp), we guess the original_file. // 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'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile = new EcmFiles($db); $ecmfile = new EcmFiles($db);
$result = $ecmfile->fetch(0, '', '', '', $hashp); $result = $ecmfile->fetch(0, '', '', '', $hashp);
if ($result > 0) if ($result > 0) {
{
$tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory
// filepath can be 'users/X' or 'X/propale/PR11111' // 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); $tmp = explode('/', $tmp[1], 2);
} }
$moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path
if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. if ($modulepart) { // Not required, so often not defined, for link using public hashp parameter.
{ if ($moduleparttocheck == $modulepart) {
if ($moduleparttocheck == $modulepart)
{
// We remove first level of directory // We remove first level of directory
$original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir
//var_dump($original_file); exit; //var_dump($original_file); exit;
@ -169,13 +206,20 @@ if (!empty($hashp))
// Define mime type // Define mime type
$type = 'application/octet-stream'; $type = 'application/octet-stream';
if (GETPOST('type', 'alpha')) $type = GETPOST('type', 'alpha'); if (GETPOST('type', 'alpha')) {
else $type = dol_mimetype($original_file); $type = GETPOST('type', 'alpha');
} else {
$type = dol_mimetype($original_file);
}
// Security: This wrapper is for images. We do not allow type/html // 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 // 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 // Security: Delete string ../ into $original_file
$original_file = str_replace("../", "/", $original_file); $original_file = str_replace("../", "/", $original_file);
@ -184,7 +228,9 @@ $original_file = str_replace("../", "/", $original_file);
$refname = basename(dirname($original_file)."/"); $refname = basename(dirname($original_file)."/");
// Security check // 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); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname);
$accessallowed = $check_access['accessallowed']; $accessallowed = $check_access['accessallowed'];
@ -200,20 +246,15 @@ if (!empty($hashp)) {
} }
} else { } else {
// Basic protection (against external users only) // Basic protection (against external users only)
if ($user->socid > 0) if ($user->socid > 0) {
{ if ($sqlprotectagainstexternals) {
if ($sqlprotectagainstexternals)
{
$resql = $db->query($sqlprotectagainstexternals); $resql = $db->query($sqlprotectagainstexternals);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($user->socid != $obj->fk_soc) if ($user->socid != $obj->fk_soc) {
{
$accessallowed = 0; $accessallowed = 0;
break; break;
} }
@ -226,15 +267,13 @@ if (!empty($hashp)) {
// Security: // Security:
// Limit access if permissions are wrong // Limit access if permissions are wrong
if (!$accessallowed) if (!$accessallowed) {
{
accessforbidden(); accessforbidden();
} }
// Security: // Security:
// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. // 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); dol_syslog("Refused to deliver file ".$fullpath_original_file);
print "ErrorFileNameInvalid: ".dol_escape_htmltag($original_file); print "ErrorFileNameInvalid: ".dol_escape_htmltag($original_file);
exit; exit;
@ -242,15 +281,13 @@ if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $full
if ($modulepart == 'barcode') if ($modulepart == 'barcode') {
{
$generator = GETPOST("generator", "alpha"); $generator = GETPOST("generator", "alpha");
$code = GETPOST("code", 'none'); // This can be rich content (qrcode, datamatrix, ...) $code = GETPOST("code", 'none'); // This can be rich content (qrcode, datamatrix, ...)
$encoding = GETPOST("encoding", "alpha"); $encoding = GETPOST("encoding", "alpha");
$readable = GETPOST("readable", 'alpha') ?GETPOST("readable", "alpha") : "Y"; $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'; print 'Error: Parameter "generator" or "encoding" not defined';
exit; exit;
} }
@ -259,23 +296,25 @@ if ($modulepart == 'barcode')
$result = 0; $result = 0;
foreach ($dirbarcode as $reldir) foreach ($dirbarcode as $reldir) {
{
$dir = dol_buildpath($reldir, 0); $dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir); $newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) // 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'; $result = @include_once $newdir.$generator.'.modules.php';
if ($result) break; if ($result) {
break;
}
} }
// Load barcode class // Load barcode class
$classname = "mod".ucfirst($generator); $classname = "mod".ucfirst($generator);
$module = new $classname($db); $module = new $classname($db);
if ($module->encodingIsSupported($encoding)) if ($module->encodingIsSupported($encoding)) {
{
$result = $module->buildBarCode($code, $encoding, $readable); $result = $module->buildBarCode($code, $encoding, $readable);
} }
} else { } else {
@ -288,17 +327,15 @@ if ($modulepart == 'barcode')
dol_syslog("viewimage.php return file $fullpath_original_file filename=$filename content-type=$type"); 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). // 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'; $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'; /*$error='Error: File '.$_GET["file"].' does not exists or filesystems permissions are not allowed';
print $error; print $error;
exit;*/ exit;*/
} }
// Permissions are ok and file found, so we return it // Permissions are ok and file found, so we return it
if ($type) if ($type) {
{
top_httphead($type); top_httphead($type);
header('Content-Disposition: inline; filename="'.basename($fullpath_original_file).'"'); header('Content-Disposition: inline; filename="'.basename($fullpath_original_file).'"');
} else { } else {
@ -312,4 +349,6 @@ if ($modulepart == 'barcode')
} }
if (is_object($db)) $db->close(); if (is_object($db)) {
$db->close();
}