--- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_accountancy_last_manual_entries.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_accountancy_last_manual_entries.php @@ -32,78 +32,78 @@ */ class box_accountancy_last_manual_entries extends ModeleBoxes { - public $boxcode = "accountancy_last_manual_entries"; - public $boximg = "object_invoice"; - public $boxlabel = "BoxLastManualEntries"; - public $depends = array("accounting"); + public $boxcode = "accountancy_last_manual_entries"; + public $boximg = "object_invoice"; + public $boxlabel = "BoxLastManualEntries"; + public $depends = array("accounting"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); - } + $this->hidden = !($user->rights->accounting->mouvements->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - $bookkeepingstatic = new BookKeeping($this->db); + $bookkeepingstatic = new BookKeeping($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); - if ($user->rights->accounting->mouvements->lire) - { - $sql = "SELECT DISTINCT b.piece_num"; - $sql .= ", b.doc_date as date_movement"; - $sql .= ", b.label_operation"; - $sql .= ", b.montant as amount"; - $sql .= ", b.code_journal"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " WHERE b.fk_doc = 0"; - $sql .= " AND b.entity = ".$conf->entity; - $sql .= " ORDER BY b.piece_num DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->accounting->mouvements->lire) + { + $sql = "SELECT DISTINCT b.piece_num"; + $sql .= ", b.doc_date as date_movement"; + $sql .= ", b.label_operation"; + $sql .= ", b.montant"; + $sql .= ", b.code_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " WHERE b.fk_doc = 0"; + $sql .= " AND b.entity = ".$conf->entity; + $sql .= " ORDER BY b.piece_num DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_movement); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_movement); $journal = $objp->code_journal; - $label = $objp->label_operation; - $amount = $objp->amount; + $label = $objp->label_operation; + $amount = $objp->montant; $bookkeepingstatic->id = $objp->id; $bookkeepingstatic->piece_num = $objp->piece_num; @@ -114,11 +114,11 @@ 'asis' => 1, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + 'asis' => 1, + ); $this->info_box_contents[$line][] = array( 'td' => 'class="center"', @@ -132,34 +132,34 @@ 'asis' => 1, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedManualEntries").'' - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedManualEntries") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover left"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -169,8 +169,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_accountancy_suspense_account.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_accountancy_suspense_account.php @@ -32,57 +32,57 @@ */ class box_accountancy_suspense_account extends ModeleBoxes { - public $boxcode = "accountancy_suspense_account"; - public $boximg = "object_invoice"; - public $boxlabel = "BoxSuspenseAccount"; - public $depends = array("accounting"); + public $boxcode = "accountancy_suspense_account"; + public $boximg = "object_invoice"; + public $boxlabel = "BoxSuspenseAccount"; + public $depends = array("accounting"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); - } + $this->hidden = !($user->rights->accounting->mouvements->lire); + } - /** - * Load data for box to show them later - * - * @return void - */ - public function loadBox() - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @return void + */ + public function loadBox() + { + global $user, $langs, $conf; - include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - //$bookkeepingstatic = new BookKeeping($this->db); + //$bookkeepingstatic = new BookKeeping($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); - if ($user->rights->accounting->mouvements->lire) - { + if ($user->rights->accounting->mouvements->lire) + { $suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; - if (!empty($suspenseAccount) && $suspenseAccount > 0) - { + if (!empty($suspenseAccount) && $suspenseAccount > 0) + { $sql = "SELECT COUNT(*) as nb_suspense_account"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql .= " WHERE b.numero_compte = ".$suspenseAccount; @@ -112,13 +112,13 @@ 'text' => ''.$langs->trans("SuspenseAccountNotDefined").'' ); } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' - ); - } - } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' + ); + } + } /** * Method to show box @@ -128,8 +128,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_actions.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_actions.php @@ -32,20 +32,20 @@ */ class box_actions extends ModeleBoxes { - public $boxcode = "lastactions"; - public $boximg = "object_action"; - public $boxlabel = "BoxLastActions"; - public $depends = array("agenda"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $enabled = 1; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "lastactions"; + public $boximg = "object_action"; + public $boxlabel = "BoxLastActions"; + public $depends = array("agenda"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,22 +54,20 @@ * @param DoliDB $db Database handler * @param string $param More parameters */ - public function __construct($db, $param) + public function __construct($db, $param = '') { - global $conf, $user; - - $this->db = $db; - - $this->enabled = $conf->agenda->enabled; - - $this->hidden = !($user->rights->agenda->myactions->read); + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->agenda->myactions->read); } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -77,25 +75,25 @@ $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $societestatic = new Societe($this->db); - $actionstatic = new ActionComm($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $societestatic = new Societe($this->db); + $actionstatic = new ActionComm($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo", $max)); - if ($user->rights->agenda->myactions->read) { + if ($user->rights->agenda->myactions->read) { $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage"; - $sql .= ", ta.code"; - $sql .= ", ta.libelle as type_label"; - $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; + $sql .= ", ta.code"; + $sql .= ", ta.libelle as type_label"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; if (!$user->rights->societe->client->voir && !$user->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 .= " WHERE a.fk_action = ta.id"; - $sql .= " AND a.entity IN (".getEntity('actioncomm').")"; + $sql .= " AND a.entity = ".$conf->entity; $sql .= " AND a.percent >= 0 AND a.percent < 100"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; @@ -103,94 +101,82 @@ $sql .= " ORDER BY a.datec DESC"; $sql .= $this->db->plimit($max, 0); - dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + dol_syslog("Box_actions::loadBox", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) { + while ($line < $num) { $late = ''; $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->dp); - - $actionstatic->id = $objp->id; - $actionstatic->label = $objp->label; - $actionstatic->type_label = $objp->type_label; - $actionstatic->code = $objp->code; - - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - //$societestatic->name_alias = $objp->name_alias; - $societestatic->code_client = $objp->code_client; - $societestatic->code_compta = $objp->code_compta; - $societestatic->client = $objp->client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; - $societestatic->entity = $objp->entity; - - if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) - $late = img_warning($langs->trans("Late")); + $actionstatic->id = $objp->id; + $actionstatic->label = $objp->label; + $actionstatic->type_label = $objp->type_label; + $actionstatic->code = $objp->code; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + + if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) + $late = img_warning($langs->trans("Late")); //($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) $label = empty($objp->label) ? $objp->type_label : $objp->label; - $this->info_box_contents[$line][0] = array( - 'td' => '', - 'text' => $actionstatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1 - ); - - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''), - 'asis' => 1 - ); - - $this->info_box_contents[$line][2] = array( - 'td' => 'class="nowrap left"', - 'text' => dol_print_date($datelimite, "dayhour"), - 'asis' => 1 - ); - - $this->info_box_contents[$line][3] = array( - 'td' => 'class="right"', - 'text' => ($objp->percentage >= 0 ? $objp->percentage.'%' : ''), - 'asis' => 1 - ); - - $this->info_box_contents[$line][4] = array( - 'td' => 'class="right" width="18"', - 'text' => $actionstatic->LibStatut($objp->percentage, 3), - 'asis' => 1 - ); - - $line++; - } - - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoActionsToDo") - ); - - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $actionstatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowrap left"', + 'text' => dol_print_date($datelimite, "dayhour"), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => ($objp->percentage >= 0 ? $objp->percentage.'%' : ''), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $actionstatic->LibStatut($objp->percentage, 3), + ); + + $line++; + } + + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoActionsToDo"), + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -202,13 +188,13 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { global $langs, $conf; - $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1); - - if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) - { + $out = parent::showBox($this->info_box_head, $this->info_box_contents); + + if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) + { $actioncejour = false; $contents = $this->info_box_contents; $nblines = count($contents); @@ -258,7 +244,9 @@ $out .= '}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).');'; } $out .= ''; - } else { + } + else + { $out .= ''; @@ -269,5 +257,5 @@ else print $out; return ''; - } + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_activity.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_activity.php @@ -30,413 +30,415 @@ */ class box_activity extends ModeleBoxes { - public $boxcode = "activity"; - public $boximg = "object_bill"; - public $boxlabel = 'BoxGlobalActivity'; - public $depends = array("facture"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - public $enabled = 1; - - public $info_box_head = array(); - public $info_box_contents = array(); - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $conf, $user; - - $this->db = $db; - - // FIXME: Pb into some status - $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) - - $this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire) - || (!empty($conf->commande->enabled) && $user->rights->commande->lire) - || (!empty($conf->propal->enabled) && $user->rights->propale->lire) - ); - } - - /** - * Charge les donnees en memoire pour affichage ulterieur - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $totalnb = 0; - $line = 0; - $cachetime = 3600; - $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir ? '1' : '0').'.cache'; - $now = dol_now(); - $nbofperiod = 3; - - if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION; - $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod); - $this->info_box_head = array( - 'text' => $textHead, - 'limit'=> dol_strlen($textHead), - ); - - // compute the year limit to show - $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofperiod, "m"); - - - // list the summary of the propals - if (!empty($conf->propal->enabled) && $user->rights->propale->lire) - { - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic = new Propal($this->db); - - $cachedir = DOL_DATA_ROOT.'/propale/temp'; - $filename = '/boxactivity-propal'.$fileid; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $data = array(); - if ($refresh) - { - $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; - $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= ")"; - $sql .= " WHERE p.entity IN (".getEntity('propal').")"; - $sql .= " AND p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; - $sql .= " AND p.date_cloture IS NULL"; // just unclosed - $sql .= " GROUP BY p.fk_statut"; - $sql .= " ORDER BY p.fk_statut DESC"; - - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - - $j = 0; - while ($j < $num) { - $data[$j] = $this->db->fetch_object($result); - $j++; - } - if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } else { - $data = dol_readcachefile($cachedir, $filename); - } - - if (!empty($data)) - { - $j = 0; - while ($j < count($data)) - { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, - 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), - 'logo' => 'object_propal' - ); - - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), - ); - - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'text' => $data[$j]->nb, - 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, - ); - $totalnb += $data[$j]->nb; - - $this->info_box_contents[$line][3] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), - ); - $this->info_box_contents[$line][4] = array( - 'td' => 'class="right" width="18"', - 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3), - ); - - $line++; - $j++; - } - } - } - - // list the summary of the orders - if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $commandestatic = new Commande($this->db); - - $langs->load("orders"); - - $cachedir = DOL_DATA_ROOT.'/commande/temp'; - $filename = '/boxactivity-order'.$fileid; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $data = array(); - - if ($refresh) { - $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; - $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= ")"; - $sql .= " WHERE c.entity IN (".getEntity('commande').")"; - $sql .= " AND c.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; - $sql .= " GROUP BY c.fk_statut"; - $sql .= " ORDER BY c.fk_statut DESC"; - - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $j = 0; - while ($j < $num) { - $data[$j] = $this->db->fetch_object($result); - $j++; - } - if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } else { - $data = dol_readcachefile($cachedir, $filename); - } - - if (!empty($data)) { - $j = 0; - while ($j < count($data)) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut, - 'tooltip' => $langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), - 'logo' => 'object_order', - ); - - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' =>$langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), - ); - - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'text' => $data[$j]->nb, - 'tooltip' => $langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), - 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut, - ); - $totalnb += $data[$j]->nb; - - $this->info_box_contents[$line][3] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), - ); - $this->info_box_contents[$line][4] = array( - 'td' => 'class="right" width="18"', - 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3), - ); - - $line++; - $j++; - } - } - } - - - // list the summary of the bills - if (!empty($conf->facture->enabled) && $user->rights->facture->lire) - { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic = new Facture($this->db); - - // part 1 - $cachedir = DOL_DATA_ROOT.'/facture/temp'; - $filename = '/boxactivity-invoice'.$fileid; - - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $data = array(); - if ($refresh) - { - $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= ")"; - $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " AND f.fk_soc = s.rowid"; - $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; - $sql .= " GROUP BY f.fk_statut"; - $sql .= " ORDER BY f.fk_statut DESC"; - - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $j = 0; - while ($j < $num) { - $data[$j] = $this->db->fetch_object($result); - $j++; - } - if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } else { - $data = dol_readcachefile($cachedir, $filename); - } - - if (!empty($data)) { - $j = 0; - while ($j < count($data)) { - $billurl = "search_status=2&paye=1&year=".$data[$j]->annee; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - 'logo' => 'bill', - ); - - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0)." ".$data[$j]->annee, - ); - - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), - 'text' => $data[$j]->nb, - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - ); - - $this->info_box_contents[$line][3] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency) - ); - - // We add only for the current year - $totalnb += $data[$j]->nb; - - $this->info_box_contents[$line][4] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3), - ); - $line++; - $j++; - } - if (count($data) == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); - } - - // part 2 - $cachedir = DOL_DATA_ROOT.'/facture/temp'; - $filename = '/boxactivity-invoice2'.$fileid; - - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - - $data = array(); - if ($refresh) { - $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; - $sql .= " AND f.fk_soc = s.rowid"; - $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0"; - $sql .= " GROUP BY f.fk_statut"; - $sql .= " ORDER BY f.fk_statut DESC"; - - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $j = 0; - while ($j < $num) { - $data[$j] = $this->db->fetch_object($result); - $j++; - } - if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } else { - $data = dol_readcachefile($cachedir, $filename); - } - - if (!empty($data)) { - $alreadypaid = -1; - - $j = 0; - while ($j < count($data)) { - $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - 'logo' => 'bill', - ); - - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), - ); - - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'text' => $data[$j]->nb, - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - ); - $totalnb += $data[$j]->nb; - $this->info_box_contents[$line][3] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), - ); - $this->info_box_contents[$line][4] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid), - ); - $line++; - $j++; - } - if (count($data) == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); - } - } - } + public $boxcode = "activity"; + public $boximg = "object_bill"; + public $boxlabel = 'BoxGlobalActivity'; + public $depends = array("facture"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $conf, $user; + + $this->db = $db; + + // FIXME: Pb into some status + $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) + + $this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire) + || (!empty($conf->commande->enabled) && $user->rights->commande->lire) + || (!empty($conf->propal->enabled) && $user->rights->propale->lire) + ); + } + + /** + * Charge les donnees en memoire pour affichage ulterieur + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $totalnb = 0; + $line = 0; + $cachetime = 3600; + $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'-r'.($user->rights->societe->client->voir ? '1' : '0').'.cache'; + $now = dol_now(); + $nbofperiod = 3; + + if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION; + $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod); + $this->info_box_head = array( + 'text' => $textHead, + 'limit'=> dol_strlen($textHead), + ); + + // compute the year limit to show + $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofperiod, "m"); + + + // list the summary of the propals + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) + { + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $propalstatic = new Propal($this->db); + + $cachedir = DOL_DATA_ROOT.'/propale/temp'; + $filename = '/boxactivity-propal'.$fileid; + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); + if ($refresh) + { + $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND p.datep >= '".$this->db->idate($tmpdate)."'"; + $sql .= " AND p.date_cloture IS NULL"; // just unclosed + $sql .= " GROUP BY p.fk_statut"; + $sql .= " ORDER BY p.fk_statut DESC"; + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + + $j = 0; + while ($j < $num) { + $data[$j] = $this->db->fetch_object($result); + $j++; + } + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + else + { + $data = dol_readcachefile($cachedir, $filename); + } + + if (!empty($data)) + { + $j = 0; + while ($j < count($data)) + { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, + 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), + 'logo' => 'object_propal' + ); + + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), + ); + + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, + ); + $totalnb += $data[$j]->nb; + + $this->info_box_contents[$line][3] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), + ); + $this->info_box_contents[$line][4] = array( + 'td' => 'class="right" width="18"', + 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3), + ); + + $line++; + $j++; + } + } + } + + // list the summary of the orders + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $commandestatic = new Commande($this->db); + + $langs->load("orders"); + + $cachedir = DOL_DATA_ROOT.'/commande/temp'; + $filename = '/boxactivity-order'.$fileid; + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); + + if ($refresh) { + $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE c.entity = ".$conf->entity; + $sql .= " AND c.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; + $sql .= " GROUP BY c.fk_statut"; + $sql .= " ORDER BY c.fk_statut DESC"; + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $j = 0; + while ($j < $num) { + $data[$j] = $this->db->fetch_object($result); + $j++; + } + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } else { + $data = dol_readcachefile($cachedir, $filename); + } + + if (!empty($data)) { + $j = 0; + while ($j < count($data)) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut, + 'tooltip' => $langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), + 'logo' => 'object_order', + ); + + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' =>$langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), + ); + + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans("Orders")." ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), + 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut, + ); + $totalnb += $data[$j]->nb; + + $this->info_box_contents[$line][3] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), + ); + $this->info_box_contents[$line][4] = array( + 'td' => 'class="right" width="18"', + 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3), + ); + + $line++; + $j++; + } + } + } + + + // list the summary of the bills + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) + { + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $facturestatic = new Facture($this->db); + + // part 1 + $cachedir = DOL_DATA_ROOT.'/facture/temp'; + $filename = '/boxactivity-invoice'.$fileid; + + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); + if ($refresh) + { + $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ")"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1"; + $sql .= " GROUP BY f.fk_statut"; + $sql .= " ORDER BY f.fk_statut DESC"; + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $j = 0; + while ($j < $num) { + $data[$j] = $this->db->fetch_object($result); + $j++; + } + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } else { + $data = dol_readcachefile($cachedir, $filename); + } + + if (!empty($data)) { + $j = 0; + while ($j < count($data)) { + $billurl = "search_status=2&paye=1&year=".$data[$j]->annee; + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'logo' => 'bill', + ); + + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0)." ".$data[$j]->annee, + ); + + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), + 'text' => $data[$j]->nb, + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + ); + + $this->info_box_contents[$line][3] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency) + ); + + // We add only for the current year + $totalnb += $data[$j]->nb; + + $this->info_box_contents[$line][4] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3), + ); + $line++; + $j++; + } + if (count($data) == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + } + + // part 2 + $cachedir = DOL_DATA_ROOT.'/facture/temp'; + $filename = '/boxactivity-invoice2'.$fileid; + + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + + $data = array(); + if ($refresh) { + $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=0"; + $sql .= " GROUP BY f.fk_statut"; + $sql .= " ORDER BY f.fk_statut DESC"; + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $j = 0; + while ($j < $num) { + $data[$j] = $this->db->fetch_object($result); + $j++; + } + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } else { + $data = dol_readcachefile($cachedir, $filename); + } + + if (!empty($data)) { + $alreadypaid = -1; + + $j = 0; + while ($j < count($data)) { + $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'logo' => 'bill', + ); + + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), + ); + + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + ); + $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][3] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency), + ); + $this->info_box_contents[$line][4] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid), + ); + $line++; + $j++; + } + if (count($data) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + } + } + } // Add the sum in the bottom of the boxes $this->info_box_contents[$line][0] = array('tr' => 'class="liste_total_wrap"'); @@ -444,19 +446,19 @@ $this->info_box_contents[$line][2] = array('td' => 'class="liste_total right" ', 'text' => $totalnb); $this->info_box_contents[$line][3] = array('td' => 'class="liste_total right" ', 'text' => ''); $this->info_box_contents[$line][4] = array('td' => 'class="liste_total right" ', 'text' => ""); - } - - - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + } + + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_birthdays.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_birthdays.php @@ -32,27 +32,27 @@ */ class box_birthdays extends ModeleBoxes { - public $boxcode = "birthdays"; - public $boximg = "object_user"; - public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; - public $depends = array("user"); + public $boxcode = "birthdays"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; + public $depends = array("user"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -64,10 +64,10 @@ } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 20) { @@ -78,20 +78,19 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $userstatic = new User($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); if ($user->rights->user->user->lire) { $tmparray = dol_getdate(dol_now(), true); - $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth, u.email, u.statut as status"; + $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; - $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); - $sql .= " ORDER BY DAY(u.birth) ASC"; + $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); @@ -104,28 +103,25 @@ while ($line < $num) { $objp = $this->db->fetch_object($result); + $userstatic->id = $objp->rowid; + $userstatic->firstname = $objp->firstname; + $userstatic->lastname = $objp->lastname; + $userstatic->email = $objp->email; + $dateb = $this->db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); - $userstatic->id = $objp->rowid; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->email = $objp->email; - $userstatic->statut = $objp->status; + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $userstatic->getNomUrl(1), + 'asis' => 1, + ); - $dateb = $this->db->jdate($objp->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $userstatic->getNomUrl(1), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') - ); - - /*$this->info_box_contents[$line][] = array( + /*$this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $userstatic->LibStatut($objp->status, 3) );*/ @@ -136,17 +132,19 @@ if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None")); $this->db->free($result); - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -159,8 +157,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_birthdays_members.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_birthdays_members.php @@ -32,27 +32,27 @@ */ class box_birthdays_members extends ModeleBoxes { - public $boxcode = "birthdays_members"; - public $boximg = "object_user"; - public $boxlabel = "BoxTitleMemberNextBirthdays"; - public $depends = array("adherent"); + public $boxcode = "birthdays_members"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleMemberNextBirthdays"; + public $depends = array("adherent"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -64,10 +64,10 @@ } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 20) { @@ -78,9 +78,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); + $memberstatic = new Adherent($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); if ($user->rights->adherent->lire) { @@ -89,9 +89,9 @@ $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as u"; $sql .= " WHERE u.entity IN (".getEntity('adherent').")"; - $sql .= " AND u.statut = 1"; - $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); - $sql .= " ORDER BY DAY(u.birth) ASC"; + $sql .= " AND u.statut = 1"; + $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); + $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); @@ -104,25 +104,25 @@ while ($line < $num) { $objp = $this->db->fetch_object($result); - $memberstatic->id = $objp->rowid; - $memberstatic->firstname = $objp->firstname; - $memberstatic->lastname = $objp->lastname; - $memberstatic->email = $objp->email; - $dateb = $this->db->jdate($objp->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $memberstatic->id = $objp->rowid; + $memberstatic->firstname = $objp->firstname; + $memberstatic->lastname = $objp->lastname; + $memberstatic->email = $objp->email; + $dateb = $this->db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $memberstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $memberstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + ); - /*$this->info_box_contents[$line][] = array( + /*$this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $memberstatic->LibStatut($objp->status, 3) );*/ @@ -133,17 +133,19 @@ if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None")); $this->db->free($result); - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -156,8 +158,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_boms.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_boms.php @@ -32,147 +32,147 @@ */ class box_boms extends ModeleBoxes { - public $boxcode = "lastboms"; - public $boximg = "object_bom"; - public $boxlabel = "BoxTitleLatestModifiedBoms"; - public $depends = array("bom"); + public $boxcode = "lastboms"; + public $boximg = "object_bom"; + public $boxlabel = "BoxTitleLatestModifiedBoms"; + public $depends = array("bom"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bom->read); - } + $this->hidden = !($user->rights->bom->read); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $bomstatic = new Bom($this->db); - $productstatic = new Product($this->db); - $userstatic = new User($this->db); + $bomstatic = new Bom($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); - if ($user->rights->bom->read) - { - $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; - $sql .= ", c.rowid"; - $sql .= ", c.date_creation"; - $sql .= ", c.tms"; - $sql .= ", c.ref"; - $sql .= ", c.status"; - $sql .= ", c.fk_user_valid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; - $sql .= " WHERE c.fk_product = p.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " ORDER BY c.tms DESC, c.ref DESC"; - $sql .= " ".$this->db->plimit($max, 0); + if ($user->rights->bom->read) + { + $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + $sql .= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datem = $this->db->jdate($objp->tms); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem = $this->db->jdate($objp->tms); - $bomstatic->id = $objp->rowid; - $bomstatic->ref = $objp->ref; - $bomstatic->id = $objp->socid; - $bomstatic->status = $objp->status; + $bomstatic->id = $objp->rowid; + $bomstatic->ref = $objp->ref; + $bomstatic->id = $objp->socid; + $bomstatic->status = $objp->status; - $productstatic->ref = $objp->product_ref; - $productstatic->status = $objp->tobuy; - $productstatic->status_buy = $objp->tosell; + $productstatic->ref = $objp->product_ref; + $productstatic->status = $objp->tobuy; + $productstatic->status_buy = $objp->tosell; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $bomstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $bomstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $bomstatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $bomstatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -182,8 +182,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_bookmarks.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_bookmarks.php @@ -28,20 +28,20 @@ */ class box_bookmarks extends ModeleBoxes { - public $boxcode = "bookmarks"; - public $boximg = "bookmark"; - public $boxlabel = "BoxMyLastBookmarks"; - public $depends = array("bookmark"); + public $boxcode = "bookmarks"; + public $boximg = "bookmark"; + public $boxlabel = "BoxMyLastBookmarks"; + public $depends = array("bookmark"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,18 +52,18 @@ */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bookmark->lire); + $this->hidden = !($user->rights->bookmark->lire); } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -73,13 +73,15 @@ $this->max = $max; $this->info_box_head = array( - 'text' => $langs->trans("BoxMyLastBookmarks", $max), - 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', - ); - if ($user->rights->bookmark->creer) { + 'text' => $langs->trans("BoxMyLastBookmarks", $max), + 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', + ); + if ($user->rights->bookmark->creer) { $this->info_box_head['subpicto'] = 'bookmark'; $this->info_box_head['subtext'] = $langs->trans("BookmarksManagement"); - } else { + } + else + { $this->info_box_head['subpicto'] = 'bookmark'; $this->info_box_head['subtext'] = $langs->trans("ListOfBookmark"); } @@ -89,7 +91,7 @@ $sql = "SELECT b.title, b.url, b.target, b.favicon"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; $sql .= " WHERE fk_user = ".$user->id; - $sql .= " AND b.entity = ".$conf->entity; + $sql .= " AND b.entity = ".$conf->entity; $sql .= $this->db->order("position", "ASC"); $sql .= $this->db->plimit($max, 0); @@ -100,63 +102,63 @@ $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'logo' => $this->boximg, - 'url' => $objp->url, - 'tooltip' => $objp->title, - 'target' => $objp->target ? 'newtab' : '', - ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $objp->title, - 'url' => $objp->url, - 'tooltip' => $objp->title, - 'target' => $objp->target ? 'newtab' : '', - ); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'logo' => $this->boximg, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target ? 'newtab' : '', + ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $objp->title, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target ? 'newtab' : '', + ); - $line++; - } + $line++; + } - if ($num == 0) { - $mytxt = $langs->trans("NoRecordedBookmarks"); - if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd"); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center" colspan="2"', - 'tooltip' => $mytxt, - 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, - ); - } + if ($num == 0) { + $mytxt = $langs->trans("NoRecordedBookmarks"); + if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd"); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center" colspan="2"', + 'tooltip' => $mytxt, + 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, + ); + } - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_clients.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_clients.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2015-2021 Frederic France + * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,27 +32,27 @@ */ class box_clients extends ModeleBoxes { - public $boxcode = "lastcustomers"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastCustomers"; - public $depends = array("societe"); + public $boxcode = "lastcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastCustomers"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -67,10 +67,10 @@ } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -79,23 +79,29 @@ $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; - $thirdpartystatic = new Client($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); if ($user->rights->societe->lire) { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", s.datec, s.tms, s.status"; + $sql = "SELECT s.nom as name, s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.client"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.code_compta"; + $sql .= ", s.code_compta_fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.email"; + $sql .= ", s.datec, s.tms, s.status, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (1, 3)"; $sql .= " AND s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($user->socid) $sql .= " AND s.rowid = $user->socid"; $sql .= " ORDER BY s.tms DESC"; $sql .= $this->db->plimit($max, 0); @@ -111,32 +117,33 @@ $objp = $this->db->fetch_object($result); $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); - - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->name_alias = $objp->name_alias; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta = $objp->code_compta; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta = $objp->code_compta; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->email = $objp->email; $thirdpartystatic->entity = $objp->entity; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day") - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day") + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3) - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + ); $line++; } @@ -147,17 +154,19 @@ ); $this->db->free($result); - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -170,8 +179,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_commandes.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_commandes.php @@ -32,173 +32,168 @@ */ class box_commandes extends ModeleBoxes { - public $boxcode = "lastcustomerorders"; - public $boximg = "object_order"; - public $boxlabel = "BoxLastCustomerOrders"; - public $depends = array("commande"); + public $boxcode = "lastcustomerorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLastCustomerOrders"; + public $depends = array("commande"); /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; - - $this->db = $db; - - $this->hidden = !($user->rights->commande->lire); - } - - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->load('orders'); - - $this->max = $max; - - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - - $commandestatic = new Commande($this->db); - $societestatic = new Societe($this->db); - $userstatic = new User($this->db); - - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); - - if ($user->rights->commande->lire) - { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", c.ref, c.tms"; - $sql .= ", c.rowid"; - $sql .= ", c.date_commande"; - $sql .= ", c.ref_client"; - $sql .= ", c.fk_statut"; - $sql .= ", c.fk_user_valid"; - $sql .= ", c.facture"; - $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; - $sql .= ", c.total_ttc"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('commande').")"; - if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); - - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - - $line = 0; - - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); - $datem = $this->db->jdate($objp->tms); - - $commandestatic->id = $objp->rowid; - $commandestatic->ref = $objp->ref; - $commandestatic->ref_client = $objp->ref_client; - $commandestatic->total_ht = $objp->total_ht; - $commandestatic->total_tva = $objp->total_tva; - $commandestatic->total_ttc = $objp->total_ttc; - - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - //$societestatic->name_alias = $objp->name_alias; - $societestatic->code_client = $objp->code_client; - $societestatic->code_compta = $objp->code_compta; - $societestatic->client = $objp->client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; - $societestatic->entity = $objp->entity; - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $commandestatic->getNomUrl(1), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); - - if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), - ); - - $line++; - } - - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); - - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->commande->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load('orders'); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $commandestatic = new Commande($this->db); + $societestatic = new Societe($this->db); + $userstatic = new User($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); + + if ($user->rights->commande->lire) + { + $sql = "SELECT s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", c.ref, c.tms"; + $sql .= ", c.rowid"; + $sql .= ", c.date_commande"; + $sql .= ", c.ref_client"; + $sql .= ", c.fk_statut"; + $sql .= ", c.fk_user_valid"; + $sql .= ", c.facture"; + $sql .= ", c.total_ht"; + $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); + $datem = $this->db->jdate($objp->tms); + $commandestatic->id = $objp->rowid; + $commandestatic->ref = $objp->ref; + $commandestatic->ref_client = $objp->ref_client; + $commandestatic->total_ht = $objp->total_ht; + $commandestatic->total_tva = $objp->total_tva; + $commandestatic->total_ttc = $objp->total_ttc; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $commandestatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); + + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), + ); + + $line++; + } + + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -208,8 +203,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_comptes.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_comptes.php @@ -33,28 +33,28 @@ */ class box_comptes extends ModeleBoxes { - public $boxcode = "currentaccounts"; - public $boximg = "object_bill"; - public $boxlabel = "BoxCurrentAccounts"; - public $depends = array("banque"); // Box active if module banque active + public $boxcode = "currentaccounts"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCurrentAccounts"; + public $depends = array("banque"); // Box active if module banque active - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -73,7 +73,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -83,109 +83,109 @@ $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); - if ($user->rights->banque->lire) { + if ($user->rights->banque->lire) { $sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url"; $sql .= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; $sql .= ", b.domiciliation, b.proprio, b.owner_address"; $sql .= ", b.account_number, b.currency_code"; $sql .= ", b.min_allowed, b.min_desired, comment"; - $sql .= ', b.fk_accountancy_journal'; - $sql .= ', aj.code as accountancy_journal'; - $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; - $sql .= " WHERE b.entity = ".$conf->entity; + $sql .= ', b.fk_accountancy_journal'; + $sql .= ', aj.code as accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; + $sql .= " WHERE b.entity = ".$conf->entity; $sql .= " AND clos = 0"; //$sql.= " AND courant = 1"; $sql .= " ORDER BY label"; $sql .= $this->db->plimit($max, 0); - dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; - $solde_total = array(); + $line = 0; + $solde_total = array(); - $account_static = new Account($this->db); - while ($line < $num) { - $objp = $this->db->fetch_object($result); + $account_static = new Account($this->db); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $account_static->id = $objp->rowid; + $account_static->id = $objp->rowid; $account_static->ref = $objp->ref; - $account_static->label = $objp->label; - $account_static->number = $objp->number; - $account_static->account_number = $objp->account_number; - $account_static->currency_code = $objp->currency_code; - $account_static->accountancy_journal = $objp->accountancy_journal; - $solde = $account_static->solde(0); + $account_static->label = $objp->label; + $account_static->number = $objp->number; + $account_static->account_number = $objp->account_number; + $account_static->currency_code = $objp->currency_code; + $account_static->accountancy_journal = $objp->accountancy_journal; + $solde = $account_static->solde(0); - $solde_total[$objp->currency_code] += $solde; + $solde_total[$objp->currency_code] += $solde; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $account_static->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $account_static->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $objp->number, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $objp->number, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($solde, 0, $langs, 1, -1, -1, $objp->currency_code) - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) + ); - $line++; - } + $line++; + } - // Total - foreach ($solde_total as $key=>$solde) { - $this->info_box_contents[$line][] = array( - 'tr' => 'class="liste_total"', - 'td' => 'class="liste_total left"', - 'text' => $langs->trans('Total').' '.$key, - ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="liste_total right"', - 'text' => ' ' - ); + // Total + foreach ($solde_total as $key=>$solde) { + $this->info_box_contents[$line][] = array( + 'tr' => 'class="liste_total"', + 'td' => 'class="liste_total left"', + 'text' => $langs->trans('Total').' '.$key, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => ' ' + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="liste_total right nowraponall"', - 'text' => price($solde, 0, $langs, 0, -1, -1, $key) - ); - $line++; - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right nowraponall"', + 'text' => price($solde, 0, $langs, 0, -1, -1, $key) + ); + $line++; + } - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_contacts.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_contacts.php @@ -35,20 +35,20 @@ */ class box_contacts extends ModeleBoxes { - public $boxcode = "lastcontacts"; - public $boximg = "object_contact"; - public $boxlabel = "BoxLastContacts"; - public $depends = array("societe"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "lastcontacts"; + public $boximg = "object_contact"; + public $boxlabel = "BoxLastContacts"; + public $depends = array("societe"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -59,18 +59,18 @@ */ public function __construct($db, $param) { - global $user; - - $this->db = $db; - - $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -86,17 +86,15 @@ $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; $sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; - $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; - $sql .= ", s.logo, s.email, s.entity"; + $sql .= ", s.nom as socname, s.name_alias, s.email as semail"; + $sql .= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; $sql .= ", co.label as country, co.code as country_code"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid; $sql .= " ORDER BY sp.tms DESC"; $sql .= $this->db->plimit($max, 0); @@ -123,25 +121,21 @@ $contactstatic->phone_pro = $objp->phone; $contactstatic->phone_perso = $objp->phone_perso; $contactstatic->phone_mobile = $objp->phone_mobile; - $contactstatic->email = $objp->spemail; + $contactstatic->email = $objp->spemail; $contactstatic->address = $objp->address; $contactstatic->zip = $objp->zip; $contactstatic->town = $objp->town; $contactstatic->country = $objp->country; $contactstatic->country_code = $objp->country_code; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - //$societestatic->name_alias = $objp->name_alias; + $societestatic->id = $objp->fk_soc; + $societestatic->name = $objp->socname; + $societestatic->email = $objp->semail; + $societestatic->name_alias = $objp->name_alias; $societestatic->code_client = $objp->code_client; - $societestatic->code_compta = $objp->code_compta; + $societestatic->code_fournisseur = $objp->code_fournisseur; $societestatic->client = $objp->client; - $societestatic->code_fournisseur = $objp->code_fournisseur; - $societestatic->code_compta_fournisseur = $objp->code_compta_fournisseur; $societestatic->fournisseur = $objp->fournisseur; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; - $societestatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', @@ -151,7 +145,7 @@ $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''), + 'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''), 'asis' => 1, ); @@ -186,8 +180,8 @@ } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover left"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_contracts.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_contracts.php @@ -31,158 +31,158 @@ */ class box_contracts extends ModeleBoxes { - public $boxcode = "lastcontracts"; - public $boximg = "object_contract"; - public $boxlabel = "BoxLastContracts"; - public $depends = array("contrat"); // conf->contrat->enabled + public $boxcode = "lastcontracts"; + public $boximg = "object_contract"; + public $boxlabel = "BoxLastContracts"; + public $depends = array("contrat"); // conf->contrat->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); - } + $this->hidden = !($user->rights->contrat->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); - if ($user->rights->contrat->lire) - { - $contractstatic = new Contrat($this->db); - $thirdpartytmp = new Societe($this->db); + if ($user->rights->contrat->lire) + { + $contractstatic = new Contrat($this->db); + $thirdpartytmp = new Societe($this->db); - $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; - $sql .= ", c.ref_customer, c.ref_supplier"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); + $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; + $sql .= ", c.ref_customer, c.ref_supplier"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $now = dol_now(); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $now = dol_now(); - $line = 0; + $line = 0; - $langs->load("contracts"); + $langs->load("contracts"); - while ($line < $num) - { - $objp = $this->db->fetch_object($resql); + while ($line < $num) + { + $objp = $this->db->fetch_object($resql); - $datec = $this->db->jdate($objp->datec); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - $late = ''; + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $late = ''; - $contractstatic->statut = $objp->fk_statut; - $contractstatic->id = $objp->rowid; - $contractstatic->ref = $objp->ref; - $contractstatic->ref_customer = $objp->ref_customer; - $contractstatic->ref_supplier = $objp->ref_supplier; - $result = $contractstatic->fetch_lines(); + $contractstatic->statut = $objp->fk_statut; + $contractstatic->id = $objp->rowid; + $contractstatic->ref = $objp->ref; + $contractstatic->ref_customer = $objp->ref_customer; + $contractstatic->ref_supplier = $objp->ref_supplier; + $result = $contractstatic->fetch_lines(); - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->client = $objp->client; - $thirdpartytmp->fournisseur = $objp->fournisseur; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->code_compta = $objp->code_compta; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - // fin_validite is no more on contract but on services - // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } + // fin_validite is no more on contract but on services + // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contractstatic->getNomUrl(1), - 'text2'=> $late, - 'asis'=>1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contractstatic->getNomUrl(1), + 'text2'=> $late, + 'asis'=>1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1), - 'asis'=>1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1), + 'asis'=>1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => $contractstatic->getLibStatut(7), - 'asis'=>1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => $contractstatic->getLibStatut(7), + 'asis'=>1, + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedContracts"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedContracts"), + ); - $this->db->free($resql); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($resql); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -192,8 +192,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_external_rss.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_external_rss.php @@ -34,45 +34,45 @@ */ class box_external_rss extends ModeleBoxes { - public $boxcode = "lastrssinfos"; - public $boximg = "object_rss"; - public $boxlabel = "BoxLastRssInfos"; - public $depends = array("externalrss"); + public $boxcode = "lastrssinfos"; + public $boximg = "object_rss"; + public $boxlabel = "BoxLastRssInfos"; + public $depends = array("externalrss"); /** - * @var DoliDB Database handler. - */ - public $db; - - public $paramdef; // Params of box definition (not user params) - - public $info_box_head = array(); - public $info_box_contents = array(); - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { + * @var DoliDB Database handler. + */ + public $db; + + public $paramdef; // Params of box definition (not user params) + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { $this->db = $db; $this->paramdef = $param; - } - - /** + } + + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @param int $cachedelay Delay we accept for cache file - * @return void - */ - public function loadBox($max = 5, $cachedelay = 3600) - { - global $user, $langs, $conf; - $langs->load("boxes"); + * @param int $cachedelay Delay we accept for cache file + * @return void + */ + public function loadBox($max = 5, $cachedelay = 3600) + { + global $user, $langs, $conf; + $langs->load("boxes"); $this->max = $max; @@ -90,42 +90,44 @@ // Get RSS feed $url = $conf->global->$keyforparamurl; - $rssparser = new RssParser($this->db); + $rssparser = new RssParser($this->db); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); // INFO on channel $description = $rssparser->getDescription(); $link = $rssparser->getLink(); - $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); - if ($result < 0 || !empty($rssparser->error)) - { - // Show warning - $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); - if ($rssparser->error) $errormessage .= " - ".$rssparser->error; - $title .= " ".img_error($errormessage); - $this->info_box_head = array('text' => $title, 'limit' => 0); - } else { - $this->info_box_head = array( - 'text' => $title, - 'sublink' => $link, - 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), - 'subpicto'=>'globe', - 'target'=>'_blank', - ); + $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); + if ($result < 0 || !empty($rssparser->error)) + { + // Show warning + $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); + if ($rssparser->error) $errormessage .= " - ".$rssparser->error; + $title .= " ".img_error($errormessage); + $this->info_box_head = array('text' => $title, 'limit' => 0); + } + else + { + $this->info_box_head = array( + 'text' => $title, + 'sublink' => $link, + 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), + 'subpicto'=>'globe', + 'target'=>'_blank', + ); } // INFO on items $items = $rssparser->getItems(); - //print '
'.print_r($items,true).'
'; + //print '
'.print_r($items,true).'
'; $nbitems = count($items); - for ($line = 0; $line < $max && $line < $nbitems; $line++) - { - $item = $items[$line]; + for ($line = 0; $line < $max && $line < $nbitems; $line++) + { + $item = $items[$line]; // Feed common fields - $href = $item['link']; - $title = urldecode($item['title']); + $href = $item['link']; + $title = urldecode($item['title']); $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') // If RSS { @@ -145,46 +147,46 @@ if (is_numeric($date)) $date = dol_print_date($date, "dayhour"); $isutf8 = utf8_check($title); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); - - $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 - $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut - $this->info_box_contents["$href"] = "$title"; - - $tooltip = $title; - $description = !empty($item['description']) ? $item['description'] : ''; - $isutf8 = utf8_check($description); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); - $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); - $description = preg_replace("/^\s+/", "", $description); - $description = str_replace("\r\n", "", $description); - $tooltip .= '
'.$description; - - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'logo' => $this->boximg, - 'url' => $href, - 'tooltip' => $tooltip, - 'target' => 'newrss', - ); - - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $title, - 'url' => $href, - 'tooltip' => $tooltip, - 'maxlength' => 64, - 'target' => 'newrss', - ); - - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right nowrap"', - 'text' => $date, - ); - } - } + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); + + $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 + $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut + $this->info_box_contents["$href"] = "$title"; + + $tooltip = $title; + $description = !empty($item['description']) ? $item['description'] : ''; + $isutf8 = utf8_check($description); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); + $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); + $description = preg_replace("/^\s+/", "", $description); + $description = str_replace("\r\n", "", $description); + $tooltip .= '
'.$description; + + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'logo' => $this->boximg, + 'url' => $href, + 'tooltip' => $tooltip, + 'target' => 'newrss', + ); + + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $title, + 'url' => $href, + 'tooltip' => $tooltip, + 'maxlength' => 64, + 'target' => 'newrss', + ); + + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right nowrap"', + 'text' => $date, + ); + } + } /** @@ -195,8 +197,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_factures.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_factures.php @@ -30,20 +30,20 @@ */ class box_factures extends ModeleBoxes { - public $boxcode = "lastcustomerbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxLastCustomerBills"; - public $depends = array("facture"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "lastcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastCustomerBills"; + public $depends = array("facture"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,18 +54,18 @@ */ public function __construct($db, $param) { - global $user; - - $this->db = $db; - - $this->hidden = !($user->rights->facture->lire); + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -73,13 +73,13 @@ $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - - $facturestatic = new Facture($this->db); - $societestatic = new Societe($this->db); - - $langs->load("bills"); + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); + + $langs->load("bills"); $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerBills", $max); $this->info_box_head = array( @@ -87,18 +87,15 @@ 'limit'=> dol_strlen($text) ); - if ($user->rights->facture->lire) { - $sql = "SELECT f.rowid as facid"; - $sql .= ", f.ref, f.type, f.total as total_ht"; - $sql .= ", f.tva as total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.datef as df"; - $sql .= ", f.paye, f.fk_statut as status, f.datec, f.tms"; + if ($user->rights->facture->lire) { + $sql = "SELECT f.rowid as facid"; + $sql .= ", f.ref, f.type, f.total as total_ht"; + $sql .= ", f.tva as total_tva"; + $sql .= ", f.total_ttc"; + $sql .= ", f.datef as df"; + $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; + $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= ", f.date_lim_reglement as datelimite"; - $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ")"; @@ -106,8 +103,8 @@ $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -119,97 +116,90 @@ $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datelimite = $this->db->jdate($objp->datelimite); - $date = $this->db->jdate($objp->df); - $datem = $this->db->jdate($objp->tms); - - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->type = $objp->type; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->statut = $objp->status; - $facturestatic->status = $objp->status; - $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $facturestatic->alreadypaid = $objp->paye; - - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - //$societestatic->name_alias = $objp->name_alias; - $societestatic->code_client = $objp->code_client; - $societestatic->code_compta = $objp->code_compta; - $societestatic->client = $objp->client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; - $societestatic->entity = $objp->entity; - $societestatic->tva_intra = $objp->tva_intra; - $societestatic->idprof1 = $objp->idprof1; - $societestatic->idprof2 = $objp->idprof2; - $societestatic->idprof3 = $objp->idprof3; - $societestatic->idprof4 = $objp->idprof4; - $societestatic->idprof5 = $objp->idprof5; - $societestatic->idprof6 = $objp->idprof6; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datelimite = $this->db->jdate($objp->datelimite); + $date = $this->db->jdate($objp->df); + $datem = $this->db->jdate($objp->tms); + + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->statut = $objp->fk_statut; + $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); + + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + $societestatic->tva_intra = $objp->tva_intra; + $societestatic->email = $objp->email; + $societestatic->idprof1 = $objp->idprof1; + $societestatic->idprof2 = $objp->idprof2; + $societestatic->idprof3 = $objp->idprof3; + $societestatic->idprof4 = $objp->idprof4; + $societestatic->idprof5 = $objp->idprof5; + $societestatic->idprof6 = $objp->idprof6; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax200"', - 'text' => $societestatic->getNomUrl(1, '', 40), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $objp->paye), - ); - - $line++; - } - - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); - - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax200"', + 'text' => $societestatic->getNomUrl(1, '', 40), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), + ); + + $line++; + } + + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -219,8 +209,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_factures_fourn.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_factures_fourn.php @@ -31,20 +31,20 @@ */ class box_factures_fourn extends ModeleBoxes { - public $boxcode = "lastsupplierbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxLastSupplierBills"; - public $depends = array("facture", "fournisseur"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "lastsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastSupplierBills"; + public $depends = array("facture", "fournisseur"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,18 +55,18 @@ */ public function __construct($db, $param) { - global $user; - - $this->db = $db; - - $this->hidden = !($user->rights->fournisseur->facture->lire); + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -75,10 +75,10 @@ $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - - $facturestatic = new FactureFournisseur($this->db); - $thirdpartystatic = new Fournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + + $facturestatic = new FactureFournisseur($this->db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array( 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierBills", $max) @@ -86,19 +86,17 @@ if ($user->rights->fournisseur->facture->lire) { - $langs->load("bills"); - - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", f.rowid as facid, f.ref, f.ref_supplier"; - $sql .= ", f.total_ht"; - $sql .= ", f.total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.paye, f.fk_statut as status"; - $sql .= ', f.datef as df'; - $sql .= ', f.datec as datec'; - $sql .= ', f.date_lim_reglement as datelimite, f.tms, f.type'; + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; + $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; + $sql .= " f.total_ht,"; + $sql .= " f.total_tva,"; + $sql .= " f.total_ttc,"; + $sql .= " f.paye, f.fk_statut,"; + $sql .= ' f.datef as df,'; + $sql .= ' f.datec as datec,'; + $sql .= ' f.date_lim_reglement as datelimite, f.tms, f.type'; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -106,8 +104,8 @@ $sql .= " AND f.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -118,101 +116,96 @@ $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - while ($line < $num) { + while ($line < $num) { $objp = $this->db->fetch_object($result); - $datelimite = $this->db->jdate($objp->datelimite); $date = $this->db->jdate($objp->df); $datem = $this->db->jdate($objp->tms); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->date_echeance = $datelimite; - $facturestatic->statut = $objp->status; - $facturestatic->status = $objp->status; - $facturestatic->ref_supplier = $objp->ref_supplier; - - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->name_alias = $objp->name_alias; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->entity = $objp->entity; + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->date_echeance = $datelimite; + $facturestatic->statut = $objp->fk_statut; + $facturestatic->ref_supplier = $objp->ref_supplier; + + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150"', - 'text' => $objp->ref_supplier, - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150"', - 'text' => $thirdpartystatic->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); - - $fac = new FactureFournisseur($this->db); - $fac->fetch($objp->facid); - $alreadypaid = $fac->getSommePaiement(); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type), - ); - - $line++; - } - - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoModifiedSupplierBills"), - ); - - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->transnoentities("ReadPermissionNotAllowed") - ); - } - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150"', + 'text' => $objp->ref_supplier, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); + + $fac = new FactureFournisseur($this->db); + $fac->fetch($objp->facid); + $alreadypaid = $fac->getSommePaiement(); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + ); + + $line++; + } + + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoModifiedSupplierBills"), + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->transnoentities("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -222,8 +215,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_factures_fourn_imp.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_factures_fourn_imp.php @@ -26,24 +26,24 @@ /** - * Class to manage the box to show not paid suppliers invoices + * Class to manage the box to show not payed suppliers invoices */ class box_factures_fourn_imp extends ModeleBoxes { - public $boxcode = "oldestunpaidsupplierbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxOldestUnpaidSupplierBills"; - public $depends = array("facture", "fournisseur"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "oldestunpaidsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidSupplierBills"; + public $depends = array("facture", "fournisseur"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,18 +54,18 @@ */ public function __construct($db, $param) { - global $user; - - $this->db = $db; - - $this->hidden = !($user->rights->fournisseur->facture->lire); + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -76,29 +76,25 @@ include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $facturestatic = new FactureFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartystatic = new Fournisseur($this->db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $max)); if ($user->rights->fournisseur->facture->lire) { - $langs->load("bills"); - - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite"; - $sql .= ", f.datef as df"; - $sql .= ", f.total_ht as total_ht"; - $sql .= ", f.tva as total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.paye, f.fk_statut as status, f.type"; + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; + $sql .= " f.datef as df,"; + $sql .= " f.total_ht as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; + $sql .= " f.paye, f.fk_statut, f.type"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = ".$conf->entity; - $sql .= " AND f.paye = 0"; + $sql .= " AND f.paye=0"; $sql .= " AND fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; @@ -113,7 +109,7 @@ $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - $facturestatic = new FactureFournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); while ($line < $num) { @@ -121,88 +117,81 @@ $datelimite = $this->db->jdate($objp->datelimite); $date = $this->db->jdate($objp->df); $datem = $this->db->jdate($objp->tms); - $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->total_ht = $objp->total_ht; $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->date_echeance = $datelimite; - $facturestatic->statut = $objp->status; - $facturestatic->status = $objp->status; - - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->name_alias = $objp->name_alias; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->entity = $objp->entity; + $facturestatic->statut = $objp->fk_statut; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } - - $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier; - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1 - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartystatic->getNomUrl(1, '', 40), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datelimite, 'day'), - ); + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } + + $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier; + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1 + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datelimite, 'day'), + ); $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); $alreadypaid = $fac->getSommePaiement(); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $alreadypaid, $objp->type), - ); - - $line++; - } - - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoUnpaidSupplierBills"), - ); - - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + ); + + $line++; + } + + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoUnpaidSupplierBills"), + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -212,8 +201,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_factures_imp.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_factures_imp.php @@ -33,20 +33,20 @@ */ class box_factures_imp extends ModeleBoxes { - public $boxcode = "oldestunpaidcustomerbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxOldestUnpaidCustomerBills"; - public $depends = array("facture"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "oldestunpaidcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidCustomerBills"; + public $depends = array("facture"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,18 +57,18 @@ */ public function __construct($db, $param) { - global $user; - - $this->db = $db; - - $this->hidden = !($user->rights->facture->lire); + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -77,10 +77,10 @@ $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - - $facturestatic = new Facture($this->db); - $societestatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); $langs->load("bills"); @@ -88,17 +88,16 @@ if ($user->rights->facture->lire) { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; - $sql .= ", f.ref, f.date_lim_reglement as datelimite"; - $sql .= ", f.type"; - $sql .= ", f.datef as df"; - $sql .= ", f.total as total_ht"; - $sql .= ", f.tva as total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.paye, f.fk_statut as status, f.rowid as facid"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; + $sql .= " s.code_client,"; + $sql .= " s.logo,"; + $sql .= " f.ref, f.date_lim_reglement as datelimite,"; + $sql .= " f.type,"; + $sql .= " f.datef as df,"; + $sql .= " f.total as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; + $sql .= " f.paye, f.fk_statut, f.rowid as facid"; $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -110,8 +109,7 @@ $sql .= " AND fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,"; - $sql .= " f.ref, f.date_lim_reglement,"; + $sql .= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; $sql .= " f.type, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; $sql .= " ORDER BY datelimite ASC, f.ref ASC "; @@ -130,66 +128,54 @@ { $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->datelimite); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->type = $objp->type; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->statut = $objp->status; - $facturestatic->status = $objp->status; + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->statut = $objp->fk_statut; $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $facturestatic->alreadypaid = $objp->paye; - - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - //$societestatic->name_alias = $objp->name_alias; - $societestatic->code_client = $objp->code_client; - $societestatic->code_compta = $objp->code_compta; - $societestatic->client = $objp->client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; - $societestatic->entity = $objp->entity; - $societestatic->tva_intra = $objp->tva_intra; - $societestatic->idprof1 = $objp->idprof1; - $societestatic->idprof2 = $objp->idprof2; - $societestatic->idprof3 = $objp->idprof3; - $societestatic->idprof4 = $objp->idprof4; - $societestatic->idprof5 = $objp->idprof5; - $societestatic->idprof6 = $objp->idprof6; + + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->client = 1; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1, '', 44), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datelimite, 'day'), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->status, 3, $objp->am), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1, '', 44), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datelimite, 'day'), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), + ); $line++; } @@ -200,18 +186,21 @@ ); $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + else + { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } + else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -223,8 +212,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_ficheinter.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_ficheinter.php @@ -31,20 +31,20 @@ */ class box_ficheinter extends ModeleBoxes { - public $boxcode = "ficheinter"; - public $boximg = "object_intervention"; - public $boxlabel = "BoxFicheInter"; - public $depends = array("ficheinter"); // conf->contrat->enabled + public $boxcode = "ficheinter"; + public $boximg = "object_intervention"; + public $boxlabel = "BoxFicheInter"; + public $depends = array("ficheinter"); // conf->contrat->enabled /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,11 +55,11 @@ */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->ficheinter->lire); + $this->hidden = !($user->rights->ficheinter->lire); } /** @@ -67,7 +67,7 @@ * * @param int $max Maximum number of records to load * @return void - */ + */ public function loadBox($max = 10) { global $user, $langs, $conf; @@ -76,19 +76,17 @@ include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $ficheinterstatic = new Fichinter($this->db); - $thirdpartystatic = new Societe($this->db); + $companystatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max)); if (!empty($user->rights->ficheinter->lire)) { - $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status"; - $sql .= ", f.datec"; - $sql .= ", f.date_valid as datev"; - $sql .= ", f.tms as datem"; - $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; + $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut,"; + $sql .= " f.datec,"; + $sql .= " f.date_valid as datev,"; + $sql .= " f.tms as datem,"; + $sql .= " s.nom as name, s.rowid as socid, s.client, s.email as semail"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ", ".MAIN_DB_PREFIX."fichinter as f"; @@ -113,42 +111,35 @@ $objp = $this->db->fetch_object($resql); $datec = $this->db->jdate($objp->datec); - $ficheinterstatic->statut = $objp->status; - $ficheinterstatic->status = $objp->status; + $ficheinterstatic->statut = $objp->fk_statut; $ficheinterstatic->id = $objp->rowid; $ficheinterstatic->ref = $objp->ref; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - //$thirdpartystatic->name_alias = $objp->name_alias; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta = $objp->code_compta; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->entity = $objp->entity; + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + $companystatic->email = $objp->semail; $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $ficheinterstatic->getNomUrl(1), - 'asis' => 1, + 'td' => 'class="nowraponall"', + 'text' => $ficheinterstatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $companystatic->getNomUrl(1), + 'asis' => 1, + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day'), - ); + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'day'), + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowrap right"', - 'text' => $ficheinterstatic->getLibStatut(3), - 'asis' => 1, + 'td' => 'class="nowrap right"', + 'text' => $ficheinterstatic->getLibStatut(3), + 'asis' => 1, ); $i++; @@ -160,17 +151,21 @@ ); $this->db->free($resql); - } else { + } + else + { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } - } else { + } + else + { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -183,8 +178,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_fournisseurs.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_fournisseurs.php @@ -32,134 +32,129 @@ */ class box_fournisseurs extends ModeleBoxes { - public $boxcode = "lastsuppliers"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastSuppliers"; - public $depends = array("fournisseur"); + public $boxcode = "lastsuppliers"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastSuppliers"; + public $depends = array("fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->societe->lire && empty($user->socid)); - } + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - $langs->load("boxes"); + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->load("boxes"); $this->max = $max; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartystatic = new Fournisseur($this->db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); - if ($user->rights->societe->lire) - { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", s.datec, s.tms, s.status"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE s.fournisseur = 1"; - $sql .= " AND s.entity IN (".getEntity('societe').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " ORDER BY s.tms DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->societe->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; + $sql .= " s.code_fournisseur, s.email as semail,"; + $sql .= " s.logo, s.code_compta_fournisseur, s.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.fournisseur = 1"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY s.tms DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) - { - $objp = $this->db->fetch_object($result); - $datec = $this->db->jdate($objp->datec); - $datem = $this->db->jdate($objp->tms); + $line = 0; + while ($line < $num) + { + $objp = $this->db->fetch_object($result); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->semail; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->entity = $objp->entity; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->name_alias = $objp->name_alias; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->entity = $objp->entity; + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3), - ); + $line++; + } - $line++; - } + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedSuppliers"), + ); - if ($num == 0) { - $langs->load("suppliers"); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedSuppliers"), - ); - } - - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -169,8 +164,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_goodcustomers.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_goodcustomers.php @@ -33,27 +33,27 @@ */ class box_goodcustomers extends ModeleBoxes { - public $boxcode = "goodcustomers"; - public $boximg = "object_company"; - public $boxlabel = "BoxGoodCustomers"; - public $depends = array("societe"); + public $boxcode = "goodcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxGoodCustomers"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -69,10 +69,10 @@ } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -81,10 +81,10 @@ $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); if ($user->rights->societe->lire) { @@ -119,24 +119,24 @@ $nbimpaye = $objp->nbfact - $objp->nbfactpaye; $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day") + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day") ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') + 'td' => 'class="right"', + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) ); $line++; @@ -148,16 +148,18 @@ ); $this->db->free($result); - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', + 'td' => 'class="nohover opacitymedium left"', 'text' => $langs->trans("ReadPermissionNotAllowed") ); } @@ -171,8 +173,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_graph_invoices_permonth.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_graph_invoices_permonth.php @@ -28,18 +28,18 @@ */ class box_graph_invoices_permonth extends ModeleBoxes { - public $boxcode = "invoicespermonth"; - public $boximg = "object_bill"; - public $boxlabel = "BoxCustomersInvoicesPerMonth"; - public $depends = array("facture"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "invoicespermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCustomersInvoicesPerMonth"; + public $depends = array("facture"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -111,7 +111,9 @@ $endyear = GETPOST($param_year, 'int'); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); - } else { + } + else + { $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); $endyear = $tmparray['year']; $shownb = $tmparray['shownb']; @@ -120,8 +122,7 @@ if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); - + $startyear = $endyear - 1; $mode = 'customer'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; @@ -142,9 +143,9 @@ $mesg = $px1->isGraphKo(); if (!$mesg) { - $langs->load("bills"); - - $px1->SetData($data1); + $langs->load("bills"); + + $px1->SetData($data1); unset($data1); $i = $startyear; $legend = array(); while ($i <= $endyear) @@ -152,7 +153,9 @@ if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -187,7 +190,7 @@ $mesg = $px2->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); $px2->SetData($data2); unset($data2); @@ -197,7 +200,9 @@ if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -265,13 +270,16 @@ $stringtoshow .= ''; } $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); - } else { + } + else + { $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength'=>500, 'text' => $mesg); } - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover left"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -284,8 +292,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_graph_invoices_supplier_permonth.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_graph_invoices_supplier_permonth.php @@ -28,18 +28,18 @@ */ class box_graph_invoices_supplier_permonth extends ModeleBoxes { - public $boxcode = "invoicessupplierpermonth"; - public $boximg = "object_bill"; - public $boxlabel = "BoxSuppliersInvoicesPerMonth"; - public $depends = array("fournisseur"); + public $boxcode = "invoicessupplierpermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxSuppliersInvoicesPerMonth"; + public $depends = array("fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; - - public $info_box_head = array(); - public $info_box_contents = array(); + * @var DoliDB Database handler. + */ + public $db; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -108,7 +108,9 @@ $endyear = GETPOST($param_year, 'int'); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); - } else { + } + else + { $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); $endyear = $tmparray['year']; $shownb = $tmparray['shownb']; @@ -117,8 +119,7 @@ if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); - + $startyear = $endyear - 1; $mode = 'supplier'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; @@ -131,7 +132,7 @@ $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$year.'.png'; @@ -139,18 +140,20 @@ $mesg = $px1->isGraphKo(); if (!$mesg) { - $langs->load("bills"); - - $px1->SetData($data1); + $langs->load("bills"); + + $px1->SetData($data1); unset($data1); $i = $startyear; - $legend = array(); + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -184,7 +187,7 @@ $mesg = $px2->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); $px2->SetData($data2); unset($data2); @@ -194,7 +197,9 @@ if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -262,18 +267,21 @@ $stringtoshow .= ''; } $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); - } else { + } + else + { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); - } - } else { + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); + } + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -286,8 +294,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_graph_orders_permonth.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_graph_orders_permonth.php @@ -28,18 +28,18 @@ */ class box_graph_orders_permonth extends ModeleBoxes { - public $boxcode = "orderspermonth"; - public $boximg = "object_order"; - public $boxlabel = "BoxCustomersOrdersPerMonth"; - public $depends = array("commande"); + public $boxcode = "orderspermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxCustomersOrdersPerMonth"; + public $depends = array("commande"); /** - * @var DoliDB Database handler. - */ - public $db; - - public $info_box_head = array(); - public $info_box_contents = array(); + * @var DoliDB Database handler. + */ + public $db; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -97,9 +97,9 @@ if ($user->rights->commande->lire) { - $langs->load("orders"); - - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $langs->load("orders"); + + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -111,7 +111,9 @@ $endyear = GETPOST($param_year, 'int'); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); - } else { + } + else + { $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); $endyear = $tmparray['year']; $shownb = $tmparray['shownb']; @@ -120,8 +122,7 @@ if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); - + $startyear = $endyear - 1; $mode = 'customer'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; @@ -134,7 +135,7 @@ $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$endyear.'.png'; @@ -145,13 +146,15 @@ $px1->SetData($data1); unset($data1); $i = $startyear; - $legend = array(); + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -177,7 +180,7 @@ $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$endyear.'.png'; @@ -193,7 +196,9 @@ if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -261,22 +266,25 @@ $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); - } else { + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); + } + else + { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); - } - } else { + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); + } + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -289,8 +297,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_graph_orders_supplier_permonth.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_graph_orders_supplier_permonth.php @@ -28,18 +28,18 @@ */ class box_graph_orders_supplier_permonth extends ModeleBoxes { - public $boxcode = "orderssupplierpermonth"; - public $boximg = "object_order"; - public $boxlabel = "BoxSuppliersOrdersPerMonth"; - public $depends = array("fournisseur"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "orderssupplierpermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxSuppliersOrdersPerMonth"; + public $depends = array("fournisseur"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -96,9 +96,9 @@ if ($user->rights->fournisseur->commande->lire) { - $langs->load("orders"); - - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $langs->load("orders"); + + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -110,7 +110,9 @@ $endyear = GETPOST($param_year, 'int'); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); - } else { + } + else + { $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); $endyear = $tmparray['year']; $shownb = $tmparray['shownb']; @@ -119,8 +121,7 @@ if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); - + $startyear = $endyear - 1; $mode = 'supplier'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; @@ -150,7 +151,9 @@ if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -192,7 +195,9 @@ if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -260,22 +265,25 @@ $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); - } else { + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); + } + else + { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); - } - } else { + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); + } + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -288,8 +296,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_graph_product_distribution.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_graph_product_distribution.php @@ -29,20 +29,20 @@ */ class box_graph_product_distribution extends ModeleBoxes { - public $boxcode = "productdistribution"; - public $boximg = "object_product"; - public $boxlabel = "BoxProductDistribution"; - public $depends = array("product|service", "facture|propal|commande"); + public $boxcode = "productdistribution"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductDistribution"; + public $depends = array("product|service", "facture|propal|commande"); /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -58,7 +58,7 @@ $this->db = $db; $this->hidden = !( - (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) ); @@ -68,7 +68,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -94,7 +94,9 @@ $showinvoicenb = GETPOST($param_showinvoicenb, 'alpha'); $showpropalnb = GETPOST($param_showpropalnb, 'alpha'); $showordernb = GETPOST($param_showordernb, 'alpha'); - } else { + } + else + { $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); $year = $tmparray['year']; $showinvoicenb = $tmparray['showinvoicenb']; @@ -133,12 +135,72 @@ $WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320'; $HEIGHT = '192'; + if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + { + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) + if ($showinvoicenb) + { + $langs->load("bills"); + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; + + $showpointvalue = 1; $nocolor = 0; + $mode = 'customer'; + $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); + $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); + + if (empty($data1)) + { + $showpointvalue = 0; + $nocolor = 1; + $data1 = array(array(0=>$langs->trans("None"), 1=>1)); + } + $filenamenb = $dir."/prodserforinvoice-".$year.".png"; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; + + $px1 = new DolGraph(); + $mesg = $px1->isGraphKo(); + if (!$mesg) + { + $i = 0; $legend = array(); + + foreach ($data1 as $key => $val) + { + $data1[$key][0] = dol_trunc($data1[$key][0], 32); + $legend[] = $data1[$key][0]; + $i++; + } + + $px1->SetData($data1); + unset($data1); + + if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220))); + $px1->SetLegend($legend); + $px1->setShowLegend(2); + $px1->setShowPointValue($showpointvalue); + $px1->setShowPercent(0); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + //$px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + //$px1->SetYLabel($langs->trans("NumberOfBills")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->SetCssPrefix("cssboxes"); + //$px1->mode='depth'; + $px1->SetType(array('pie')); + $px1->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Invoices"))); + $px1->combine = 0.05; + + $px1->draw($filenamenb, $fileurlnb); + } + } + } + if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) { - $langs->load("propal"); + $langs->load("propal"); include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; $showpointvalue = 1; $nocolor = 0; @@ -197,7 +259,7 @@ // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) { - $langs->load("orders"); + $langs->load("orders"); include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; $showpointvalue = 1; $nocolor = 0; @@ -252,71 +314,10 @@ } } - - if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) - { - // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) - if ($showinvoicenb) - { - $langs->load("bills"); - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - - $showpointvalue = 1; $nocolor = 0; - $mode = 'customer'; - $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); - $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); - - if (empty($data1)) - { - $showpointvalue = 0; - $nocolor = 1; - $data1 = array(array(0=>$langs->trans("None"), 1=>1)); - } - $filenamenb = $dir."/prodserforinvoice-".$year.".png"; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; - - $px1 = new DolGraph(); - $mesg = $px1->isGraphKo(); - if (!$mesg) - { - $i = 0; $legend = array(); - - foreach ($data1 as $key => $val) - { - $data1[$key][0] = dol_trunc($data1[$key][0], 32); - $legend[] = $data1[$key][0]; - $i++; - } - - $px1->SetData($data1); - unset($data1); - - if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220))); - $px1->SetLegend($legend); - $px1->setShowLegend(2); - $px1->setShowPointValue($showpointvalue); - $px1->setShowPercent(0); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - //$px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - //$px1->SetYLabel($langs->trans("NumberOfBills")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->SetCssPrefix("cssboxes"); - //$px1->mode='depth'; - $px1->SetType(array('pie')); - $px1->SetTitle($langs->trans("ForObject", $langs->transnoentitiesnoconv("Invoices"))); - $px1->combine = 0.05; - - $px1->draw($filenamenb, $fileurlnb); - } - } - } - if (empty($nbofgraph)) { - $langs->load("errors"); - $mesg = $langs->trans("ReadPermissionNotAllowed"); + $langs->load("errors"); + $mesg = $langs->trans("ReadPermissionNotAllowed"); } if (empty($conf->use_javascript_ajax)) { @@ -340,6 +341,11 @@ $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; + if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire)) + { + $stringtoshow .= ' '.$langs->trans("ForCustomersInvoices"); + $stringtoshow .= '   '; + } if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire)) { $stringtoshow .= ' '.$langs->trans("ForProposals"); @@ -348,11 +354,6 @@ if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire)) { $stringtoshow .= ' '.$langs->trans("ForCustomersOrders"); - } - if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire)) - { - $stringtoshow .= ' '.$langs->trans("ForCustomersInvoices"); - $stringtoshow .= '   '; } $stringtoshow .= '
'; $stringtoshow .= $langs->trans("Year").' '; @@ -362,39 +363,41 @@ if ($nbofgraph == 1) { - if ($showpropalnb) $stringtoshow .= $px2->show(); - elseif ($showordernb) $stringtoshow .= $px3->show(); - else $stringtoshow .= $px1->show(); + if ($showinvoicenb) $stringtoshow .= $px1->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); + else $stringtoshow .= $px3->show(); } if ($nbofgraph == 2) { $stringtoshow .= '
'; - if ($showpropalnb) $stringtoshow .= $px2->show(); - elseif ($showordernb) $stringtoshow .= $px3->show(); + if ($showinvoicenb) $stringtoshow .= $px1->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); $stringtoshow .= '
'; - if ($showinvoicenb) $stringtoshow .= $px1->show(); - elseif ($showordernb) $stringtoshow .= $px3->show(); + if ($showordernb) $stringtoshow .= $px3->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); $stringtoshow .= '
'; } if ($nbofgraph == 3) { $stringtoshow .= '
'; + $stringtoshow .= $px1->show(); + $stringtoshow .= '
'; $stringtoshow .= $px2->show(); - $stringtoshow .= '
'; - $stringtoshow .= $px3->show(); $stringtoshow .= '
'; $stringtoshow .= '
'; - $stringtoshow .= $px1->show(); + $stringtoshow .= $px3->show(); $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); - } else { + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); + } + else + { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', + 'td' => 'class="nohover opacitymedium left"', 'maxlength'=>500, 'text' => $mesg ); @@ -409,8 +412,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_graph_propales_permonth.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_graph_propales_permonth.php @@ -28,18 +28,18 @@ */ class box_graph_propales_permonth extends ModeleBoxes { - public $boxcode = "propalpermonth"; - public $boximg = "object_propal"; - public $boxlabel = "BoxProposalsPerMonth"; - public $depends = array("propal"); + public $boxcode = "propalpermonth"; + public $boximg = "object_propal"; + public $boxlabel = "BoxProposalsPerMonth"; + public $depends = array("propal"); /** - * @var DoliDB Database handler. - */ - public $db; - - public $info_box_head = array(); - public $info_box_contents = array(); + * @var DoliDB Database handler. + */ + public $db; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -111,7 +111,9 @@ $endyear = GETPOST($param_year, 'int'); $shownb = GETPOST($param_shownb, 'alpha'); $showtot = GETPOST($param_showtot, 'alpha'); - } else { + } + else + { $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); $endyear = $tmparray['year']; $shownb = $tmparray['shownb']; @@ -120,8 +122,7 @@ if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) $endyear = $nowarray['year']; - $startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH); - + $startyear = $endyear - 1; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $HEIGHT = '192'; @@ -149,7 +150,9 @@ if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + } + else + { $legend[] = $i; } $i++; @@ -192,8 +195,10 @@ { if ($startmonth != 1) { - $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); - } else { + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); + } + else + { $legend[] = $i; } $i++; @@ -261,22 +266,25 @@ $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); - } else { + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); + } + else + { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength' => 500, - 'text' => $mesg, - ); - } - } else { + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength' => 500, + 'text' => $mesg, + ); + } + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -289,8 +297,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_last_modified_ticket.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_last_modified_ticket.php @@ -31,179 +31,179 @@ class box_last_modified_ticket extends ModeleBoxes { - public $boxcode = "box_last_modified_ticket"; - public $boximg = "ticket"; - public $boxlabel; - public $depends = array("ticket"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); - - /** - * Constructor - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $langs; + public $boxcode = "box_last_modified_ticket"; + public $boximg = "ticket"; + public $boxlabel; + public $depends = array("ticket"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; $langs->load("boxes"); $this->db = $db; - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); - } - - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - - $this->max = $max; - - require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; - - $text = $langs->trans("BoxLastModifiedTicketDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) - ); - - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("BoxLastModifiedTicketContent"), - ); - - if ($user->rights->ticket->read) { - $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - - $sql .= " WHERE t.entity = ".$conf->entity; - // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) { - $sql .= " AND t.fk_soc= ".$user->socid; - } - - $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; - $sql .= $this->db->plimit($max, 0); - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - - $i = 0; - - while ($i < $num) { - $objp = $this->db->fetch_object($resql); - $datec = $this->db->jdate($objp->datec); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - $late = ''; - - $ticket = new Ticket($this->db); - $ticket->id = $objp->id; - $ticket->track_id = $objp->track_id; - $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; - $ticket->subject = $objp->subject; - if ($objp->fk_soc > 0) { - $thirdparty = new Societe($this->db); - $thirdparty->id = $objp->fk_soc; - $thirdparty->email = $objp->socemail; - $thirdparty->client = $objp->client; - $thirdparty->fournisseur = $objp->fournisseur; - $thirdparty->name = $objp->company_name; - $link = $thirdparty->getNomUrl(1); - } else { - $link = dol_print_email($objp->origin_email); - } - - - $r = 0; - - // Ticket - $this->info_box_contents[$i][0] = array( - 'td' => 'class="nowraponall"', - 'text' => $ticket->getNomUrl(1), - 'asis' => 1, - ); - $r++; - - // Subject - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="nowrap"', - 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, - ); - $r++; - - // Customer - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="tdoverflowmax150 maxwidth300onsmartphone"', - 'text' => $link, - 'asis' => 1, - ); - $r++; - - - // Date creation - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'dayhour') - ); - $r++; - - // Statut - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right nowraponall"', - 'text' => $ticket->getLibStatut(3) - ); - $r++; - - $i++; - } - - if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); - } - } else { - dol_print_error($this->db); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed"), - ); - } - } - - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + $this->max = $max; + + require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + + $text = $langs->trans("BoxLastModifiedTicketDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text) + ); + + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastModifiedTicketContent"), + ); + + if ($user->rights->ticket->read) { + $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; + $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; + $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + + $sql .= " WHERE t.entity = ".$conf->entity; + // $sql.= " AND e.rowid = er.fk_event"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= ".$user->socid; + } + + $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + $i = 0; + + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $late = ''; + + $ticket = new Ticket($this->db); + $ticket->id = $objp->id; + $ticket->track_id = $objp->track_id; + $ticket->ref = $objp->ref; + $ticket->fk_statut = $objp->fk_statut; + $ticket->subject = $objp->subject; + if ($objp->fk_soc > 0) { + $thirdparty = new Societe($this->db); + $thirdparty->id = $objp->fk_soc; + $thirdparty->email = $objp->socemail; + $thirdparty->client = $objp->client; + $thirdparty->fournisseur = $objp->fournisseur; + $thirdparty->name = $objp->company_name; + $link = $thirdparty->getNomUrl(1); + } else { + $link = dol_print_email($objp->origin_email); + } + + + $r = 0; + + // Ticket + $this->info_box_contents[$i][0] = array( + 'td' => 'class="nowraponall"', + 'text' => $ticket->getNomUrl(1), + 'asis' => 1, + ); + $r++; + + // Subject + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowrap"', + 'text' => $objp->subject, // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + ); + $r++; + + // Customer + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="tdoverflowmax150 maxwidth300onsmartphone"', + 'text' => $link, + 'asis' => 1, + ); + $r++; + + + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'dayhour') + ); + $r++; + + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $ticket->getLibStatut(3) + ); + $r++; + + $i++; + } + + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); + } + } else { + dol_print_error($this->db); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_last_ticket.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_last_ticket.php @@ -31,177 +31,177 @@ class box_last_ticket extends ModeleBoxes { - public $boxcode = "box_last_ticket"; - public $boximg = "ticket"; - public $boxlabel; - public $depends = array("ticket"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); - - /** - * Constructor - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $langs; - $langs->load("boxes"); - $this->db = $db; - - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); - } - - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - - $this->max = $max; - - require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; - - $text = $langs->trans("BoxLastTicketDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text), - ); - - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("BoxLastTicketContent"), - ); - - if ($user->rights->ticket->read) { - $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - - $sql .= " WHERE t.entity = ".$conf->entity; - // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) { - $sql .= " AND t.fk_soc= ".$user->socid; - } - - //$sql.= " AND t.fk_statut > 9"; - - $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; - $sql .= $this->db->plimit($max, 0); - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - - $i = 0; - - while ($i < $num) { - $objp = $this->db->fetch_object($resql); - $datec = $this->db->jdate($objp->datec); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - $late = ''; - - $ticket = new Ticket($this->db); - $ticket->id = $objp->id; - $ticket->track_id = $objp->track_id; - $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; - $ticket->subject = $objp->subject; - if ($objp->fk_soc > 0) { - $thirdparty = new Societe($this->db); - $thirdparty->id = $objp->fk_soc; - $thirdparty->email = $objp->socemail; - $thirdparty->client = $objp->client; - $thirdparty->fournisseur = $objp->fournisseur; - $thirdparty->name = $objp->company_name; - $link = $thirdparty->getNomUrl(1); - } else { - $link = ''.dol_print_email($objp->origin_email).''; - } - - $r = 0; - - // Ticket - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="nowraponall"', - 'text' => $ticket->getNomUrl(1), - 'asis' => 1 - ); - $r++; - - // Subject - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="tdoverflowmax200"', - 'text' => ''.$objp->subject.'', // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, - ); - $r++; - - // Customer - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="tdoverflowmax100"', - 'text' => $link, - 'asis' => 1, - ); - $r++; - - // Date creation - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'dayhour'), - ); - $r++; - - // Statut - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right nowraponall"', - 'text' => $ticket->getLibStatut(3), - ); - $r++; - - $i++; - } - - if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); - } - } else { - dol_print_error($this->db); - } - } else { - $this->info_box_contents[0][0] = array('td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } - } - - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public $boxcode = "box_last_ticket"; + public $boximg = "ticket"; + public $boxlabel; + public $depends = array("ticket"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; + $langs->load("boxes"); + $this->db = $db; + + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + $this->max = $max; + + require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + + $text = $langs->trans("BoxLastTicketDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text), + ); + + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastTicketContent"), + ); + + if ($user->rights->ticket->read) { + $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; + $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; + $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + + $sql .= " WHERE t.entity = ".$conf->entity; + // $sql.= " AND e.rowid = er.fk_event"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= ".$user->socid; + } + + //$sql.= " AND t.fk_statut > 9"; + + $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + $i = 0; + + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $late = ''; + + $ticket = new Ticket($this->db); + $ticket->id = $objp->id; + $ticket->track_id = $objp->track_id; + $ticket->ref = $objp->ref; + $ticket->fk_statut = $objp->fk_statut; + $ticket->subject = $objp->subject; + if ($objp->fk_soc > 0) { + $thirdparty = new Societe($this->db); + $thirdparty->id = $objp->fk_soc; + $thirdparty->email = $objp->socemail; + $thirdparty->client = $objp->client; + $thirdparty->fournisseur = $objp->fournisseur; + $thirdparty->name = $objp->company_name; + $link = $thirdparty->getNomUrl(1); + } else { + $link = dol_print_email($objp->origin_email); + } + + $r = 0; + + // Ticket + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowraponall"', + 'text' => $ticket->getNomUrl(1), + 'asis' => 1 + ); + $r++; + + // Subject + $this->info_box_contents[$i][$r] = array( + 'td' => '', + 'text' => $objp->subject, // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + ); + $r++; + + // Customer + $this->info_box_contents[$i][$r] = array( + 'td' => '', + 'text' => $link, + 'asis' => 1, + ); + $r++; + + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'dayhour'), + ); + $r++; + + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $ticket->getLibStatut(3), + ); + $r++; + + $i++; + } + + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); + } + } else { + dol_print_error($this->db); + } + } else { + $this->info_box_contents[0][0] = array('td' => 'class="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed")); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_lastlogin.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_lastlogin.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2017 Laurent Destailleur - * Copyright (C) 2014-2020 Frederic France + * Copyright (C) 2014-2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,75 +30,75 @@ */ class box_lastlogin extends ModeleBoxes { - public $boxcode = "lastlogin"; - public $boximg = "object_user"; - public $boxlabel = 'BoxLoginInformation'; - public $depends = array("user"); + public $boxcode = "lastlogin"; + public $boximg = "object_user"; + public $boxlabel = 'BoxLoginInformation'; + public $depends = array("user"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $conf; - $this->db = $db; - } + $this->db = $db; + } - /** - * Charge les donnees en memoire pour affichage ulterieur - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Charge les donnees en memoire pour affichage ulterieur + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $textHead = $langs->trans("BoxLoginInformation"); - $this->info_box_head = array( - 'text' => $textHead, - 'limit'=> dol_strlen($textHead), - ); + $textHead = $langs->trans("BoxLoginInformation"); + $this->info_box_head = array( + 'text' => $textHead, + 'limit'=> dol_strlen($textHead), + ); - $line = 0; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $langs->trans("User"), - ); - $this->info_box_contents[$line][1] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $user->getNomUrl(-1), - 'asis' => 1 - ); + $line = 0; + $this->info_box_contents[$line][0] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $langs->trans("User"), + ); + $this->info_box_contents[$line][1] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $user->getNomUrl(-1), + 'asis' => 1 + ); - $line = 1; - $this->info_box_contents[$line][0] = array( - 'td' => '', - 'text' => $langs->trans("PreviousConnexion"), - ); - if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - else $tmp = $langs->trans("Unknown"); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $tmp, - ); - } + $line = 1; + $this->info_box_contents[$line][0] = array( + 'td' => '', + 'text' => $langs->trans("PreviousConnexion"), + ); + if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + else $tmp = $langs->trans("Unknown"); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $tmp, + ); + } /** @@ -107,10 +107,10 @@ * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return string + * @return void */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + public function showBox($head = null, $contents = null, $nooutput = 0) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_members.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_members.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2020 Frederic France + * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,28 +32,28 @@ */ class box_members extends ModeleBoxes { - public $boxcode = "lastmembers"; - public $boximg = "object_user"; - public $boxlabel = "BoxLastMembers"; - public $depends = array("adherent"); + public $boxcode = "lastmembers"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastMembers"; + public $depends = array("adherent"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -72,7 +72,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -81,15 +81,15 @@ $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $memberstatic = new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); - if ($user->rights->adherent->lire) { + if ($user->rights->adherent->lire) + { $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; - $sql .= ' a.photo, a.email, a.gender, a.morphy,'; $sql .= " t.subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE a.entity IN (".getEntity('member').")"; @@ -98,11 +98,13 @@ $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); - if ($result) { + if ($result) + { $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) { + while ($line < $num) + { $objp = $this->db->fetch_object($result); $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); @@ -110,17 +112,8 @@ $memberstatic->lastname = $objp->lastname; $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; - $memberstatic->ref = $objp->rowid; - $memberstatic->photo = $objp->photo; - $memberstatic->gender = $objp->gender; - $memberstatic->email = $objp->email; - $memberstatic->morphy = $objp->morphy; - $memberstatic->company = $objp->company; - $memberstatic->statut = $objp->status; - $memberstatic->date_creation = $datec; - $memberstatic->date_modification = $datem; - $memberstatic->need_subscription = $objp->subscription; - $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription); + $memberstatic->ref = $objp->rowid; + $memberstatic->company = $objp->company; if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; @@ -130,52 +123,52 @@ $memberstatic->name = $objp->company; } - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->getNomUrl(-1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->company, - 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->company, + 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedCustomers"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedCustomers"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -185,8 +178,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_mos.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_mos.php @@ -32,143 +32,143 @@ */ class box_mos extends ModeleBoxes { - public $boxcode = "lastmos"; - public $boximg = "object_mrp"; - public $boxlabel = "BoxTitleLatestModifiedMos"; - public $depends = array("mrp"); + public $boxcode = "lastmos"; + public $boximg = "object_mrp"; + public $boxlabel = "BoxTitleLatestModifiedMos"; + public $depends = array("mrp"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bom->read); - } + $this->hidden = !($user->rights->bom->read); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $mostatic = new Mo($this->db); - $productstatic = new Product($this->db); - $userstatic = new User($this->db); + $mostatic = new Mo($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); - if ($user->rights->mrp->read) - { - $sql = "SELECT p.ref as product_ref"; - $sql .= ", c.rowid"; - $sql .= ", c.date_creation"; - $sql .= ", c.tms"; - $sql .= ", c.ref"; - $sql .= ", c.status"; - //$sql.= ", c.fk_user_valid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; - $sql .= " WHERE c.fk_product = p.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " ORDER BY c.tms DESC, c.ref DESC"; - $sql .= " ".$this->db->plimit($max, 0); + if ($user->rights->mrp->read) + { + $sql = "SELECT p.ref as product_ref"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + //$sql.= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datem = $this->db->jdate($objp->tms); - $mostatic->id = $objp->rowid; - $mostatic->ref = $objp->ref; - $mostatic->id = $objp->socid; - $mostatic->status = $objp->status; - $productstatic->ref = $objp->product_ref; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem = $this->db->jdate($objp->tms); + $mostatic->id = $objp->rowid; + $mostatic->ref = $objp->ref; + $mostatic->id = $objp->socid; + $mostatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $mostatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $mostatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $mostatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $mostatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=> ''.$langs->trans("NoRecordedOrders").'' - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover left"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -178,8 +178,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_produits.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_produits.php @@ -33,20 +33,20 @@ */ class box_produits extends ModeleBoxes { - public $boxcode = "lastproducts"; - public $boximg = "object_product"; - public $boxlabel = "BoxLastProducts"; - public $depends = array("produit"); + public $boxcode = "lastproducts"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProducts"; + public $depends = array("produit"); /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,21 +57,21 @@ */ public function __construct($db, $param) { - global $conf, $user; - - $this->db = $db; - - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); - $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden = ($showmode != 1); + global $conf, $user; + + $this->db = $db; + + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $this->hidden = ($showmode != 1); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -84,163 +84,151 @@ $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); - if ($user->rights->produit->lire || $user->rights->service->lire) { + if ($user->rights->produit->lire || $user->rights->service->lire) + { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; - $sql .= ", p.accountancy_code_sell"; - $sql .= ", p.accountancy_code_sell_intra"; - $sql .= ", p.accountancy_code_sell_export"; - $sql .= ", p.accountancy_code_buy"; - $sql .= ", p.accountancy_code_buy_intra"; - $sql .= ", p.accountancy_code_buy_export"; - $sql .= ', p.barcode'; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; - if (empty($user->rights->produit->lire)) { - $sql .= ' AND p.fk_product_type != 0'; - } - if (empty($user->rights->service->lire)) { - $sql .= ' AND p.fk_product_type != 1'; - } + if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; + if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks - if (is_object($hookmanager)) { - $parameters = array('boxproductlist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; + if (is_object($hookmanager)) + { + $parameters = array('boxproductlist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } $sql .= $this->db->order('p.datec', 'DESC'); $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); - if ($result) { + if ($result) + { $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) { + while ($line < $num) + { $objp = $this->db->fetch_object($result); $datem = $this->db->jdate($objp->tms); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { $sqld = "SELECT label"; $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sqld .= " WHERE fk_product=".$objp->rowid; - $sqld .= " AND lang='".$this->db->escape($langs->getDefaultLang())."'"; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); - if ($resultd) { + if ($resultd) + { $objtp = $this->db->fetch_object($resultd); - if (isset($objtp->label) && $objtp->label != '') { + if (isset($objtp->label) && $objtp->label != '') $objp->label = $objtp->label; - } } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->type = $objp->fk_product_type; - $productstatic->label = $objp->label; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; - $productstatic->status = $objp->tosell; - $productstatic->status_buy = $objp->tobuy; - $productstatic->barcode = $objp->barcode; - $productstatic->accountancy_code_sell = $objp->accountancy_code_sell; - $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra; - $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export; - $productstatic->accountancy_code_buy = $objp->accountancy_code_buy; - $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra; - $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $objp->label, - ); - $price = ''; - $price_base_type = ''; - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { - $price_base_type = $langs->trans($objp->price_base_type); - $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else { - //Parse the dynamic price + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $objp->label, + ); + $price = ''; + $price_base_type = ''; + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); + } + else //Parse the dynamic price + { $productstatic->fetch($objp->rowid, '', '', 1); - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($productstatic); - if ($price_result >= 0) { - if ($objp->price_base_type == 'HT') { + $priceparser = new PriceParser($this->db); + $price_result = $priceparser->parseProduct($productstatic); + if ($price_result >= 0) { + if ($objp->price_base_type == 'HT') + { $price_base_type = $langs->trans("HT"); - } else { + } + else + { $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); $price_base_type = $langs->trans("TTC"); } $price = price($price_result); - } - } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $price, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowrap"', - 'text' => $price_base_type, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', - 'asis' => 1 - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 1).'', - 'asis' => 1 - ); - - $line++; - } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProducts"), - ); - } - - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } - - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + } + } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $price, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowrap"', + 'text' => $price_base_type, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', + 'asis' => 1 + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 1).'', + 'asis' => 1 + ); + + $line++; + } + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProducts"), + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_produits_alerte_stock.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_produits_alerte_stock.php @@ -35,20 +35,20 @@ */ class box_produits_alerte_stock extends ModeleBoxes { - public $boxcode = "productsalertstock"; - public $boximg = "object_product"; - public $boxlabel = "BoxProductsAlertStock"; - public $depends = array("produit"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "productsalertstock"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductsAlertStock"; + public $depends = array("produit"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -59,21 +59,21 @@ */ public function __construct($db, $param = '') { - global $conf, $user; - - $this->db = $db; - - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); - $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden = ($showmode != 1); + global $conf, $user; + + $this->db = $db; + + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $this->hidden = ($showmode != 1); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -99,16 +99,16 @@ if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks - if (is_object($hookmanager)) - { - $parameters = array('boxproductalertstocklist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; - } - $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,"; - $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; - $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; - $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; + if (is_object($hookmanager)) + { + $parameters = array('boxproductalertstocklist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + } + $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,"; + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; + $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; $sql .= $this->db->order('p.seuil_stock_alerte', 'DESC'); $sql .= $this->db->plimit($max, 0); @@ -118,11 +118,11 @@ $langs->load("stocks"); $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datem = $this->db->jdate($objp->tms); - $price = ''; - $price_base_type = ''; + $price = ''; + $price_base_type = ''; // Multilangs if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active @@ -130,7 +130,7 @@ $sqld = "SELECT label"; $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sqld .= " WHERE fk_product=".$objp->rowid; - $sqld .= " AND lang='".$this->db->escape($langs->getDefaultLang())."'"; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; $sqld .= " LIMIT 1"; $resultd = $this->db->query($sqld); @@ -141,10 +141,10 @@ $objp->label = $objtp->label; } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->type = $objp->fk_product_type; - $productstatic->label = $objp->label; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; $productstatic->barcode = $objp->barcode; $productstatic->status = $objp->tosell; @@ -156,87 +156,93 @@ $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra; $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $objp->label, - ); - - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) - { - $price_base_type = $langs->trans($objp->price_base_type); - $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $objp->label, + ); + + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) + { + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); + } + else //Parse the dynamic price + { $productstatic->fetch($objp->rowid, '', '', 1); - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($productstatic); - if ($price_result >= 0) { + $priceparser = new PriceParser($this->db); + $price_result = $priceparser->parseProduct($productstatic); + if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); - } else { + } + else + { $price_result = $price_result * (1 + ($productstatic->tva_tx / 100)); $price_base_type = $langs->trans("TTC"); } $price = price($price_result); - } - } + } + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => $price, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $price_base_type, + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => $price, + 'td' => 'class="center"', + 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, + 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', + 'asis' => 1 ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $price_base_type, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, - 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', - 'asis' => 1 - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 0).'', - 'asis' => 1 - ); - - $line++; - } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoTooLowStockProducts"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 0).'', + 'asis' => 1 + ); + + $line++; + } + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoTooLowStockProducts"), + ); $this->db->free($result); - } else { + } + else + { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + } + else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -248,8 +254,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_project.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_project.php @@ -31,174 +31,175 @@ */ class box_project extends ModeleBoxes { - public $boxcode = "project"; - public $boximg = "object_projectpub"; - public $boxlabel; - //var $depends = array("projet"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $user, $langs; - - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); - - $this->db = $db; - $this->boxlabel = "OpenedProjects"; - - $this->hidden = !($user->rights->projet->lire); - } - - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - - $this->max = $max; - - $totalMnt = 0; - $totalnb = 0; - $totalnbTask = 0; - - $textHead = $langs->trans("OpenedProjects"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - - // list the summary of the orders - if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); - - $socid = 0; - //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. - - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId = ''; - if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + public $boxcode = "project"; + public $boximg = "object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs; + + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); + + $this->db = $db; + $this->boxlabel = "OpenedProjects"; + + $this->hidden = !($user->rights->projet->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + + $this->max = $max; + + $totalMnt = 0; + $totalnb = 0; + $totalnbTask = 0; + + $textHead = $langs->trans("OpenedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); + + $socid = 0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok $sql .= " AND p.fk_statut = 1"; // Only open projects - if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - - $sql .= " ORDER BY p.datec DESC"; - //$sql.= $this->db->plimit($max, 0); - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < min($num, $max)) { - $objp = $this->db->fetch_object($result); - - $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; - $projectstatic->title = $objp->title; - $projectstatic->public = $objp->public; - $projectstatic->statut = $objp->status; - - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 - ); - - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $objp->title, - ); - - $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql .= " WHERE p.entity IN (".getEntity('project').')'; - $sql .= " AND p.rowid = ".$objp->rowid; - $resultTask = $this->db->query($sql); - if ($resultTask) { - $objTask = $this->db->fetch_object($resultTask); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objTask->nb." ".$langs->trans("Tasks"), - ); - if ($objTask->nb > 0) - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", - ); - else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - $totalnbTask += $objTask->nb; - } else { - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - } - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); - - $i++; - } - if ($max < $num) - { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); - $i++; - } - } - } - - - // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => round($num, 0)." ".$langs->trans("Projects"), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - } - - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + + $sql .= " ORDER BY p.datec DESC"; + //$sql.= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < min($num, $max)) { + $objp = $this->db->fetch_object($result); + + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; + $projectstatic->title = $objp->title; + $projectstatic->public = $objp->public; + $projectstatic->statut = $objp->status; + + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $objp->title, + ); + + $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql .= " WHERE p.entity IN (".getEntity('project').')'; + $sql .= " AND p.rowid = ".$objp->rowid; + $resultTask = $this->db->query($sql); + if ($resultTask) { + $objTask = $this->db->fetch_object($resultTask); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objTask->nb." ".$langs->trans("Tasks"), + ); + if ($objTask->nb > 0) + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", + ); + else + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + $totalnbTask += $objTask->nb; + } else { + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + } + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); + + $i++; + } + if ($max < $num) + { + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $i++; + } + } + } + + + // Add the sum à the bottom of the boxes + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total")." ".$textHead, + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => round($num, 0)." ".$langs->trans("Projects"), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_propales.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_propales.php @@ -33,164 +33,155 @@ */ class box_propales extends ModeleBoxes { - public $boxcode = "lastpropals"; - public $boximg = "object_propal"; - public $boxlabel = "BoxLastProposals"; - public $depends = array("propal"); // conf->propal->enabled + public $boxcode = "lastpropals"; + public $boximg = "object_propal"; + public $boxlabel = "BoxLastProposals"; + public $depends = array("propal"); // conf->propal->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->propale->lire); - } + $this->hidden = !($user->rights->propale->lire); + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $propalstatic = new Propal($this->db); - $societestatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $propalstatic = new Propal($this->db); + $societestatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max)); - if ($user->rights->propale->lire) - { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", p.rowid, p.ref, p.fk_statut as status, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; - else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->propale->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; + $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE p.fk_soc = s.rowid"; + $sql .= " AND p.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; + else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $now = dol_now(); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $now = dol_now(); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->dp); - $datec = $this->db->jdate($objp->datec); - $datem = $this->db->jdate($objp->tms); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - - $propalstatic->id = $objp->rowid; - $propalstatic->ref = $objp->ref; - $propalstatic->total_ht = $objp->total_ht; - $propalstatic->total_tva = $objp->total_tva; - $propalstatic->total_ttc = $objp->total_ttc; - $propalstatic->statut = $objp->status; - $propalstatic->status = $objp->status; - - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - //$societestatic->name_alias = $objp->name_alias; - $societestatic->code_client = $objp->code_client; - $societestatic->code_compta = $objp->code_compta; - $societestatic->client = $objp->client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->dp); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $propalstatic->id = $objp->rowid; + $propalstatic->ref = $objp->ref; + $propalstatic->total_ht = $objp->total_ht; + $propalstatic->total_tva = $objp->total_tva; + $propalstatic->total_ttc = $objp->total_ttc; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; + $societestatic->email = $objp->email; $societestatic->entity = $objp->entity; - $late = ''; - if ($objp->status == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { - $late = img_warning($langs->trans("Late")); - } + $late = ''; + if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { + $late = img_warning($langs->trans("Late")); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $propalstatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $propalstatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $propalstatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProposals"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProposals"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -200,8 +191,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_prospect.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_prospect.php @@ -34,27 +34,27 @@ */ class box_prospect extends ModeleBoxes { - public $boxcode = "lastprospects"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastProspects"; - public $depends = array("societe"); + public $boxcode = "lastprospects"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastProspects"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -72,7 +72,7 @@ * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -86,11 +86,13 @@ if ($user->rights->societe->lire) { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", s.fk_stcomm"; - $sql .= ", s.datec, s.tms, s.status"; + $sql = "SELECT s.nom as name, s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.client, s.email"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.fk_stcomm, s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (2, 3)"; @@ -112,61 +114,59 @@ $objp = $this->db->fetch_object($resql); $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->name_alias = $objp->name_alias; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_compta = $objp->code_compta; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->entity = $objp->entity; + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => str_replace('img ', 'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => str_replace('img ', 'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3), - ); + $line++; + } - $line++; - } + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=> $langs->trans("NoRecordedProspects"), + ); + } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=> $langs->trans("NoRecordedProspects"), - ); - } - - $this->db->free($resql); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength' => 500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + $this->db->free($resql); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -178,8 +178,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_services_contracts.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_services_contracts.php @@ -32,20 +32,20 @@ */ class box_services_contracts extends ModeleBoxes { - public $boxcode = "lastproductsincontract"; - public $boximg = "object_product"; - public $boxlabel = "BoxLastProductsInContract"; - public $depends = array("service", "contrat"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "lastproductsincontract"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProductsInContract"; + public $depends = array("service", "contrat"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,18 +56,18 @@ */ public function __construct($db, $param) { - global $user; - - $this->db = $db; - - $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -83,15 +83,15 @@ if ($user->rights->service->lire && $user->rights->contrat->lire) { - $contractstatic = new Contrat($this->db); - $contractlinestatic = new ContratLigne($this->db); - $thirdpartytmp = new Societe($this->db); - $productstatic = new Product($this->db); + $contractstatic = new Contrat($this->db); + $contractlinestatic = new ContratLigne($this->db); + $thirdpartytmp = new Societe($this->db); + $productstatic = new Product($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; - $sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut as contractline_status, cd.product_type as type, cd.date_fin_validite as date_line,"; - $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as product_type, p.entity, p.tobuy, p.tosell"; + $sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type, cd.date_fin_validite as date_line,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; @@ -125,8 +125,6 @@ $contractlinestatic->type = $objp->type; $contractlinestatic->product_id = $objp->product_id; $contractlinestatic->product_ref = $objp->product_ref; - $contractlinestatic->product_type = $objp->product_type; - $contractlinestatic->statut = $objp->contractline_status; $contractstatic->id = $objp->rowid; $contractstatic->ref = $objp->ref; @@ -145,69 +143,88 @@ $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; $dateline = $this->db->jdate($objp->date_line); - if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->contractline_status == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->statut == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + + // Multilangs + if (!empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on + { + $sqld = "SELECT label"; + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sqld .= " WHERE fk_product=".$objp->product_id; + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; + $sqld .= " LIMIT 1"; + + $resultd = $this->db->query($sqld); + if ($resultd) + { + $objtp = $this->db->fetch_object($resultd); + if ($objtp->label != '') $contractlinestatic->label = $objtp->label; + } + } // Label if ($objp->product_id > 0) { $productstatic->id = $objp->product_id; - $productstatic->type = $objp->product_type; + $productstatic->type = $objp->ptype; $productstatic->ref = $objp->product_ref; $productstatic->entity = $objp->pentity; - $productstatic->label = $objp->product_label; + $productstatic->label = $objp->plabel; $productstatic->status = $objp->tosell; $productstatic->status_buy = $objp->tobuy; $text = $productstatic->getNomUrl(1, '', 20); - if ($objp->product_label) + if ($objp->plabel) { $text .= ' - '; //$productstatic->ref=$objp->label; //$text .= $productstatic->getNomUrl(0,'',16); - $text .= $objp->product_label; + $text .= $objp->plabel; } $description = $objp->description; // Add description in form if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - //$text .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; + //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
'.dol_htmlentitiesbr($objp->description):''; $description = ''; // Already added into main visible desc } - $s = $form->textwithtooltip($text, $description, 3, '', '', '', 0, (!empty($objp->fk_parent_line) ?img_picto('', 'rightarrow') : '')); - } else { + $s = $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); + } + else + { $s = img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description); } $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $s, - 'asis' => 1 - ); - - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contractstatic->getNomUrl(1), - 'asis' => 1 - ); - - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1), - 'asis' => 1 - ); - - $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => dol_print_date($datem, 'day'), + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $s, + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contractstatic->getNomUrl(1), + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1), + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array( + 'td' => '', + 'text' => dol_print_date($datem, 'day'), 'text2'=> $late, - ); - - $this->info_box_contents[$i][] = array( - 'td' => 'class="right" width="18"', - 'text' => $contractlinestatic->getLibStatut(3) + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="right" width="18"', + 'text' => $contractlinestatic->LibStatut($objp->statut, 3) ); $i++; @@ -218,17 +235,20 @@ ); $this->db->free($result); - } else { + } + else + { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength' => 500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error().' sql='.$sql), + ); } - } else { + } + else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -241,8 +261,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_services_expired.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_services_expired.php @@ -30,160 +30,164 @@ class box_services_expired extends ModeleBoxes { - public $boxcode = "expiredservices"; // id of box - public $boximg = "object_contract"; - public $boxlabel = "BoxOldestExpiredServices"; - public $depends = array("contrat"); // conf->propal->enabled - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - - public $info_box_head = array(); - public $info_box_contents = array(); - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; - - $this->db = $db; - - $this->hidden = !($user->rights->contrat->lire); - } - - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - - $this->max = $max; - - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - - $now = dol_now(); - - $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); - - if ($user->rights->contrat->lire) - { - // Select contracts with at least one expired service + public $boxcode = "expiredservices"; // id of box + public $boximg = "object_contract"; + public $boxlabel = "BoxOldestExpiredServices"; + public $depends = array("contrat"); // conf->propal->enabled + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->hidden = !($user->rights->contrat->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + + $now = dol_now(); + + $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); + + if ($user->rights->contrat->lire) + { + // Select contracts with at least one expired service $sql = "SELECT "; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; $sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; - $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; - if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; - $sql .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; - $sql .= " ORDER BY date_line ASC"; - $sql .= $this->db->plimit($max, 0); - - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - - $i = 0; - - $thirdpartytmp = new Societe($this->db); - $contract = new Contrat($this->db); - - while ($i < $num) - { - $late = ''; - - $objp = $this->db->fetch_object($resql); - - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->client = $objp->client; - $thirdpartytmp->fournisseur = $objp->fournisseur; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->code_compta = $objp->code_compta; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - - $contract->id = $objp->rowid; - $contract->ref = $objp->ref; - $contract->statut = $objp->fk_statut; - $contract->ref_customer = $objp->ref_customer; - $contract->ref_supplier = $objp->ref_supplier; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; + if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; + $sql .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= " ORDER BY date_line ASC"; + $sql .= $this->db->plimit($max, 0); + + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + + $i = 0; + + $thirdpartytmp = new Societe($this->db); + $contract = new Contrat($this->db); + + while ($i < $num) + { + $late = ''; + + $objp = $this->db->fetch_object($resql); + + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + + $contract->id = $objp->rowid; + $contract->ref = $objp->ref; + $contract->statut = $objp->fk_statut; + $contract->ref_customer = $objp->ref_customer; + $contract->ref_supplier = $objp->ref_supplier; $dateline = $this->db->jdate($objp->date_line); if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contract->getNomUrl(1), - 'asis' => 1 - ); - - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone left"', - 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), - 'asis' => 1 - ); - - $this->info_box_contents[$i][] = array( - 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateline, 'day'), - 'text2'=> $late, - ); - - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objp->nb_services, - ); - - - $i++; - } - - if ($num == 0) - { - $langs->load("contracts"); - $this->info_box_contents[$i][] = array( - 'td' => 'class="nohover opacitymedium center"', - 'text' => $langs->trans("NoExpiredServices"), - ); - } + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contract->getNomUrl(1), + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone left"', + 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), + 'asis' => 1 + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="center nowraponall"', + 'text' => dol_print_date($dateline, 'day'), + 'text2'=> $late, + ); + + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objp->nb_services, + ); + + + $i++; + } + + if ($num == 0) + { + $langs->load("contracts"); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nohover opacitymedium center"', + 'text' => $langs->trans("NoExpiredServices"), + ); + } $this->db->free($resql); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + } + else + { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } + else + { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -193,8 +197,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_shipments.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_shipments.php @@ -32,156 +32,152 @@ */ class box_shipments extends ModeleBoxes { - public $boxcode = "lastcustomershipments"; - public $boximg = "sending"; - public $boxlabel = "BoxLastCustomerShipments"; - public $depends = array("expedition"); + public $boxcode = "lastcustomershipments"; + public $boximg = "sending"; + public $boxlabel = "BoxLastCustomerShipments"; + public $depends = array("expedition"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->expedition->lire); - } + $this->hidden = !($user->rights->expedition->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->loadLangs(array('orders', 'sendings')); + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->loadLangs(array('orders', 'sendings')); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $shipmentstatic = new Expedition($this->db); - $orderstatic = new Commande($this->db); - $societestatic = new Societe($this->db); + $shipmentstatic = new Expedition($this->db); + $orderstatic = new Commande($this->db); + $societestatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); - if ($user->rights->expedition->lire) - { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_client, s.code_compta, s.client"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", e.ref, e.tms"; - $sql .= ", e.rowid"; - $sql .= ", e.ref_customer"; - $sql .= ", e.fk_statut"; - $sql .= ", e.fk_user_valid"; - $sql .= ", c.ref as commande_ref"; - $sql .= ", c.rowid as commande_id"; - $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; - if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; - if ($user->socid > 0) $sql.= " AND s.rowid = ".$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; - else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->expedition->lire) + { + $sql = "SELECT s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", e.ref, e.tms"; + $sql .= ", e.rowid"; + $sql .= ", e.ref_customer"; + $sql .= ", e.fk_statut"; + $sql .= ", e.fk_user_valid"; + $sql .= ", c.ref as commande_ref"; + $sql .= ", c.rowid as commande_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql .= " WHERE e.entity = ".$conf->entity; + if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; + else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $shipmentstatic->id = $objp->rowid; - $shipmentstatic->ref = $objp->ref; - $shipmentstatic->ref_customer = $objp->ref_customer; + $shipmentstatic->id = $objp->rowid; + $shipmentstatic->ref = $objp->ref; + $shipmentstatic->ref_customer = $objp->ref_customer; - $orderstatic->id = $objp->commande_id; - $orderstatic->ref = $objp->commande_ref; + $orderstatic->id = $objp->commande_id; + $orderstatic->ref = $objp->commande_ref; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - //$societestatic->name_alias = $objp->name_alias; - $societestatic->code_client = $objp->code_client; - $societestatic->code_compta = $objp->code_compta; - $societestatic->client = $objp->client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; - $societestatic->entity = $objp->entity; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $shipmentstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $shipmentstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $orderstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $orderstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedShipments") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedShipments") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -191,8 +187,8 @@ * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_supplier_orders.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_supplier_orders.php @@ -31,164 +31,162 @@ class box_supplier_orders extends ModeleBoxes { - public $boxcode = "latestsupplierorders"; - public $boximg = "object_order"; - public $boxlabel = "BoxLatestSupplierOrders"; - public $depends = array("fournisseur"); + public $boxcode = "latestsupplierorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLatestSupplierOrders"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); - } + $this->hidden = !($user->rights->fournisseur->commande->lire); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - $langs->load("boxes"); + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->load("boxes"); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic = new CommandeFournisseur($this->db); - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartystatic = new Fournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $supplierorderstatic = new CommandeFournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); - if ($user->rights->fournisseur->commande->lire) - { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", c.rowid, c.ref, c.tms, c.date_commande"; - $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; - $sql .= ", c.total_ttc"; - $sql .= ", c.fk_statut as status"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->fournisseur->commande->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " s.code_client, s.code_fournisseur,"; + $sql .= " s.logo, s.email,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); + $line = 0; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); $datem = $this->db->jdate($objp->tms); $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; - $supplierorderstatic->statut = $objp->status; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - //$thirdpartystatic->name_alias = $objp->name_alias; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->entity = $objp->entity; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $supplierorderstatic->getNomUrl(1), + 'asis' => 1 + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $supplierorderstatic->getNomUrl(1), - 'asis' => 1 - ); + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartystatic->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $line++; + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + if ($num == 0) + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoSupplierOrder"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $supplierorderstatic->LibStatut($objp->status, 3), - ); + $this->db->free($result); + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } + else + { + $this->info_box_contents[0][] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } - $line++; - } - - if ($num == 0) - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoSupplierOrder"), - ); - - $this->db->free($result); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][] = array( - 'td' => 'class="nohover left"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' - ); - } - } - - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_supplier_orders_awaiting_reception.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_supplier_orders_awaiting_reception.php @@ -31,168 +31,169 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes { - public $boxcode = "supplierordersawaitingreception"; - public $boximg = "object_order"; - public $boxlabel = "BoxLatestSupplierOrdersAwaitingReception"; - public $depends = array("fournisseur"); + public $boxcode = "supplierordersawaitingreception"; + public $boximg = "object_order"; + public $boxlabel = "BoxLatestSupplierOrdersAwaitingReception"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); - } + $this->hidden = !($user->rights->fournisseur->commande->lire); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - $langs->loadLangs(array("boxes", "sendings", "orders")); + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->loadLangs(array("boxes", "sendings", "orders")); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic = new CommandeFournisseur($this->db); - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartystatic = new Fournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $supplierorderstatic = new CommandeFournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleSupplierOrdersAwaitingReception", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleSupplierOrdersAwaitingReception", $max)); - if ($user->rights->fournisseur->commande->lire) - { - $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; - $sql .= ", s.logo, s.email, s.entity"; - $sql .= ", c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison as delivery_date"; - $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; - $sql .= ", c.total_ttc"; - $sql .= ", c.fk_statut as status"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC"; - else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC"; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->fournisseur->commande->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " s.code_client, s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison, "; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $sql .= " AND c.fk_statut = ".CommandeFournisseur::STATUS_ORDERSENT; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC "; + $sql .= $this->db->plimit($max, 0); - $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); - $delivery_date = $this->db->jdate($objp->delivery_date); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + + $line = 0; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); + $date_livraison = $this->db->jdate($objp->date_livraison); $datem = $this->db->jdate($objp->tms); + + $supplierorderstatic->date_livraison = $date_livraison; + $supplierorderstatic->statut = $objp->fk_statut; $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; - $supplierorderstatic->delivery_date = $delivery_date; - $supplierorderstatic->statut = $objp->status; - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - //$thirdpartystatic->name_alias = $objp->name_alias; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->entity = $objp->entity; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $supplierorderstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $supplierorderstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartystatic->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $delayIcon = ''; - if ($supplierorderstatic->hasDelay()) { - $delayIcon = img_warning($langs->trans("Late")); - } + $delayIcon = ''; + if ($supplierorderstatic->hasDelay()) { + $delayIcon = img_warning($langs->trans("Late")); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $delayIcon.' '.dol_print_date($delivery_date, 'day').'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $delayIcon.' '.dol_print_date($date_livraison, 'day').'', + 'asis' => 1 + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoSupplierOrder"), - ); + if ($num == 0) + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoSupplierOrder"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } + else + { + $this->info_box_contents[0][] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_box_task.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_box_task.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2020 Frederic France +/* Copyright (C) 2012-2018 Charlene BENKE + * Copyright (C) 2015-2019 Frederic France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,41 +31,41 @@ */ class box_task extends ModeleBoxes { - public $boxcode = "projettask"; - public $boximg = "object_projecttask"; - public $boxlabel; - public $depends = array("projet"); - - /** - * @var DoliDB Database handler. - */ - public $db; - - public $param; - public $enabled = 1; // enable because fixed ;-). - - public $info_box_head = array(); - public $info_box_contents = array(); - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $conf, $user, $langs; - - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); - - $this->boxlabel = "Tasks"; - $this->db = $db; - - $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); - } + public $boxcode = "projettask"; + public $boximg = "object_projecttask"; + public $boxlabel; + public $depends = array("projet"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; // enable because fixed ;-). + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user, $langs; + + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); + + $this->boxlabel = "Tasks"; + $this->db = $db; + + $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); + } /** * Load data for box to show them later @@ -80,93 +80,96 @@ $this->max = $max; include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php"; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; - $projectstatic = new Project($this->db); + require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; + $projectstatic = new Project($this->db); $taskstatic = new Task($this->db); $form = new Form($this->db); - $cookie_name = 'DOLUSERCOOKIE_boxfilter_task'; - $boxcontent = ''; - $socid = $user->socid; - - $textHead = $langs->trans("CurentlyOpenedTasks"); - - $filterValue = 'all'; - if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { - $filterValue = GETPOST($cookie_name); - } elseif (!empty($_COOKIE[$cookie_name])) { - $filterValue = preg_replace('/[^a-z_]/', '', $_COOKIE[$cookie_name]); // Clean cookie from evil data - } - - if ($filterValue == 'im_task_contact') { - $textHead .= ' : '.$langs->trans("WhichIamLinkedTo"); - } elseif ($filterValue == 'im_project_contact') { - $textHead .= ' : '.$langs->trans("WhichIamLinkedToProject"); - } + $cookie_name = 'DOLUSERCOOKIE_boxfilter_task'; + $boxcontent = ''; + $socid = $user->socid; + + $textHead = $langs->trans("CurentlyOpenedTasks"); + + $filterValue = 'all'; + if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { + $filterValue = GETPOST($cookie_name); + } + elseif (!empty($_COOKIE[$cookie_name])) { + $filterValue = $_COOKIE[$cookie_name]; + } + + if ($filterValue == 'im_task_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedTo"); + } + elseif ($filterValue == 'im_project_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedToProject"); + } $this->info_box_head = array( - 'text' => $textHead, - 'limit'=> dol_strlen($textHead), - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" - ); + 'text' => $textHead, + 'limit'=> dol_strlen($textHead), + 'sublink'=>'', + 'subtext'=>$langs->trans("Filter"), + 'subpicto'=>'filter.png', + 'subclass'=>'linkobject boxfilter', + 'target'=>'none' // Set '' to get target="_blank" + ); // list the summary of the orders if ($user->rights->projet->lire) { - $boxcontent .= '
'."\n"; - $boxcontent .= '
'."\n"; - $boxcontent .= '
boxcode.'">'."\n"; - $boxcontent .= ''."\n"; - $selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject")); - $boxcontent .= $form->selectArray($cookie_name, $selectArray, $filterValue); - $boxcontent .= ''; - $boxcontent .= '
'."\n"; - $boxcontent .= '
'."\n"; - if (!empty($conf->use_javascript_ajax)) { - $boxcontent .= ''; - // set cookie by js - $boxcontent .= ''; - } - $this->info_box_contents[0][] = array( - 'tr' => 'class="nohover showiffilter'.$this->boxcode.' hideobject"', - 'td' => 'class="nohover"', - 'textnoformat' => $boxcontent, - ); - - - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId = ''; - if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - - $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; + // set cookie by js + $boxcontent .= ''; + } + $this->info_box_contents[0][] = array( + 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', + 'td' => 'class="nohover"', + 'textnoformat' => $boxcontent, + ); + + + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + + $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; $sql .= ", p.rowid project_id, p.ref project_ref, p.title project_title"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; $sql .= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; - if ($filterValue === 'im_task_contact') { - $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = ".((int) $user->id).")"; - $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; - } elseif ($filterValue === 'im_project_contact') { - $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = ".((int) $user->id).")"; - $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; - } + if ($filterValue === 'im_task_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '".$user->id."' )"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; + } + elseif ($filterValue === 'im_project_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '".$user->id."' )"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; + } $sql .= " WHERE "; $sql .= " pt.entity = ".$conf->entity; $sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED; $sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed - $sql .= " AND p.usage_task = 1 "; - if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + $sql .= " AND p.usage_task = 1 "; + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql .= " ORDER BY pt.datee ASC, pt.dateo ASC"; $sql .= $this->db->plimit($max, 0); @@ -175,33 +178,33 @@ $i = 1; if ($result) { $num = $this->db->num_rows($result); - while ($objp = $this->db->fetch_object($result)) { - $taskstatic->id = $objp->rowid; - $taskstatic->ref = $objp->ref; - $taskstatic->label = $objp->label; - $taskstatic->progress = $objp->progress; - $taskstatic->fk_statut = $objp->fk_statut; - $taskstatic->date_end = $this->db->jdate($objp->datee); - $taskstatic->planned_workload = $objp->planned_workload; - $taskstatic->duration_effective = $objp->duration_effective; - - $projectstatic->id = $objp->project_id; - $projectstatic->ref = $objp->project_ref; - $projectstatic->title = $objp->project_title; - - $label = $projectstatic->getNomUrl(1).'   '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - - $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); - - $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => $boxcontent, - ); + while ($objp = $this->db->fetch_object($result)) { + $taskstatic->id = $objp->rowid; + $taskstatic->ref = $objp->ref; + $taskstatic->label = $objp->label; + $taskstatic->progress = $objp->progress; + $taskstatic->fk_statut = $objp->fk_statut; + $taskstatic->date_end = $objp->datee; + $taskstatic->planned_workload = $objp->planned_workload; + $taskstatic->duration_effective = $objp->duration_effective; + + $projectstatic->id = $objp->project_id; + $projectstatic->ref = $objp->project_ref; + $projectstatic->title = $objp->project_title; + + $label = $projectstatic->getNomUrl(1).' '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); + + $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); + + $this->info_box_contents[$i][] = array( + 'td' => '', + 'text' => $boxcontent, + ); $i++; } } else { - dol_print_error($this->db); - } + dol_print_error($this->db); + } } } --- /tmp/dsg/dolibarr/htdocs/core/boxes/github_modules_boxes.php +++ /tmp/dsg/dolibarr/htdocs/core/boxes/client_modules_boxes.php @@ -56,7 +56,7 @@ /** * @var boolean Condition to have widget visible (in most cases, permissions) */ - public $hidden = false; + public $hidden = 0; /** * @var int Box definition database ID @@ -113,7 +113,7 @@ * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -143,10 +143,10 @@ global $conf; // Recupere liste des boites d'un user si ce dernier a sa propre liste - $sql = "SELECT b.rowid as id, b.box_id, b.position, b.box_order, b.fk_user"; + $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."boxes as b"; $sql .= " WHERE b.entity = ".$conf->entity; - $sql .= " AND b.rowid = ".((int) $rowid); + $sql .= " AND b.rowid = ".$rowid; dol_syslog(get_class($this)."::fetch rowid=".$rowid); $resql = $this->db->query($sql); @@ -155,19 +155,45 @@ $obj = $this->db->fetch_object($resql); if ($obj) { - $this->id = $obj->id; - $this->rowid = $obj->id; // For backward compatibility + $this->rowid = $obj->rowid; $this->box_id = $obj->box_id; $this->position = $obj->position; $this->box_order = $obj->box_order; $this->fk_user = $obj->fk_user; return 1; - } else { + } + else + { return -1; } - } else { + } + else + { return -1; } + } + + + /** + * Standard method to get content of a box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * + * @return string + */ + public function outputBox($head = null, $contents = null) + { + global $langs, $user, $conf; + + // Trick to get result into a var from a function that makes print instead of return + // TODO Replace ob_start with param nooutput=1 into showBox + ob_start(); + $result = $this->showBox($head, $contents); + $output = ob_get_contents(); + ob_end_clean(); + + return $output; } /** @@ -184,180 +210,180 @@ if (!empty($this->hidden)) return '\n\n'; // Nothing done if hidden (for example when user has no permission) - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $MAXLENGTHBOX = 60; // Mettre 0 pour pas de limite - $cachetime = 900; // 900 : 15mn - $cachedir = DOL_DATA_ROOT.'/boxes/temp'; - $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; - $filename = '/box-'.$fileid; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $out = ''; - - if ($refresh) { - dol_syslog(get_class($this).'::showBox'); - - // Define nbcol and nblines of the box to show - $nbcol = 0; - if (isset($contents[0])) $nbcol = count($contents[0]); - $nblines = count($contents); - - $out .= "\n\n"; - - $out .= '
'."\n"; - - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) - { - $out .= ''."\n"; - } - - // Show box title - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) - { - $out .= ''; - $out .= ' 0) { $out .= ' colspan="'.$nbcol.'"'; } - $out .= '>'; - if (!empty($conf->use_javascript_ajax)) - { - //$out.= '
'; - - if (!empty($conf->use_javascript_ajax)) - { - $sublink = ''; - if (!empty($head['sublink'])) $sublink .= ''; - if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); - if (!empty($head['sublink'])) $sublink .= ''; - - //$out.= '
'; - $out .= '
'; - } - if (!empty($head['text'])) - { - $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); - $out .= $s; - } - if (!empty($conf->use_javascript_ajax)) - { - $out .= '
'; - } - //$out.= '
'; - $out .= '
'; - $out .= $sublink; - // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"'); - $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"'); - $label = $head['text']; - //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; - if (!empty($head['graph'])) $label .= ' '; - $out .= ''; - //$out.= '
'; - $out .= '
'; - } - - $out .= ""; - $out .= "\n"; - } - - // Show box lines - if ($nblines) - { - // Loop on each record - for ($i = 0, $n = $nblines; $i < $n; $i++) - { - if (isset($contents[$i])) - { - // TR - if (isset($contents[$i][0]['tr'])) $out .= ''; - else $out .= ''; - - // Loop on each TD - $nbcolthisline = count($contents[$i]); - for ($j = 0; $j < $nbcolthisline; $j++) { - // Define tdparam - $tdparam = ''; - if (!empty($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; - - $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; - $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); - $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; - $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); - - $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; - //$out.= "xxx $textwithnotags y"; - if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = ""; - $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; - - $out .= ''."\n"; - - // Url - if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) - { - $out .= 'trans("Show").' '.$tooltip, 1).'" class="classfortooltip"'; - } - //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "" - $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : ''; - $out .= '>'; - } - - // Logo - if (!empty($contents[$i][$j]['logo'])) - { - $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); - $out .= ''; - $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); - } - - $maxlength = $MAXLENGTHBOX; - if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength']; - - if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength); - if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning - else $out .= $textwithnotags; // show text with html cleaning - - // End Url - if (!empty($contents[$i][$j]['url'])) $out .= ''; - - if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning - else $out .= $text2withnotags; // show text with html cleaning - - if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n"; - - $out .= "\n"; - } - - $out .= "\n"; - } - } - } - - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) - { - $out .= "\n"; - } - - // If invisible box with no contents - if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "
\n"; - - $out .= "\n"; - - $out .= "\n\n"; - if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $out); - } - } else { - dol_syslog(get_class($this).'::showBoxCached'); - $out = ""; - $out .= dol_readcachefile($cachedir, $filename); - } - - if ($nooutput) return $out; - else print $out; - - return ''; + $cachetime = 900; // 900 : 15mn + $cachedir = DOL_DATA_ROOT.'/boxes/temp'; + $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; + $filename = '/box-'.$fileid; + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $out = ''; + + if ($refresh) { + dol_syslog(get_class($this).'::showBox'); + + // Define nbcol and nblines of the box to show + $nbcol = 0; + if (isset($contents[0])) $nbcol = count($contents[0]); + $nblines = count($contents); + + $out .= "\n\n"; + + $out .= '
'."\n"; + + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) + { + $out .= ''."\n"; + } + + // Show box title + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) + { + $out .= ''; + $out .= ' 0) { $out .= ' colspan="'.$nbcol.'"'; } + $out .= '>'; + if (!empty($conf->use_javascript_ajax)) + { + //$out.= '
'; + + if (!empty($conf->use_javascript_ajax)) + { + $sublink = ''; + if (!empty($head['sublink'])) $sublink .= ''; + if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); + if (!empty($head['sublink'])) $sublink .= ''; + + //$out.= '
'; + $out .= '
'; + } + if (!empty($head['text'])) + { + $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); + $out .= $s; + } + if (!empty($conf->use_javascript_ajax)) + { + $out .= '
'; + } + //$out.= '
'; + $out .= '
'; + $out .= $sublink; + // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object + $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"'); + $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"'); + $label = $head['text']; + //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; + if (!empty($head['graph'])) $label .= ' '; + $out .= ''; + //$out.= '
'; + $out .= '
'; + } + + $out .= ""; + $out .= "\n"; + } + + // Show box lines + if ($nblines) + { + // Loop on each record + for ($i = 0, $n = $nblines; $i < $n; $i++) + { + if (isset($contents[$i])) + { + // TR + if (isset($contents[$i][0]['tr'])) $out .= ''; + else $out .= ''; + + // Loop on each TD + $nbcolthisline = count($contents[$i]); + for ($j = 0; $j < $nbcolthisline; $j++) { + // Define tdparam + $tdparam = ''; + if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; + + $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; + $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); + $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; + $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); + + $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; + //$out.= "xxx $textwithnotags y"; + if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = ""; + $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; + + $out .= ''."\n"; + + // Url + if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) + { + $out .= 'trans("Show").' '.$tooltip, 1).'" class="classfortooltip"'; + } + //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "" + $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : ''; + $out .= '>'; + } + + // Logo + if (!empty($contents[$i][$j]['logo'])) + { + $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); + $out .= ''; + $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); + } + + $maxlength = $MAXLENGTHBOX; + if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength']; + + if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength); + if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning + else $out .= $textwithnotags; // show text with html cleaning + + // End Url + if (!empty($contents[$i][$j]['url'])) $out .= ''; + + if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning + else $out .= $text2withnotags; // show text with html cleaning + + if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n"; + + $out .= "\n"; + } + + $out .= "\n"; + } + } + } + + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) + { + $out .= "\n"; + } + + // If invisible box with no contents + if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "
\n"; + + $out .= "\n"; + + $out .= "\n\n"; + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $out); + } + } else { + dol_syslog(get_class($this).'::showBoxCached'); + $out = ""; + $out .= dol_readcachefile($cachedir, $filename); + } + + if ($nooutput) return $out; + else print $out; + + return ''; } @@ -400,7 +426,6 @@ { while (($file = readdir($handle)) !== false) { - $reg = array(); if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $file, $reg)) { if (preg_match('/\.back$/', $file)) continue; @@ -413,10 +438,13 @@ { $langs->load("errors"); print '
'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget", $modName, "").'
'; - } else { + } + else + { try { include_once $newdir.'/'.$file; - } catch (Exception $e) + } + catch (Exception $e) { print $e->getMessage(); } @@ -458,7 +486,6 @@ { // Define disabledbyname and disabledbymodule $disabledbyname = 0; - $disabledbymodule = 0; // TODO Set to 2 if module is not enabled $module = ''; // Check if widget file is disabled by name @@ -477,7 +504,7 @@ $text = ''.$langs->trans("Description").':
'; $text .= $objMod->boxlabel.'
'; $text .= '
'.$langs->trans("Status").':
'; - if ($disabledbymodule == 2) $text .= $langs->trans("WidgetDisabledAsModuleDisabled", $module).'
'; + if ($disabledbymodule == 2) $text .= $langs->trans("HooksDisabledAsModuleDisabled", $module).'
'; $widget[$j]['info'] = $text; }