diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 994b604ae78..67718e7fb8e 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -71,14 +71,14 @@ class box_actions extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $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($db); - $actionstatic = new ActionComm($db); + $societestatic = new Societe($this->db); + $actionstatic = new ActionComm($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo", $max)); @@ -99,20 +99,20 @@ class box_actions extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; $sql.= " ORDER BY a.datec DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog("Box_actions::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { $now=dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { $late = ''; - $objp = $db->fetch_object($result); - $datelimite = $db->jdate($objp->dp); + $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; @@ -164,12 +164,12 @@ class box_actions extends ModeleBoxes 'text'=>$langs->trans("NoActionsToDo"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 72116993505..0b690240db6 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -76,7 +76,7 @@ class box_activity extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -103,7 +103,7 @@ class box_activity extends ModeleBoxes if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic=new Propal($db); + $propalstatic=new Propal($this->db); $cachedir = DOL_DATA_ROOT.'/propale/temp'; $filename = '/boxactivity-propal'.$fileid; @@ -119,27 +119,27 @@ class box_activity extends ModeleBoxes $sql.= " AND p.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND p.datep >= '".$db->idate($tmpdate)."'"; + $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 = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $j=0; while ($j < $num) { - $data[$j]=$db->fetch_object($result); + $data[$j]=$this->db->fetch_object($result); $j++; } if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } - $db->free($result); + $this->db->free($result); } else { - dol_print_error($db); + dol_print_error($this->db); } } else @@ -190,7 +190,7 @@ class box_activity extends ModeleBoxes // 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($db); + $commandestatic=new Commande($this->db); $langs->load("orders"); @@ -209,24 +209,24 @@ class box_activity extends ModeleBoxes $sql.= " AND c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'"; + $sql.= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'"; $sql.= " GROUP BY c.fk_statut"; $sql.= " ORDER BY c.fk_statut DESC"; - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $j=0; while ($j < $num) { - $data[$j]=$db->fetch_object($result); + $data[$j]=$this->db->fetch_object($result); $j++; } if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } - $db->free($result); + $this->db->free($result); } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $data = dol_readcachefile($cachedir, $filename); @@ -275,7 +275,7 @@ class box_activity extends ModeleBoxes if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic=new Facture($db); + $facturestatic=new Facture($this->db); // part 1 $cachedir = DOL_DATA_ROOT.'/facture/temp'; @@ -293,24 +293,24 @@ class box_activity extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1"; + $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 = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $j=0; while ($j < $num) { - $data[$j]=$db->fetch_object($result); + $data[$j]=$this->db->fetch_object($result); $j++; } if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } - $db->free($result); + $this->db->free($result); } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $data = dol_readcachefile($cachedir, $filename); @@ -373,24 +373,24 @@ class box_activity extends ModeleBoxes $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 >= '".$db->idate($tmpdate)."' AND f.paye=0"; + $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 = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $j=0; while ($j < $num) { - $data[$j]=$db->fetch_object($result); + $data[$j]=$this->db->fetch_object($result); $j++; } if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $data); } - $db->free($result); + $this->db->free($result); } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $data = dol_readcachefile($cachedir, $filename); diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index f15c5c8d1cb..8204543540e 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -71,13 +71,13 @@ class box_birthdays extends ModeleBoxes */ public function loadBox($max = 20) { - global $user, $langs, $db; + global $user, $langs; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $userstatic=new User($db); + $userstatic=new User($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); @@ -89,23 +89,23 @@ class box_birthdays extends ModeleBoxes $sql.= " WHERE u.entity IN (".getEntity('user').")"; $sql.= " AND MONTH(u.birth) = ".date('m'); $sql.= " ORDER BY u.birth ASC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $userstatic->id = $objp->rowid; $userstatic->firstname = $objp->firstname; $userstatic->lastname = $objp->lastname; $userstatic->email = $objp->email; - $dateb=$db->jdate($objp->birth); + $dateb=$this->db->jdate($objp->birth); $age = date('Y', dol_now()) - date('Y', $dateb); $this->info_box_contents[$line][] = array( @@ -129,13 +129,13 @@ class box_birthdays extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedUsers")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql) + 'text' => ($this->db->error().' sql='.$sql) ); } } diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 446b74a184c..45f64adce42 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -71,42 +71,42 @@ class box_birthdays_members extends ModeleBoxes */ public function loadBox($max = 20) { - global $user, $langs, $db; + global $user, $langs; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic=new Adherent($db); + $memberstatic=new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); if ($user->rights->adherent->lire) { $sql = "SELECT u.rowid, u.firstname, u.lastname"; - $sql.= ", u.birth"; + $sql.= ", u.birth"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as u"; $sql.= " WHERE u.entity IN (".getEntity('adherent').")"; - $sql.= " AND u.statut = 1"; - $sql.= " AND date_format(u.birth, '%m-%d') >= date_format(curdate(), '%m-%d')"; + $sql.= " AND u.statut = 1"; + $sql.= " AND date_format(u.birth, '%m-%d') >= date_format(curdate(), '%m-%d')"; $sql.= " ORDER BY date_format(u.birth, '%m-%d') ASC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $memberstatic->id = $objp->rowid; $memberstatic->firstname = $objp->firstname; $memberstatic->lastname = $objp->lastname; $memberstatic->email = $objp->email; - $dateb=$db->jdate($objp->birth); + $dateb=$this->db->jdate($objp->birth); $age = date('Y', dol_now()) - date('Y', $dateb); $this->info_box_contents[$line][] = array( @@ -130,13 +130,13 @@ class box_birthdays_members extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedUsers")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql) + 'text' => ($this->db->error().' sql='.$sql) ); } } diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index bb35c311f00..6edd7fa9866 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -67,7 +67,7 @@ class box_bookmarks extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; @@ -92,18 +92,18 @@ class box_bookmarks extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b"; $sql.= " WHERE fk_user = ".$user->id; $sql.= " AND b.entity = ".$conf->entity; - $sql.= $db->order("position", "ASC"); - $sql.= $db->plimit($max, 0); + $sql.= $this->db->order("position", "ASC"); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', @@ -133,12 +133,12 @@ class box_bookmarks extends ModeleBoxes ); } - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index ea2a7814f14..858a99921f3 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -74,13 +74,13 @@ class box_clients extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($db); + $thirdpartystatic=new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); @@ -103,20 +103,20 @@ class box_clients extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND s.rowid = $user->societe_id"; $sql.= " ORDER BY s.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $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->code_client = $objp->code_client; @@ -149,13 +149,13 @@ class box_clients extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql) + 'text' => ($this->db->error().' sql='.$sql) ); } } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index e0d7d1fee4d..9084b6ad71a 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -71,16 +71,16 @@ class box_commandes extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $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($db); - $societestatic = new Societe($db); - $userstatic = new User($db); + $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)); @@ -110,18 +110,18 @@ class box_commandes extends ModeleBoxes if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; 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.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $date=$db->jdate($objp->date_commande); - $datem=$db->jdate($objp->tms); + $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; @@ -174,12 +174,12 @@ class box_commandes extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 1928ac7cc94..4cd053b82fc 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -77,7 +77,7 @@ class box_comptes extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; @@ -97,19 +97,19 @@ class box_comptes extends ModeleBoxes $sql.= " AND clos = 0"; //$sql.= " AND courant = 1"; $sql.= " ORDER BY label"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; $solde_total = array(); - $account_static = new Account($db); + $account_static = new Account($this->db); while ($line < $num) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $account_static->id = $objp->rowid; $account_static->ref = $objp->ref; @@ -160,12 +160,12 @@ class box_comptes extends ModeleBoxes $line++; } - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 667f892bc0a..02f62324200 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -73,7 +73,7 @@ class box_contacts extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; @@ -93,21 +93,21 @@ class box_contacts extends ModeleBoxes if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; $sql.= " ORDER BY sp.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); - $contactstatic=new Contact($db); - $societestatic=new Societe($db); + $contactstatic=new Contact($this->db); + $societestatic=new Societe($this->db); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datec=$this->db->jdate($objp->datec); + $datem=$this->db->jdate($objp->tms); $contactstatic->id=$objp->id; $contactstatic->lastname=$objp->lastname; @@ -161,12 +161,12 @@ class box_contacts extends ModeleBoxes 'text'=>$langs->trans("NoRecordedContacts"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 43ade84ad20..eb4a8c44ed0 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -70,7 +70,7 @@ class box_contracts extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; @@ -80,11 +80,12 @@ class box_contracts extends ModeleBoxes if ($user->rights->contrat->lire) { - $contractstatic=new Contrat($db); - $thirdpartytmp=new Societe($db); + $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.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->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; @@ -93,12 +94,12 @@ class box_contracts extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; 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.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $now=dol_now(); $line = 0; @@ -107,16 +108,18 @@ class box_contracts extends ModeleBoxes while ($line < $num) { - $objp = $db->fetch_object($resql); + $objp = $this->db->fetch_object($resql); - $datec=$db->jdate($objp->datec); - $dateterm=$db->jdate($objp->fin_validite); - $dateclose=$db->jdate($objp->date_cloture); + $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(); $thirdpartytmp->name = $objp->name; @@ -165,12 +168,12 @@ class box_contracts extends ModeleBoxes 'text'=>$langs->trans("NoRecordedContracts"), ); - $db->free($resql); + $this->db->free($resql); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 05ab5db50fd..fd1203ac520 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -69,15 +69,15 @@ class box_factures extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $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($db); - $societestatic = new Societe($db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); $langs->load("bills"); @@ -105,22 +105,22 @@ class box_factures extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; 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.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $now=dol_now(); $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; while ($line < $num) { - $objp = $db->fetch_object($result); - $datelimite = $db->jdate($objp->datelimite); - $date = $db->jdate($objp->df); - $datem = $db->jdate($objp->tms); + $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; @@ -129,7 +129,7 @@ class box_factures extends ModeleBoxes $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; - $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite); + $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -185,12 +185,12 @@ class box_factures extends ModeleBoxes 'text'=>$langs->trans("NoRecordedInvoices"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 9d2e8e995e3..05cd900623e 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -70,15 +70,15 @@ class box_factures_fourn extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $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($db); - $thirdpartytmp = new Fournisseur($db); + $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) @@ -87,7 +87,7 @@ class box_factures_fourn extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql.= " s.code_fournisseur,"; + $sql.= " s.code_fournisseur, s.email,"; $sql.= " s.logo,"; $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; $sql.= " f.total_ht,"; @@ -106,21 +106,21 @@ class box_factures_fourn extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; 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.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; while ($line < $num) { - $objp = $db->fetch_object($result); - $datelimite=$db->jdate($objp->datelimite); - $date=$db->jdate($objp->df); - $datem=$db->jdate($objp->tms); + $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; @@ -133,6 +133,7 @@ class box_factures_fourn extends ModeleBoxes $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; @@ -173,7 +174,7 @@ class box_factures_fourn extends ModeleBoxes 'text' => dol_print_date($date, 'day'), ); - $fac = new FactureFournisseur($db); + $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); $alreadypaid=$fac->getSommePaiement(); $this->info_box_contents[$line][] = array( @@ -190,12 +191,12 @@ class box_factures_fourn extends ModeleBoxes 'text'=>$langs->trans("NoModifiedSupplierBills"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index a28f275dc96..b6066255a17 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -69,14 +69,14 @@ class box_factures_fourn_imp extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $facturestatic=new FactureFournisseur($db); + $facturestatic=new FactureFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp=new Fournisseur($db); + $thirdpartytmp=new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $max)); @@ -99,24 +99,24 @@ class box_factures_fourn_imp extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY datelimite DESC, f.ref_supplier DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - $facturestatic = new FactureFournisseur($db); + $facturestatic = new FactureFournisseur($this->db); while ($line < $num) { - $objp = $db->fetch_object($result); - $datelimite=$db->jdate($objp->datelimite); - $date=$db->jdate($objp->df); - $datem=$db->jdate($objp->tms); + $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; @@ -160,7 +160,7 @@ class box_factures_fourn_imp extends ModeleBoxes 'text' => dol_print_date($datelimite, 'day'), ); - $fac = new FactureFournisseur($db); + $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); $alreadypaid=$fac->getSommePaiement(); $this->info_box_contents[$line][] = array( @@ -177,12 +177,12 @@ class box_factures_fourn_imp extends ModeleBoxes 'text'=>$langs->trans("NoUnpaidSupplierBills"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 5dfa6c8c492..9880d236a8e 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -72,15 +72,15 @@ class box_factures_imp extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $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($db); - $societestatic = new Societe($db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills", $max)); @@ -111,12 +111,12 @@ class box_factures_imp extends ModeleBoxes $sql.= " f.type, f.amount, 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 "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $now=dol_now(); $line = 0; @@ -124,8 +124,8 @@ class box_factures_imp extends ModeleBoxes while ($line < $num) { - $objp = $db->fetch_object($result); - $datelimite=$db->jdate($objp->datelimite); + $objp = $this->db->fetch_object($result); + $datelimite=$this->db->jdate($objp->datelimite); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->type = $objp->type; @@ -133,7 +133,7 @@ class box_factures_imp extends ModeleBoxes $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; - $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite); + $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -180,14 +180,14 @@ class box_factures_imp extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 8311ae7226c..2755e7a3f0d 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -70,12 +70,13 @@ class box_ficheinter extends ModeleBoxes */ public function loadBox($max = 10) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; - $ficheinterstatic=new Fichinter($db); + $ficheinterstatic=new Fichinter($this->db); + $companystatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max)); @@ -85,7 +86,7 @@ class box_ficheinter extends ModeleBoxes $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"; + $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"; @@ -94,42 +95,40 @@ class box_ficheinter extends ModeleBoxes if (! $user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY f.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this).'::loadBox', LOG_DEBUG); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $now=dol_now(); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($resql); - $datec=$db->jdate($objp->datec); + $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); $ficheinterstatic->statut=$objp->fk_statut; $ficheinterstatic->id=$objp->rowid; $ficheinterstatic->ref=$objp->ref; + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; + $companystatic->email = $objp->semail; + $this->info_box_contents[$i][] = array( 'td' => '', 'text' => $ficheinterstatic->getNomUrl(1), 'asis' => 1, ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="left" width="16"', - 'logo' => 'company', - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, - ); - $this->info_box_contents[$i][] = array( 'td' => '', - 'text' => dol_trunc($objp->name, 40), - 'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid, + 'text' => $companystatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$i][] = array( @@ -148,14 +147,14 @@ class box_ficheinter extends ModeleBoxes if ($num==0) $this->info_box_contents[$i][] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedInterventions")); - $db->free($resql); + $this->db->free($resql); } else { $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 8d231cc472b..ff73e80b21c 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -70,15 +70,15 @@ class box_fournisseurs extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($db); + $thirdpartystatic=new Societe($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp=new Fournisseur($db); + $thirdpartytmp=new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); @@ -94,19 +94,19 @@ class box_fournisseurs extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY s.tms DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $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->code_client = $objp->code_client; @@ -136,12 +136,12 @@ class box_fournisseurs extends ModeleBoxes 'text'=>$langs->trans("NoRecordedSuppliers"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index ea973caf773..3f0cea0651a 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -76,13 +76,13 @@ class box_goodcustomers extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($db); + $thirdpartystatic=new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); @@ -90,25 +90,25 @@ class box_goodcustomers extends ModeleBoxes { $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; - $sql.= " count(*) as nbfact, sum(". $db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; + $sql.= " count(*) as nbfact, sum(". $this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; $sql.= ' AND s.rowid = f.fk_soc'; $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; - $sql.= $db->order("nbfact", "DESC"); - $sql.= $db->plimit($max, 0); + $sql.= $this->db->order("nbfact", "DESC"); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->rowid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->code_client = $objp->code_client; @@ -145,13 +145,13 @@ class box_goodcustomers extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 6e5afe5df99..b83630f8916 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -65,14 +65,14 @@ class box_graph_invoices_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; $refreshaction='refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - //$facturestatic=new Facture($db); + //$facturestatic=new Facture($this->db); $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index df4f4afc146..0b395946731 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -65,7 +65,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index b530b4ea268..1a1e29fb47a 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -65,14 +65,14 @@ class box_graph_orders_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; $refreshaction='refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - //$commandestatic=new Commande($db); + //$commandestatic=new Commande($this->db); $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 8359ddbe070..da956670779 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -65,7 +65,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index d32c9bb1918..dac5137938a 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -72,7 +72,7 @@ class box_graph_product_distribution extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 36a35c3bbc2..98b12cf65f4 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -65,14 +65,14 @@ class box_graph_propales_permonth extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; $refreshaction='refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - //$propalstatic=new Propal($db); + //$propalstatic=new Propal($this->db); $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index e9f00049e04..4de36596cc7 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -47,11 +47,14 @@ class box_last_modified_ticket extends ModeleBoxes /** * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters */ - public function __construct() + public function __construct($db, $param = '') { global $langs; - $langs->load("boxes"); + $langs->load("boxes"); + $this->db = $db; $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); } @@ -64,7 +67,7 @@ class box_last_modified_ticket extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max = $max; @@ -72,8 +75,8 @@ class box_last_modified_ticket extends ModeleBoxes $text = $langs->trans("BoxLastModifiedTicketDescription", $max); $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) + 'text' => $text, + 'limit' => dol_strlen($text) ); $this->info_box_contents[0][0] = array( @@ -99,20 +102,20 @@ class box_last_modified_ticket extends ModeleBoxes } $sql.= " ORDER BY t.tms DESC, t.rowid DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $now=gmmktime(); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($resql); - $datec=$db->jdate($objp->datec); - $dateterm=$db->jdate($objp->fin_validite); - $dateclose=$db->jdate($objp->date_cloture); + $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); @@ -157,7 +160,7 @@ class box_last_modified_ticket extends ModeleBoxes // Date creation $this->info_box_contents[$i][$r] = array( 'td' => 'class="right"', - 'text' => dol_print_date($db->idate($objp->datec), 'dayhour') + 'text' => dol_print_date($this->db->idate($objp->datec), 'dayhour') ); $r++; @@ -177,7 +180,7 @@ class box_last_modified_ticket extends ModeleBoxes $this->info_box_contents[$i][0] = array('td' => 'class="center"','text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); } } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $this->info_box_contents[0][0] = array( diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 352a10db682..708c4e97633 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -46,11 +46,14 @@ class box_last_ticket extends ModeleBoxes /** * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters */ - public function __construct() + public function __construct($db, $param = '') { global $langs; $langs->load("boxes"); + $this->db = $db; $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); } @@ -63,7 +66,7 @@ class box_last_ticket extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max = $max; @@ -100,20 +103,20 @@ class box_last_ticket extends ModeleBoxes //$sql.= " AND t.fk_statut > 9"; $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; - $sql .= $db->plimit($max, 0); + $sql .= $this->db->plimit($max, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $now = gmmktime(); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($resql); - $datec = $db->jdate($objp->datec); - $dateterm = $db->jdate($objp->fin_validite); - $dateclose = $db->jdate($objp->date_cloture); + $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); @@ -156,7 +159,7 @@ class box_last_ticket extends ModeleBoxes // Date creation $this->info_box_contents[$i][$r] = array( 'td' => 'class="right"', - 'text' => dol_print_date($db->idate($objp->datec), 'dayhour'), + 'text' => dol_print_date($this->db->idate($objp->datec), 'dayhour'), ); $r++; @@ -176,7 +179,7 @@ class box_last_ticket extends ModeleBoxes $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); } } else { - dol_print_error($db); + dol_print_error($this->db); } } else { $this->info_box_contents[0][0] = array('td' => 'class="left"', diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 8a5b90ae9d5..997f3b8ca26 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -68,7 +68,7 @@ class box_lastlogin extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $textHead = $langs->trans("BoxLoginInformation"); $this->info_box_head = array( diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index b0f1200dec7..20bf6ca136f 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -76,13 +76,13 @@ class box_members extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $langs->load("boxes"); $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic=new Adherent($db); + $memberstatic=new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); @@ -95,19 +95,19 @@ class box_members extends ModeleBoxes $sql.= " WHERE a.entity IN (".getEntity('member').")"; $sql.= " AND a.fk_adherent_type = t.rowid"; $sql.= " ORDER BY a.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datec=$this->db->jdate($objp->datec); + $datem=$this->db->jdate($objp->tms); $memberstatic->lastname=$objp->lastname; $memberstatic->firstname=$objp->firstname; @@ -142,7 +142,7 @@ class box_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', - 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $db->jdate($objp->date_end_subscription), 3), + 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), ); $line++; @@ -154,12 +154,12 @@ class box_members extends ModeleBoxes 'text'=>$langs->trans("NoRecordedCustomers"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 68c1b4c790b..0f094c5369e 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -75,12 +75,12 @@ class box_produits extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf, $hookmanager; + global $user, $langs, $conf, $hookmanager; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $productstatic=new Product($db); + $productstatic=new Product($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastProducts", $max)); @@ -98,18 +98,18 @@ class box_produits extends ModeleBoxes $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; } - $sql.= $db->order('p.datec', 'DESC'); - $sql.= $db->plimit($max, 0); + $sql.= $this->db->order('p.datec', 'DESC'); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); // Multilangs if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active @@ -120,10 +120,10 @@ class box_produits extends ModeleBoxes $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; $sqld.= " LIMIT 1"; - $resultd = $db->query($sqld); + $resultd = $this->db->query($sqld); if ($resultd) { - $objtp = $db->fetch_object($resultd); + $objtp = $this->db->fetch_object($resultd); if (isset($objtp->label) && $objtp->label != '') $objp->label = $objtp->label; } @@ -202,12 +202,12 @@ class box_produits extends ModeleBoxes 'text'=>$langs->trans("NoRecordedProducts"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 095709c2ea8..4f285c990cc 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -77,19 +77,19 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf, $hookmanager; + global $user, $langs, $conf, $hookmanager; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $productstatic=new Product($db); + $productstatic=new Product($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max)); if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire) { $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, p.entity,"; - $sql.= " SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; + $sql.= " SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") as total_stock"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; @@ -104,19 +104,19 @@ class box_produits_alerte_stock extends ModeleBoxes $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.seuil_stock_alerte, p.entity"; - $sql.= " HAVING SUM(".$db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; - $sql.= $db->order('p.seuil_stock_alerte', 'DESC'); - $sql.= $db->plimit($max, 0); + $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); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { $langs->load("stocks"); - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->tms); + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); $price = ''; $price_base_type = ''; @@ -129,10 +129,10 @@ class box_produits_alerte_stock extends ModeleBoxes $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; $sqld.= " LIMIT 1"; - $resultd = $db->query($sqld); + $resultd = $this->db->query($sqld); if ($resultd) { - $objtp = $db->fetch_object($resultd); + $objtp = $this->db->fetch_object($resultd); if (isset($objtp->label) && $objtp->label != '') $objp->label = $objtp->label; } @@ -214,14 +214,14 @@ class box_produits_alerte_stock extends ModeleBoxes 'text'=>$langs->trans("NoTooLowStockProducts"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 3cd36c470fe..f1265bc6658 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -72,7 +72,7 @@ class box_project extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $this->max=$max; @@ -102,15 +102,15 @@ class box_project extends ModeleBoxes 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.= $db->plimit($max, 0); + //$sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $i = 0; while ($i < min($num, $max)) { - $objp = $db->fetch_object($result); + $objp = $this->db->fetch_object($result); $projectstatic->id = $objp->rowid; $projectstatic->ref = $objp->ref; @@ -132,9 +132,9 @@ class box_project extends ModeleBoxes $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 = $db->query($sql); + $resultTask = $this->db->query($sql); if ($resultTask) { - $objTask = $db->fetch_object($resultTask); + $objTask = $this->db->fetch_object($resultTask); $this->info_box_contents[$i][] = array( 'td' => 'class="right"', 'text' => $objTask->nb." ".$langs->trans("Tasks"), diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index f486463a32a..3b138eacd47 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -71,14 +71,14 @@ class box_propales extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $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($db); - $societestatic = new Societe($db); + $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)); @@ -95,23 +95,23 @@ class box_propales extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; 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.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $now=dol_now(); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $date=$db->jdate($objp->dp); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); - $dateterm=$db->jdate($objp->fin_validite); - $dateclose=$db->jdate($objp->date_cloture); + $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; @@ -164,12 +164,12 @@ class box_propales extends ModeleBoxes 'text'=>$langs->trans("NoRecordedProposals"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 947ebc18b52..3011234a3fb 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -76,11 +76,11 @@ class box_prospect extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; - $thirdpartystatic=new Client($db); + $thirdpartystatic=new Client($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects", $max)); @@ -100,20 +100,20 @@ class box_prospect extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY s.tms DESC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($resql); - $datec=$db->jdate($objp->datec); - $datem=$db->jdate($objp->tms); + $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->code_client = $objp->code_client; @@ -153,12 +153,12 @@ class box_prospect extends ModeleBoxes ); } - $db->free($resql); + $this->db->free($resql); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength' => 500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index eaca6dc1548..3d852c7a190 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -71,22 +71,22 @@ class box_services_contracts extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $form = new Form($db); + $form = new Form($this->db); $this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract", $max)); if ($user->rights->service->lire && $user->rights->contrat->lire) { - $contractstatic=new Contrat($db); - $contractlinestatic=new ContratLigne($db); - $thirdpartytmp = new Societe($db); - $productstatic = new Product($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,"; @@ -100,21 +100,21 @@ class box_services_contracts extends ModeleBoxes $sql.= ")"; $sql.= " WHERE c.entity = ".$conf->entity; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= $db->order("c.tms", "DESC"); - $sql.= $db->plimit($max, 0); + $sql.= $this->db->order("c.tms", "DESC"); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $now=dol_now(); $i = 0; while ($i < $num) { - $objp = $db->fetch_object($result); - $datem=$db->jdate($objp->datem); + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->datem); $contractlinestatic->id=$objp->cdid; $contractlinestatic->fk_contrat=$objp->rowid; @@ -149,10 +149,10 @@ class box_services_contracts extends ModeleBoxes $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; $sqld.= " LIMIT 1"; - $resultd = $db->query($sqld); + $resultd = $this->db->query($sqld); if ($resultd) { - $objtp = $db->fetch_object($resultd); + $objtp = $this->db->fetch_object($resultd); if ($objtp->label != '') $contractlinestatic->label = $objtp->label; } } @@ -222,14 +222,14 @@ class box_services_contracts extends ModeleBoxes } if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'class="center"','text'=>$langs->trans("NoContractedProducts")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength' => 500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 58262a16dec..f1f1c38dd59 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -69,7 +69,7 @@ class box_services_expired extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; $this->max=$max; @@ -88,19 +88,19 @@ class box_services_expired extends ModeleBoxes $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->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$db->idate($now)."'"; + $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->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; if (!$user->rights->societe->client->voir && !$user->societe_id) $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.= " ORDER BY date_line ASC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $i = 0; @@ -111,7 +111,7 @@ class box_services_expired extends ModeleBoxes { $late=''; - $objp = $db->fetch_object($resql); + $objp = $this->db->fetch_object($resql); $thirdpartytmp->name = $objp->name; $thirdpartytmp->id = $objp->socid; @@ -129,7 +129,7 @@ class box_services_expired extends ModeleBoxes $contract->ref_customer = $objp->ref_customer; $contract->ref_supplier = $objp->ref_supplier; - $dateline=$db->jdate($objp->date_line); + $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( @@ -168,14 +168,14 @@ class box_services_expired extends ModeleBoxes ); } - $db->free($resql); + $this->db->free($resql); } else { $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 1ae1172de1d..6dc7385d363 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -69,15 +69,15 @@ class box_supplier_orders extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $langs->load("boxes"); $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic=new CommandeFournisseur($db); + $supplierorderstatic=new CommandeFournisseur($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp = new Fournisseur($db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max)); @@ -100,18 +100,18 @@ class box_supplier_orders extends ModeleBoxes if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; 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.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $date=$db->jdate($objp->date_commande); - $datem=$db->jdate($objp->tms); + $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; @@ -158,12 +158,12 @@ class box_supplier_orders extends ModeleBoxes 'text' => $langs->trans("NoSupplierOrder"), ); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index cf1d5241753..b0c6306ac38 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -75,15 +75,15 @@ class box_task extends ModeleBoxes */ public function loadBox($max = 5) { - global $conf, $user, $langs, $db; + global $conf, $user, $langs; $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); - $taskstatic=new Task($db); - $form= new Form($db); + $taskstatic=new Task($this->db); + $form= new Form($this->db); $cookie_name='boxfilter_task'; $boxcontent=''; @@ -160,13 +160,13 @@ class box_task extends ModeleBoxes $sql.= " ORDER BY pt.datee ASC, pt.dateo ASC"; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); $i = 0; if ($result) { - $num = $db->num_rows($result); - while ($objp = $db->fetch_object($result)) { + $num = $this->db->num_rows($result); + while ($objp = $this->db->fetch_object($result)) { $taskstatic->id=$objp->rowid; $taskstatic->ref=$objp->ref;