@@ -30,72 +30,72 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class box_lastlogin extends ModeleBoxes |
32 | 32 | { |
33 | - var $boxcode="lastlogin"; |
|
34 | - var $boximg="object_user"; |
|
35 | - var $boxlabel='BoxLoginInformation'; |
|
36 | - var $depends = array("user"); |
|
33 | + var $boxcode="lastlogin"; |
|
34 | + var $boximg="object_user"; |
|
35 | + var $boxlabel='BoxLoginInformation'; |
|
36 | + var $depends = array("user"); |
|
37 | 37 | |
38 | - var $db; |
|
39 | - var $param; |
|
40 | - var $enabled = 1; |
|
38 | + var $db; |
|
39 | + var $param; |
|
40 | + var $enabled = 1; |
|
41 | 41 | |
42 | - var $info_box_head = array(); |
|
43 | - var $info_box_contents = array(); |
|
42 | + var $info_box_head = array(); |
|
43 | + var $info_box_contents = array(); |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Constructor |
|
48 | - * |
|
49 | - * @param DoliDB $db Database handler |
|
50 | - * @param string $param More parameters |
|
51 | - */ |
|
52 | - function __construct($db,$param) |
|
53 | - { |
|
54 | - global $conf; |
|
46 | + /** |
|
47 | + * Constructor |
|
48 | + * |
|
49 | + * @param DoliDB $db Database handler |
|
50 | + * @param string $param More parameters |
|
51 | + */ |
|
52 | + function __construct($db,$param) |
|
53 | + { |
|
54 | + global $conf; |
|
55 | 55 | |
56 | - $this->db=$db; |
|
57 | - } |
|
56 | + $this->db=$db; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Charge les donnees en memoire pour affichage ulterieur |
|
61 | - * |
|
62 | - * @param int $max Maximum number of records to load |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - function loadBox($max=5) |
|
66 | - { |
|
67 | - global $conf, $user, $langs, $db; |
|
59 | + /** |
|
60 | + * Charge les donnees en memoire pour affichage ulterieur |
|
61 | + * |
|
62 | + * @param int $max Maximum number of records to load |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + function loadBox($max=5) |
|
66 | + { |
|
67 | + global $conf, $user, $langs, $db; |
|
68 | 68 | |
69 | - $textHead = $langs->trans("BoxLoginInformation"); |
|
70 | - $this->info_box_head = array( |
|
71 | - 'text' => $textHead, |
|
72 | - 'limit'=> dol_strlen($textHead), |
|
73 | - ); |
|
69 | + $textHead = $langs->trans("BoxLoginInformation"); |
|
70 | + $this->info_box_head = array( |
|
71 | + 'text' => $textHead, |
|
72 | + 'limit'=> dol_strlen($textHead), |
|
73 | + ); |
|
74 | 74 | |
75 | - $line=0; |
|
76 | - $this->info_box_contents[$line][0] = array( |
|
77 | - 'td' => '', |
|
78 | - 'text' => $langs->trans("User"), |
|
79 | - ); |
|
80 | - $this->info_box_contents[$line][1] = array( |
|
81 | - 'td' => '', |
|
82 | - 'text' => $user->getNomUrl(-1), |
|
83 | - 'asis' => 1 |
|
84 | - ); |
|
75 | + $line=0; |
|
76 | + $this->info_box_contents[$line][0] = array( |
|
77 | + 'td' => '', |
|
78 | + 'text' => $langs->trans("User"), |
|
79 | + ); |
|
80 | + $this->info_box_contents[$line][1] = array( |
|
81 | + 'td' => '', |
|
82 | + 'text' => $user->getNomUrl(-1), |
|
83 | + 'asis' => 1 |
|
84 | + ); |
|
85 | 85 | |
86 | - $line=1; |
|
87 | - $this->info_box_contents[$line][0] = array( |
|
88 | - 'td' => '', |
|
89 | - 'text' => $langs->trans("PreviousConnexion"), |
|
90 | - ); |
|
91 | - if ($user->datepreviouslogin) $tmp= dol_print_date($user->datepreviouslogin,"dayhour",'tzuser'); |
|
92 | - else $tmp= $langs->trans("Unknown"); |
|
93 | - $this->info_box_contents[$line][1] = array( |
|
94 | - 'td' => '', |
|
95 | - 'text' => $tmp, |
|
96 | - ); |
|
86 | + $line=1; |
|
87 | + $this->info_box_contents[$line][0] = array( |
|
88 | + 'td' => '', |
|
89 | + 'text' => $langs->trans("PreviousConnexion"), |
|
90 | + ); |
|
91 | + if ($user->datepreviouslogin) $tmp= dol_print_date($user->datepreviouslogin,"dayhour",'tzuser'); |
|
92 | + else $tmp= $langs->trans("Unknown"); |
|
93 | + $this->info_box_contents[$line][1] = array( |
|
94 | + 'td' => '', |
|
95 | + 'text' => $tmp, |
|
96 | + ); |
|
97 | 97 | |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | 101 | /** |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | * @param int $nooutput No print, only return string |
107 | 107 | * @return void |
108 | 108 | */ |
109 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
110 | - { |
|
109 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
110 | + { |
|
111 | 111 | parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
112 | 112 | } |
113 | 113 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class box_lastlogin extends ModeleBoxes |
32 | 32 | { |
33 | - var $boxcode="lastlogin"; |
|
34 | - var $boximg="object_user"; |
|
35 | - var $boxlabel='BoxLoginInformation'; |
|
33 | + var $boxcode = "lastlogin"; |
|
34 | + var $boximg = "object_user"; |
|
35 | + var $boxlabel = 'BoxLoginInformation'; |
|
36 | 36 | var $depends = array("user"); |
37 | 37 | |
38 | 38 | var $db; |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | * @param DoliDB $db Database handler |
50 | 50 | * @param string $param More parameters |
51 | 51 | */ |
52 | - function __construct($db,$param) |
|
52 | + function __construct($db, $param) |
|
53 | 53 | { |
54 | 54 | global $conf; |
55 | 55 | |
56 | - $this->db=$db; |
|
56 | + $this->db = $db; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param int $max Maximum number of records to load |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - function loadBox($max=5) |
|
65 | + function loadBox($max = 5) |
|
66 | 66 | { |
67 | 67 | global $conf, $user, $langs, $db; |
68 | 68 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'limit'=> dol_strlen($textHead), |
73 | 73 | ); |
74 | 74 | |
75 | - $line=0; |
|
75 | + $line = 0; |
|
76 | 76 | $this->info_box_contents[$line][0] = array( |
77 | 77 | 'td' => '', |
78 | 78 | 'text' => $langs->trans("User"), |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | 'asis' => 1 |
84 | 84 | ); |
85 | 85 | |
86 | - $line=1; |
|
86 | + $line = 1; |
|
87 | 87 | $this->info_box_contents[$line][0] = array( |
88 | 88 | 'td' => '', |
89 | 89 | 'text' => $langs->trans("PreviousConnexion"), |
90 | 90 | ); |
91 | - if ($user->datepreviouslogin) $tmp= dol_print_date($user->datepreviouslogin,"dayhour",'tzuser'); |
|
92 | - else $tmp= $langs->trans("Unknown"); |
|
91 | + if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); |
|
92 | + else $tmp = $langs->trans("Unknown"); |
|
93 | 93 | $this->info_box_contents[$line][1] = array( |
94 | 94 | 'td' => '', |
95 | 95 | 'text' => $tmp, |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param int $nooutput No print, only return string |
107 | 107 | * @return void |
108 | 108 | */ |
109 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
109 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
110 | 110 | { |
111 | 111 | parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
112 | 112 | } |
@@ -88,8 +88,11 @@ |
||
88 | 88 | 'td' => '', |
89 | 89 | 'text' => $langs->trans("PreviousConnexion"), |
90 | 90 | ); |
91 | - if ($user->datepreviouslogin) $tmp= dol_print_date($user->datepreviouslogin,"dayhour",'tzuser'); |
|
92 | - else $tmp= $langs->trans("Unknown"); |
|
91 | + if ($user->datepreviouslogin) { |
|
92 | + $tmp= dol_print_date($user->datepreviouslogin,"dayhour",'tzuser'); |
|
93 | + } else { |
|
94 | + $tmp= $langs->trans("Unknown"); |
|
95 | + } |
|
93 | 96 | $this->info_box_contents[$line][1] = array( |
94 | 97 | 'td' => '', |
95 | 98 | 'text' => $tmp, |
@@ -31,123 +31,123 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class box_fournisseurs extends ModeleBoxes |
33 | 33 | { |
34 | - var $boxcode="lastsuppliers"; |
|
35 | - var $boximg="object_company"; |
|
36 | - var $boxlabel="BoxLastSuppliers"; |
|
37 | - var $depends = array("fournisseur"); |
|
34 | + var $boxcode="lastsuppliers"; |
|
35 | + var $boximg="object_company"; |
|
36 | + var $boxlabel="BoxLastSuppliers"; |
|
37 | + var $depends = array("fournisseur"); |
|
38 | 38 | |
39 | 39 | var $db; |
40 | 40 | var $param; |
41 | 41 | |
42 | - var $info_box_head = array(); |
|
43 | - var $info_box_contents = array(); |
|
42 | + var $info_box_head = array(); |
|
43 | + var $info_box_contents = array(); |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Constructor |
|
48 | - * |
|
49 | - * @param DoliDB $db Database handler |
|
50 | - * @param string $param More parameters |
|
51 | - */ |
|
52 | - function __construct($db,$param) |
|
53 | - { |
|
54 | - global $user; |
|
46 | + /** |
|
47 | + * Constructor |
|
48 | + * |
|
49 | + * @param DoliDB $db Database handler |
|
50 | + * @param string $param More parameters |
|
51 | + */ |
|
52 | + function __construct($db,$param) |
|
53 | + { |
|
54 | + global $user; |
|
55 | 55 | |
56 | - $this->db=$db; |
|
56 | + $this->db=$db; |
|
57 | 57 | |
58 | - $this->hidden=! ($user->rights->societe->lire && empty($user->socid)); |
|
59 | - } |
|
58 | + $this->hidden=! ($user->rights->societe->lire && empty($user->socid)); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
61 | + /** |
|
62 | 62 | * Load data into info_box_contents array to show array later. |
63 | 63 | * |
64 | 64 | * @param int $max Maximum number of records to load |
65 | - * @return void |
|
66 | - */ |
|
67 | - function loadBox($max=5) |
|
68 | - { |
|
69 | - global $conf, $user, $langs, $db; |
|
70 | - $langs->load("boxes"); |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + function loadBox($max=5) |
|
68 | + { |
|
69 | + global $conf, $user, $langs, $db; |
|
70 | + $langs->load("boxes"); |
|
71 | 71 | |
72 | 72 | $this->max=$max; |
73 | 73 | |
74 | - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
75 | - $thirdpartystatic=new Societe($db); |
|
74 | + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
75 | + $thirdpartystatic=new Societe($db); |
|
76 | 76 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
77 | 77 | $thirdpartytmp=new Fournisseur($db); |
78 | 78 | |
79 | 79 | $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers",$max)); |
80 | 80 | |
81 | - if ($user->rights->societe->lire) |
|
82 | - { |
|
83 | - $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; |
|
84 | - $sql.= " s.code_fournisseur,"; |
|
85 | - $sql.= " s.logo"; |
|
86 | - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
87 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | - $sql.= " WHERE s.fournisseur = 1"; |
|
89 | - $sql.= " AND s.entity IN (".getEntity('societe').")"; |
|
90 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | - $sql.= " ORDER BY s.tms DESC "; |
|
93 | - $sql.= $db->plimit($max, 0); |
|
94 | - |
|
95 | - $result = $db->query($sql); |
|
96 | - if ($result) |
|
97 | - { |
|
98 | - $num = $db->num_rows($result); |
|
99 | - |
|
100 | - $line = 0; |
|
101 | - while ($line < $num) |
|
102 | - { |
|
103 | - $objp = $db->fetch_object($result); |
|
104 | - $datec=$db->jdate($objp->datec); |
|
105 | - $datem=$db->jdate($objp->tms); |
|
81 | + if ($user->rights->societe->lire) |
|
82 | + { |
|
83 | + $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; |
|
84 | + $sql.= " s.code_fournisseur,"; |
|
85 | + $sql.= " s.logo"; |
|
86 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
87 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | + $sql.= " WHERE s.fournisseur = 1"; |
|
89 | + $sql.= " AND s.entity IN (".getEntity('societe').")"; |
|
90 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | + if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | + $sql.= " ORDER BY s.tms DESC "; |
|
93 | + $sql.= $db->plimit($max, 0); |
|
94 | + |
|
95 | + $result = $db->query($sql); |
|
96 | + if ($result) |
|
97 | + { |
|
98 | + $num = $db->num_rows($result); |
|
99 | + |
|
100 | + $line = 0; |
|
101 | + while ($line < $num) |
|
102 | + { |
|
103 | + $objp = $db->fetch_object($result); |
|
104 | + $datec=$db->jdate($objp->datec); |
|
105 | + $datem=$db->jdate($objp->tms); |
|
106 | 106 | $thirdpartytmp->id = $objp->socid; |
107 | - $thirdpartytmp->name = $objp->name; |
|
108 | - $thirdpartytmp->code_client = $objp->code_client; |
|
109 | - $thirdpartytmp->logo = $objp->logo; |
|
110 | - |
|
111 | - $this->info_box_contents[$line][] = array( |
|
112 | - 'td' => '', |
|
113 | - 'text' => $thirdpartytmp->getNomUrl(1, '', 40), |
|
114 | - 'asis' => 1, |
|
115 | - ); |
|
116 | - |
|
117 | - $this->info_box_contents[$line][] = array( |
|
118 | - 'td' => 'class="right"', |
|
119 | - 'text' => dol_print_date($datem, "day"), |
|
120 | - ); |
|
121 | - |
|
122 | - $this->info_box_contents[$line][] = array( |
|
123 | - 'td' => 'align="right" width="18"', |
|
124 | - 'text' => $thirdpartystatic->LibStatut($objp->status,3), |
|
125 | - ); |
|
126 | - |
|
127 | - $line++; |
|
128 | - } |
|
129 | - |
|
130 | - if ($num==0) $this->info_box_contents[$line][0] = array( |
|
131 | - 'td' => 'align="center"', |
|
132 | - 'text'=>$langs->trans("NoRecordedSuppliers"), |
|
133 | - ); |
|
134 | - |
|
135 | - $db->free($result); |
|
136 | - } else { |
|
137 | - $this->info_box_contents[0][0] = array( |
|
138 | - 'td' => '', |
|
139 | - 'maxlength'=>500, |
|
140 | - 'text' => ($db->error().' sql='.$sql), |
|
141 | - ); |
|
142 | - } |
|
143 | - } else { |
|
144 | - $this->info_box_contents[0][0] = array( |
|
145 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
146 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
147 | - ); |
|
148 | - } |
|
149 | - |
|
150 | - } |
|
107 | + $thirdpartytmp->name = $objp->name; |
|
108 | + $thirdpartytmp->code_client = $objp->code_client; |
|
109 | + $thirdpartytmp->logo = $objp->logo; |
|
110 | + |
|
111 | + $this->info_box_contents[$line][] = array( |
|
112 | + 'td' => '', |
|
113 | + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), |
|
114 | + 'asis' => 1, |
|
115 | + ); |
|
116 | + |
|
117 | + $this->info_box_contents[$line][] = array( |
|
118 | + 'td' => 'class="right"', |
|
119 | + 'text' => dol_print_date($datem, "day"), |
|
120 | + ); |
|
121 | + |
|
122 | + $this->info_box_contents[$line][] = array( |
|
123 | + 'td' => 'align="right" width="18"', |
|
124 | + 'text' => $thirdpartystatic->LibStatut($objp->status,3), |
|
125 | + ); |
|
126 | + |
|
127 | + $line++; |
|
128 | + } |
|
129 | + |
|
130 | + if ($num==0) $this->info_box_contents[$line][0] = array( |
|
131 | + 'td' => 'align="center"', |
|
132 | + 'text'=>$langs->trans("NoRecordedSuppliers"), |
|
133 | + ); |
|
134 | + |
|
135 | + $db->free($result); |
|
136 | + } else { |
|
137 | + $this->info_box_contents[0][0] = array( |
|
138 | + 'td' => '', |
|
139 | + 'maxlength'=>500, |
|
140 | + 'text' => ($db->error().' sql='.$sql), |
|
141 | + ); |
|
142 | + } |
|
143 | + } else { |
|
144 | + $this->info_box_contents[0][0] = array( |
|
145 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
146 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
147 | + ); |
|
148 | + } |
|
149 | + |
|
150 | + } |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Method to show box |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | * @param int $nooutput No print, only return string |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
161 | - { |
|
162 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
163 | - } |
|
160 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
161 | + { |
|
162 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
163 | + } |
|
164 | 164 | |
165 | 165 | } |
166 | 166 |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class box_fournisseurs extends ModeleBoxes |
33 | 33 | { |
34 | - var $boxcode="lastsuppliers"; |
|
35 | - var $boximg="object_company"; |
|
36 | - var $boxlabel="BoxLastSuppliers"; |
|
34 | + var $boxcode = "lastsuppliers"; |
|
35 | + var $boximg = "object_company"; |
|
36 | + var $boxlabel = "BoxLastSuppliers"; |
|
37 | 37 | var $depends = array("fournisseur"); |
38 | 38 | |
39 | 39 | var $db; |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @param DoliDB $db Database handler |
50 | 50 | * @param string $param More parameters |
51 | 51 | */ |
52 | - function __construct($db,$param) |
|
52 | + function __construct($db, $param) |
|
53 | 53 | { |
54 | 54 | global $user; |
55 | 55 | |
56 | - $this->db=$db; |
|
56 | + $this->db = $db; |
|
57 | 57 | |
58 | - $this->hidden=! ($user->rights->societe->lire && empty($user->socid)); |
|
58 | + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,33 +64,33 @@ discard block |
||
64 | 64 | * @param int $max Maximum number of records to load |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - function loadBox($max=5) |
|
67 | + function loadBox($max = 5) |
|
68 | 68 | { |
69 | 69 | global $conf, $user, $langs, $db; |
70 | 70 | $langs->load("boxes"); |
71 | 71 | |
72 | - $this->max=$max; |
|
72 | + $this->max = $max; |
|
73 | 73 | |
74 | 74 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
75 | - $thirdpartystatic=new Societe($db); |
|
75 | + $thirdpartystatic = new Societe($db); |
|
76 | 76 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
77 | - $thirdpartytmp=new Fournisseur($db); |
|
77 | + $thirdpartytmp = new Fournisseur($db); |
|
78 | 78 | |
79 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers",$max)); |
|
79 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); |
|
80 | 80 | |
81 | 81 | if ($user->rights->societe->lire) |
82 | 82 | { |
83 | 83 | $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; |
84 | - $sql.= " s.code_fournisseur,"; |
|
85 | - $sql.= " s.logo"; |
|
84 | + $sql .= " s.code_fournisseur,"; |
|
85 | + $sql .= " s.logo"; |
|
86 | 86 | $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
87 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | - $sql.= " WHERE s.fournisseur = 1"; |
|
89 | - $sql.= " AND s.entity IN (".getEntity('societe').")"; |
|
90 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | - $sql.= " ORDER BY s.tms DESC "; |
|
93 | - $sql.= $db->plimit($max, 0); |
|
87 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | + $sql .= " WHERE s.fournisseur = 1"; |
|
89 | + $sql .= " AND s.entity IN (".getEntity('societe').")"; |
|
90 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
91 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
92 | + $sql .= " ORDER BY s.tms DESC "; |
|
93 | + $sql .= $db->plimit($max, 0); |
|
94 | 94 | |
95 | 95 | $result = $db->query($sql); |
96 | 96 | if ($result) |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | while ($line < $num) |
102 | 102 | { |
103 | 103 | $objp = $db->fetch_object($result); |
104 | - $datec=$db->jdate($objp->datec); |
|
105 | - $datem=$db->jdate($objp->tms); |
|
104 | + $datec = $db->jdate($objp->datec); |
|
105 | + $datem = $db->jdate($objp->tms); |
|
106 | 106 | $thirdpartytmp->id = $objp->socid; |
107 | 107 | $thirdpartytmp->name = $objp->name; |
108 | 108 | $thirdpartytmp->code_client = $objp->code_client; |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | |
122 | 122 | $this->info_box_contents[$line][] = array( |
123 | 123 | 'td' => 'align="right" width="18"', |
124 | - 'text' => $thirdpartystatic->LibStatut($objp->status,3), |
|
124 | + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), |
|
125 | 125 | ); |
126 | 126 | |
127 | 127 | $line++; |
128 | 128 | } |
129 | 129 | |
130 | - if ($num==0) $this->info_box_contents[$line][0] = array( |
|
130 | + if ($num == 0) $this->info_box_contents[$line][0] = array( |
|
131 | 131 | 'td' => 'align="center"', |
132 | 132 | 'text'=>$langs->trans("NoRecordedSuppliers"), |
133 | 133 | ); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param int $nooutput No print, only return string |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
160 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
161 | 161 | { |
162 | 162 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
163 | 163 | } |
@@ -84,11 +84,17 @@ discard block |
||
84 | 84 | $sql.= " s.code_fournisseur,"; |
85 | 85 | $sql.= " s.logo"; |
86 | 86 | $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
87 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
87 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
88 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
89 | + } |
|
88 | 90 | $sql.= " WHERE s.fournisseur = 1"; |
89 | 91 | $sql.= " AND s.entity IN (".getEntity('societe').")"; |
90 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
93 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
94 | + } |
|
95 | + if ($user->societe_id) { |
|
96 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
97 | + } |
|
92 | 98 | $sql.= " ORDER BY s.tms DESC "; |
93 | 99 | $sql.= $db->plimit($max, 0); |
94 | 100 | |
@@ -127,10 +133,12 @@ discard block |
||
127 | 133 | $line++; |
128 | 134 | } |
129 | 135 | |
130 | - if ($num==0) $this->info_box_contents[$line][0] = array( |
|
136 | + if ($num==0) { |
|
137 | + $this->info_box_contents[$line][0] = array( |
|
131 | 138 | 'td' => 'align="center"', |
132 | 139 | 'text'=>$langs->trans("NoRecordedSuppliers"), |
133 | 140 | ); |
141 | + } |
|
134 | 142 | |
135 | 143 | $db->free($result); |
136 | 144 | } else { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * Constructor |
49 | 49 | * |
50 | 50 | * @param DoliDB $db Database handler |
51 | - * @param string $param More parameters |
|
51 | + * @param string $param More parameters |
|
52 | 52 | */ |
53 | 53 | function __construct($db,$param='') |
54 | 54 | { |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * Load data for box to show them later |
|
67 | - * |
|
68 | - * @param int $max Maximum number of records to load |
|
69 | - * @return void |
|
66 | + * Load data for box to show them later |
|
67 | + * |
|
68 | + * @param int $max Maximum number of records to load |
|
69 | + * @return void |
|
70 | 70 | */ |
71 | 71 | function loadBox($max=5) |
72 | 72 | { |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | |
76 | 76 | $this->max=$max; |
77 | 77 | |
78 | - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
79 | - $thirdpartystatic=new Societe($db); |
|
78 | + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
79 | + $thirdpartystatic=new Societe($db); |
|
80 | 80 | |
81 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers",$max)); |
|
81 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers",$max)); |
|
82 | 82 | |
83 | 83 | if ($user->rights->societe->lire) |
84 | 84 | { |
85 | 85 | $sql = "SELECT s.nom as name, s.rowid as socid"; |
86 | - $sql.= ", s.code_client"; |
|
87 | - $sql.= ", s.client"; |
|
88 | - $sql.= ", s.code_fournisseur"; |
|
89 | - $sql.= ", s.fournisseur"; |
|
90 | - $sql.= ", s.logo"; |
|
91 | - $sql.= ", s.datec, s.tms, s.status"; |
|
86 | + $sql.= ", s.code_client"; |
|
87 | + $sql.= ", s.client"; |
|
88 | + $sql.= ", s.code_fournisseur"; |
|
89 | + $sql.= ", s.fournisseur"; |
|
90 | + $sql.= ", s.logo"; |
|
91 | + $sql.= ", s.datec, s.tms, s.status"; |
|
92 | 92 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
93 | 93 | if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
94 | 94 | $sql.= " WHERE s.client IN (1, 3)"; |
@@ -110,29 +110,29 @@ discard block |
||
110 | 110 | $objp = $db->fetch_object($result); |
111 | 111 | $datec=$db->jdate($objp->datec); |
112 | 112 | $datem=$db->jdate($objp->tms); |
113 | - $thirdpartystatic->id = $objp->socid; |
|
114 | - $thirdpartystatic->name = $objp->name; |
|
115 | - $thirdpartystatic->code_client = $objp->code_client; |
|
116 | - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; |
|
117 | - $thirdpartystatic->client = $objp->client; |
|
118 | - $thirdpartystatic->fournisseur = $objp->fournisseur; |
|
119 | - $thirdpartystatic->logo = $objp->logo; |
|
120 | - |
|
121 | - $this->info_box_contents[$line][] = array( |
|
122 | - 'td' => '', |
|
123 | - 'text' => $thirdpartystatic->getNomUrl(1), |
|
124 | - 'asis' => 1, |
|
125 | - ); |
|
126 | - |
|
127 | - $this->info_box_contents[$line][] = array( |
|
128 | - 'td' => 'class="right"', |
|
129 | - 'text' => dol_print_date($datem, "day") |
|
130 | - ); |
|
131 | - |
|
132 | - $this->info_box_contents[$line][] = array( |
|
133 | - 'td' => 'align="right" width="18"', |
|
134 | - 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
135 | - ); |
|
113 | + $thirdpartystatic->id = $objp->socid; |
|
114 | + $thirdpartystatic->name = $objp->name; |
|
115 | + $thirdpartystatic->code_client = $objp->code_client; |
|
116 | + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; |
|
117 | + $thirdpartystatic->client = $objp->client; |
|
118 | + $thirdpartystatic->fournisseur = $objp->fournisseur; |
|
119 | + $thirdpartystatic->logo = $objp->logo; |
|
120 | + |
|
121 | + $this->info_box_contents[$line][] = array( |
|
122 | + 'td' => '', |
|
123 | + 'text' => $thirdpartystatic->getNomUrl(1), |
|
124 | + 'asis' => 1, |
|
125 | + ); |
|
126 | + |
|
127 | + $this->info_box_contents[$line][] = array( |
|
128 | + 'td' => 'class="right"', |
|
129 | + 'text' => dol_print_date($datem, "day") |
|
130 | + ); |
|
131 | + |
|
132 | + $this->info_box_contents[$line][] = array( |
|
133 | + 'td' => 'align="right" width="18"', |
|
134 | + 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
135 | + ); |
|
136 | 136 | |
137 | 137 | $line++; |
138 | 138 | } |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | } |
144 | 144 | else { |
145 | 145 | $this->info_box_contents[0][0] = array( 'td' => '', |
146 | - 'maxlength'=>500, |
|
147 | - 'text' => ($db->error().' sql='.$sql)); |
|
146 | + 'maxlength'=>500, |
|
147 | + 'text' => ($db->error().' sql='.$sql)); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | else { |
151 | 151 | $this->info_box_contents[0][0] = array( |
152 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
153 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
152 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
153 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
154 | 154 | ); |
155 | 155 | } |
156 | 156 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param int $nooutput No print, only return string |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
168 | - { |
|
167 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
168 | + { |
|
169 | 169 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
170 | 170 | } |
171 | 171 |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class box_clients extends ModeleBoxes |
34 | 34 | { |
35 | - var $boxcode="lastcustomers"; |
|
36 | - var $boximg="object_company"; |
|
37 | - var $boxlabel="BoxLastCustomers"; |
|
35 | + var $boxcode = "lastcustomers"; |
|
36 | + var $boximg = "object_company"; |
|
37 | + var $boxlabel = "BoxLastCustomers"; |
|
38 | 38 | var $depends = array("societe"); |
39 | 39 | |
40 | 40 | var $db; |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | * @param DoliDB $db Database handler |
51 | 51 | * @param string $param More parameters |
52 | 52 | */ |
53 | - function __construct($db,$param='') |
|
53 | + function __construct($db, $param = '') |
|
54 | 54 | { |
55 | 55 | global $conf, $user; |
56 | 56 | |
57 | 57 | $this->db = $db; |
58 | 58 | |
59 | 59 | // disable box for such cases |
60 | - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option |
|
60 | + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option |
|
61 | 61 | |
62 | - $this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); |
|
62 | + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -68,35 +68,35 @@ discard block |
||
68 | 68 | * @param int $max Maximum number of records to load |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - function loadBox($max=5) |
|
71 | + function loadBox($max = 5) |
|
72 | 72 | { |
73 | 73 | global $user, $langs, $db, $conf; |
74 | 74 | $langs->load("boxes"); |
75 | 75 | |
76 | - $this->max=$max; |
|
76 | + $this->max = $max; |
|
77 | 77 | |
78 | 78 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
79 | - $thirdpartystatic=new Societe($db); |
|
79 | + $thirdpartystatic = new Societe($db); |
|
80 | 80 | |
81 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers",$max)); |
|
81 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); |
|
82 | 82 | |
83 | 83 | if ($user->rights->societe->lire) |
84 | 84 | { |
85 | 85 | $sql = "SELECT s.nom as name, s.rowid as socid"; |
86 | - $sql.= ", s.code_client"; |
|
87 | - $sql.= ", s.client"; |
|
88 | - $sql.= ", s.code_fournisseur"; |
|
89 | - $sql.= ", s.fournisseur"; |
|
90 | - $sql.= ", s.logo"; |
|
91 | - $sql.= ", s.datec, s.tms, s.status"; |
|
92 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
93 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
94 | - $sql.= " WHERE s.client IN (1, 3)"; |
|
95 | - $sql.= " AND s.entity IN (".getEntity('societe').")"; |
|
96 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
97 | - if ($user->societe_id) $sql.= " AND s.rowid = $user->societe_id"; |
|
98 | - $sql.= " ORDER BY s.tms DESC"; |
|
99 | - $sql.= $db->plimit($max, 0); |
|
86 | + $sql .= ", s.code_client"; |
|
87 | + $sql .= ", s.client"; |
|
88 | + $sql .= ", s.code_fournisseur"; |
|
89 | + $sql .= ", s.fournisseur"; |
|
90 | + $sql .= ", s.logo"; |
|
91 | + $sql .= ", s.datec, s.tms, s.status"; |
|
92 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
93 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
94 | + $sql .= " WHERE s.client IN (1, 3)"; |
|
95 | + $sql .= " AND s.entity IN (".getEntity('societe').")"; |
|
96 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
97 | + if ($user->societe_id) $sql .= " AND s.rowid = $user->societe_id"; |
|
98 | + $sql .= " ORDER BY s.tms DESC"; |
|
99 | + $sql .= $db->plimit($max, 0); |
|
100 | 100 | |
101 | 101 | dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); |
102 | 102 | $result = $db->query($sql); |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | while ($line < $num) |
109 | 109 | { |
110 | 110 | $objp = $db->fetch_object($result); |
111 | - $datec=$db->jdate($objp->datec); |
|
112 | - $datem=$db->jdate($objp->tms); |
|
111 | + $datec = $db->jdate($objp->datec); |
|
112 | + $datem = $db->jdate($objp->tms); |
|
113 | 113 | $thirdpartystatic->id = $objp->socid; |
114 | 114 | $thirdpartystatic->name = $objp->name; |
115 | 115 | $thirdpartystatic->code_client = $objp->code_client; |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | |
132 | 132 | $this->info_box_contents[$line][] = array( |
133 | 133 | 'td' => 'align="right" width="18"', |
134 | - 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
134 | + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | $line++; |
138 | 138 | } |
139 | 139 | |
140 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
140 | + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoRecordedCustomers")); |
|
141 | 141 | |
142 | 142 | $db->free($result); |
143 | 143 | } |
144 | 144 | else { |
145 | - $this->info_box_contents[0][0] = array( 'td' => '', |
|
145 | + $this->info_box_contents[0][0] = array('td' => '', |
|
146 | 146 | 'maxlength'=>500, |
147 | 147 | 'text' => ($db->error().' sql='.$sql)); |
148 | 148 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param int $nooutput No print, only return string |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
167 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
168 | 168 | { |
169 | 169 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
170 | 170 | } |
@@ -57,7 +57,10 @@ discard block |
||
57 | 57 | $this->db = $db; |
58 | 58 | |
59 | 59 | // disable box for such cases |
60 | - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option |
|
60 | + if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { |
|
61 | + $this->enabled=0; |
|
62 | + } |
|
63 | + // disabled by this option |
|
61 | 64 | |
62 | 65 | $this->hidden = ! ($user->rights->societe->lire && empty($user->socid)); |
63 | 66 | } |
@@ -90,11 +93,17 @@ discard block |
||
90 | 93 | $sql.= ", s.logo"; |
91 | 94 | $sql.= ", s.datec, s.tms, s.status"; |
92 | 95 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
93 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
96 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
97 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
98 | + } |
|
94 | 99 | $sql.= " WHERE s.client IN (1, 3)"; |
95 | 100 | $sql.= " AND s.entity IN (".getEntity('societe').")"; |
96 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
97 | - if ($user->societe_id) $sql.= " AND s.rowid = $user->societe_id"; |
|
101 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
102 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
103 | + } |
|
104 | + if ($user->societe_id) { |
|
105 | + $sql.= " AND s.rowid = $user->societe_id"; |
|
106 | + } |
|
98 | 107 | $sql.= " ORDER BY s.tms DESC"; |
99 | 108 | $sql.= $db->plimit($max, 0); |
100 | 109 | |
@@ -137,17 +146,17 @@ discard block |
||
137 | 146 | $line++; |
138 | 147 | } |
139 | 148 | |
140 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
149 | + if ($num==0) { |
|
150 | + $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
151 | + } |
|
141 | 152 | |
142 | 153 | $db->free($result); |
143 | - } |
|
144 | - else { |
|
154 | + } else { |
|
145 | 155 | $this->info_box_contents[0][0] = array( 'td' => '', |
146 | 156 | 'maxlength'=>500, |
147 | 157 | 'text' => ($db->error().' sql='.$sql)); |
148 | 158 | } |
149 | - } |
|
150 | - else { |
|
159 | + } else { |
|
151 | 160 | $this->info_box_contents[0][0] = array( |
152 | 161 | 'td' => 'align="left" class="nohover opacitymedium"', |
153 | 162 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
@@ -32,167 +32,167 @@ |
||
32 | 32 | class box_supplier_orders extends ModeleBoxes |
33 | 33 | { |
34 | 34 | |
35 | - var $boxcode = "latestsupplierorders"; |
|
36 | - var $boximg = "object_order"; |
|
37 | - var $boxlabel="BoxLatestSupplierOrders"; |
|
38 | - var $depends = array("fournisseur"); |
|
39 | - |
|
40 | - var $db; |
|
41 | - var $param; |
|
42 | - var $info_box_head = array(); |
|
43 | - var $info_box_contents = array(); |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * Constructor |
|
48 | - * |
|
49 | - * @param DoliDB $db Database handler |
|
50 | - * @param string $param More parameters |
|
51 | - */ |
|
52 | - function __construct($db,$param) |
|
53 | - { |
|
54 | - global $user; |
|
55 | - |
|
56 | - $this->db=$db; |
|
57 | - |
|
58 | - $this->hidden=! ($user->rights->fournisseur->commande->lire); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Load data into info_box_contents array to show array later. |
|
63 | - * |
|
64 | - * @param int $max Maximum number of records to load |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - function loadBox($max = 5) |
|
68 | - { |
|
69 | - global $conf, $user, $langs, $db; |
|
70 | - $langs->load("boxes"); |
|
71 | - |
|
72 | - $this->max = $max; |
|
73 | - |
|
74 | - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
75 | - $supplierorderstatic=new CommandeFournisseur($db); |
|
76 | - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
|
77 | - $thirdpartytmp = new Fournisseur($db); |
|
78 | - |
|
79 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max)); |
|
80 | - |
|
81 | - if ($user->rights->fournisseur->commande->lire) |
|
82 | - { |
|
83 | - $sql = "SELECT s.nom as name, s.rowid as socid,"; |
|
84 | - $sql.= " s.code_client, s.code_fournisseur,"; |
|
85 | - $sql.= " s.logo,"; |
|
86 | - $sql.= " c.ref, c.tms, c.rowid, c.date_commande,"; |
|
87 | - $sql.= " c.total_ht,"; |
|
88 | - $sql.= " c.tva as total_tva,"; |
|
89 | - $sql.= " c.total_ttc,"; |
|
90 | - $sql.= " c.fk_statut"; |
|
91 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
92 | - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; |
|
93 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
94 | - $sql.= " WHERE c.fk_soc = s.rowid"; |
|
95 | - $sql.= " AND c.entity = ".$conf->entity; |
|
96 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
97 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
98 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
99 | - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
100 | - $sql.= $db->plimit($max, 0); |
|
101 | - |
|
102 | - $result = $db->query($sql); |
|
103 | - if ($result) |
|
104 | - { |
|
105 | - $num = $db->num_rows($result); |
|
106 | - |
|
107 | - $line = 0; |
|
108 | - while ($line < $num) { |
|
109 | - $objp = $db->fetch_object($result); |
|
110 | - $date=$db->jdate($objp->date_commande); |
|
35 | + var $boxcode = "latestsupplierorders"; |
|
36 | + var $boximg = "object_order"; |
|
37 | + var $boxlabel="BoxLatestSupplierOrders"; |
|
38 | + var $depends = array("fournisseur"); |
|
39 | + |
|
40 | + var $db; |
|
41 | + var $param; |
|
42 | + var $info_box_head = array(); |
|
43 | + var $info_box_contents = array(); |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * Constructor |
|
48 | + * |
|
49 | + * @param DoliDB $db Database handler |
|
50 | + * @param string $param More parameters |
|
51 | + */ |
|
52 | + function __construct($db,$param) |
|
53 | + { |
|
54 | + global $user; |
|
55 | + |
|
56 | + $this->db=$db; |
|
57 | + |
|
58 | + $this->hidden=! ($user->rights->fournisseur->commande->lire); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Load data into info_box_contents array to show array later. |
|
63 | + * |
|
64 | + * @param int $max Maximum number of records to load |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + function loadBox($max = 5) |
|
68 | + { |
|
69 | + global $conf, $user, $langs, $db; |
|
70 | + $langs->load("boxes"); |
|
71 | + |
|
72 | + $this->max = $max; |
|
73 | + |
|
74 | + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
|
75 | + $supplierorderstatic=new CommandeFournisseur($db); |
|
76 | + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
|
77 | + $thirdpartytmp = new Fournisseur($db); |
|
78 | + |
|
79 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max)); |
|
80 | + |
|
81 | + if ($user->rights->fournisseur->commande->lire) |
|
82 | + { |
|
83 | + $sql = "SELECT s.nom as name, s.rowid as socid,"; |
|
84 | + $sql.= " s.code_client, s.code_fournisseur,"; |
|
85 | + $sql.= " s.logo,"; |
|
86 | + $sql.= " c.ref, c.tms, c.rowid, c.date_commande,"; |
|
87 | + $sql.= " c.total_ht,"; |
|
88 | + $sql.= " c.tva as total_tva,"; |
|
89 | + $sql.= " c.total_ttc,"; |
|
90 | + $sql.= " c.fk_statut"; |
|
91 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
92 | + $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; |
|
93 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
94 | + $sql.= " WHERE c.fk_soc = s.rowid"; |
|
95 | + $sql.= " AND c.entity = ".$conf->entity; |
|
96 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
97 | + if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
98 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
99 | + else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
100 | + $sql.= $db->plimit($max, 0); |
|
101 | + |
|
102 | + $result = $db->query($sql); |
|
103 | + if ($result) |
|
104 | + { |
|
105 | + $num = $db->num_rows($result); |
|
106 | + |
|
107 | + $line = 0; |
|
108 | + while ($line < $num) { |
|
109 | + $objp = $db->fetch_object($result); |
|
110 | + $date=$db->jdate($objp->date_commande); |
|
111 | 111 | $datem=$db->jdate($objp->tms); |
112 | - $thirdpartytmp->id = $objp->socid; |
|
113 | - $thirdpartytmp->name = $objp->name; |
|
114 | - $thirdpartytmp->fournisseur = 1; |
|
115 | - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; |
|
116 | - $thirdpartytmp->logo = $objp->logo; |
|
117 | - |
|
118 | - $urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid; |
|
119 | - $urls = DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid; |
|
120 | - |
|
121 | - $tooltip = $langs->trans('SupplierOrder') . ': ' . $objp->ref; |
|
122 | - $this->info_box_contents[$line][] = array( |
|
123 | - 'td' => 'align="left" width="16"', |
|
124 | - 'logo' => $this->boximg, |
|
125 | - 'tooltip' => $tooltip, |
|
126 | - 'url' => $urlo, |
|
127 | - ); |
|
128 | - |
|
129 | - $this->info_box_contents[$line][] = array( |
|
130 | - 'td' => '', |
|
131 | - 'text' => $objp->ref, |
|
132 | - 'tooltip' => $tooltip, |
|
133 | - 'url' => $urlo, |
|
134 | - ); |
|
135 | - |
|
136 | - $this->info_box_contents[$line][] = array( |
|
137 | - 'td' => '', |
|
138 | - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), |
|
139 | - 'asis' => 1, |
|
140 | - ); |
|
141 | - |
|
142 | - $this->info_box_contents[$line][] = array( |
|
143 | - 'td' => 'class="right"', |
|
144 | - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
|
145 | - ); |
|
112 | + $thirdpartytmp->id = $objp->socid; |
|
113 | + $thirdpartytmp->name = $objp->name; |
|
114 | + $thirdpartytmp->fournisseur = 1; |
|
115 | + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; |
|
116 | + $thirdpartytmp->logo = $objp->logo; |
|
117 | + |
|
118 | + $urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid; |
|
119 | + $urls = DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid; |
|
120 | + |
|
121 | + $tooltip = $langs->trans('SupplierOrder') . ': ' . $objp->ref; |
|
122 | + $this->info_box_contents[$line][] = array( |
|
123 | + 'td' => 'align="left" width="16"', |
|
124 | + 'logo' => $this->boximg, |
|
125 | + 'tooltip' => $tooltip, |
|
126 | + 'url' => $urlo, |
|
127 | + ); |
|
128 | + |
|
129 | + $this->info_box_contents[$line][] = array( |
|
130 | + 'td' => '', |
|
131 | + 'text' => $objp->ref, |
|
132 | + 'tooltip' => $tooltip, |
|
133 | + 'url' => $urlo, |
|
134 | + ); |
|
135 | + |
|
136 | + $this->info_box_contents[$line][] = array( |
|
137 | + 'td' => '', |
|
138 | + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), |
|
139 | + 'asis' => 1, |
|
140 | + ); |
|
141 | + |
|
142 | + $this->info_box_contents[$line][] = array( |
|
143 | + 'td' => 'class="right"', |
|
144 | + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
|
145 | + ); |
|
146 | + |
|
147 | + $this->info_box_contents[$line][] = array( |
|
148 | + 'td' => 'class="right"', |
|
149 | + 'text' => dol_print_date($date,'day'), |
|
150 | + ); |
|
146 | 151 | |
147 | 152 | $this->info_box_contents[$line][] = array( |
148 | - 'td' => 'class="right"', |
|
149 | - 'text' => dol_print_date($date,'day'), |
|
150 | - ); |
|
151 | - |
|
152 | - $this->info_box_contents[$line][] = array( |
|
153 | - 'td' => 'align="right" width="18"', |
|
154 | - 'text' => $supplierorderstatic->LibStatut($objp->fk_statut,3), |
|
155 | - ); |
|
156 | - |
|
157 | - $line++; |
|
158 | - } |
|
159 | - |
|
160 | - if ($num == 0) |
|
161 | - $this->info_box_contents[$line][0] = array( |
|
162 | - 'td' => 'align="center"', |
|
163 | - 'text' => $langs->trans("NoSupplierOrder"), |
|
164 | - ); |
|
165 | - |
|
166 | - $db->free($result); |
|
167 | - } else { |
|
168 | - $this->info_box_contents[0][0] = array( |
|
169 | - 'td' => '', |
|
170 | - 'maxlength'=>500, |
|
171 | - 'text' => ($db->error().' sql='.$sql), |
|
172 | - ); |
|
173 | - } |
|
174 | - } |
|
175 | - else |
|
176 | - { |
|
177 | - $this->info_box_contents[0][0] = array( |
|
178 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
179 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
180 | - ); |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Method to show box |
|
186 | - * |
|
187 | - * @param array $head Array with properties of box title |
|
188 | - * @param array $contents Array with properties of box lines |
|
153 | + 'td' => 'align="right" width="18"', |
|
154 | + 'text' => $supplierorderstatic->LibStatut($objp->fk_statut,3), |
|
155 | + ); |
|
156 | + |
|
157 | + $line++; |
|
158 | + } |
|
159 | + |
|
160 | + if ($num == 0) |
|
161 | + $this->info_box_contents[$line][0] = array( |
|
162 | + 'td' => 'align="center"', |
|
163 | + 'text' => $langs->trans("NoSupplierOrder"), |
|
164 | + ); |
|
165 | + |
|
166 | + $db->free($result); |
|
167 | + } else { |
|
168 | + $this->info_box_contents[0][0] = array( |
|
169 | + 'td' => '', |
|
170 | + 'maxlength'=>500, |
|
171 | + 'text' => ($db->error().' sql='.$sql), |
|
172 | + ); |
|
173 | + } |
|
174 | + } |
|
175 | + else |
|
176 | + { |
|
177 | + $this->info_box_contents[0][0] = array( |
|
178 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
179 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
180 | + ); |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Method to show box |
|
186 | + * |
|
187 | + * @param array $head Array with properties of box title |
|
188 | + * @param array $contents Array with properties of box lines |
|
189 | 189 | * @param int $nooutput No print, only return string |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
193 | - { |
|
194 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
195 | - } |
|
192 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
193 | + { |
|
194 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
195 | + } |
|
196 | 196 | |
197 | 197 | } |
198 | 198 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | var $boxcode = "latestsupplierorders"; |
36 | 36 | var $boximg = "object_order"; |
37 | - var $boxlabel="BoxLatestSupplierOrders"; |
|
37 | + var $boxlabel = "BoxLatestSupplierOrders"; |
|
38 | 38 | var $depends = array("fournisseur"); |
39 | 39 | |
40 | 40 | var $db; |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @param DoliDB $db Database handler |
50 | 50 | * @param string $param More parameters |
51 | 51 | */ |
52 | - function __construct($db,$param) |
|
52 | + function __construct($db, $param) |
|
53 | 53 | { |
54 | 54 | global $user; |
55 | 55 | |
56 | - $this->db=$db; |
|
56 | + $this->db = $db; |
|
57 | 57 | |
58 | - $this->hidden=! ($user->rights->fournisseur->commande->lire); |
|
58 | + $this->hidden = !($user->rights->fournisseur->commande->lire); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -72,32 +72,32 @@ discard block |
||
72 | 72 | $this->max = $max; |
73 | 73 | |
74 | 74 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; |
75 | - $supplierorderstatic=new CommandeFournisseur($db); |
|
75 | + $supplierorderstatic = new CommandeFournisseur($db); |
|
76 | 76 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
77 | 77 | $thirdpartytmp = new Fournisseur($db); |
78 | 78 | |
79 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierOrders", $max)); |
|
79 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); |
|
80 | 80 | |
81 | 81 | if ($user->rights->fournisseur->commande->lire) |
82 | 82 | { |
83 | 83 | $sql = "SELECT s.nom as name, s.rowid as socid,"; |
84 | - $sql.= " s.code_client, s.code_fournisseur,"; |
|
85 | - $sql.= " s.logo,"; |
|
86 | - $sql.= " c.ref, c.tms, c.rowid, c.date_commande,"; |
|
87 | - $sql.= " c.total_ht,"; |
|
88 | - $sql.= " c.tva as total_tva,"; |
|
89 | - $sql.= " c.total_ttc,"; |
|
90 | - $sql.= " c.fk_statut"; |
|
91 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
92 | - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; |
|
93 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
94 | - $sql.= " WHERE c.fk_soc = s.rowid"; |
|
95 | - $sql.= " AND c.entity = ".$conf->entity; |
|
96 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
97 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
98 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
99 | - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
100 | - $sql.= $db->plimit($max, 0); |
|
84 | + $sql .= " s.code_client, s.code_fournisseur,"; |
|
85 | + $sql .= " s.logo,"; |
|
86 | + $sql .= " c.ref, c.tms, c.rowid, c.date_commande,"; |
|
87 | + $sql .= " c.total_ht,"; |
|
88 | + $sql .= " c.tva as total_tva,"; |
|
89 | + $sql .= " c.total_ttc,"; |
|
90 | + $sql .= " c.fk_statut"; |
|
91 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
92 | + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; |
|
93 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
94 | + $sql .= " WHERE c.fk_soc = s.rowid"; |
|
95 | + $sql .= " AND c.entity = ".$conf->entity; |
|
96 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
97 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
98 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
99 | + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; |
|
100 | + $sql .= $db->plimit($max, 0); |
|
101 | 101 | |
102 | 102 | $result = $db->query($sql); |
103 | 103 | if ($result) |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $line = 0; |
108 | 108 | while ($line < $num) { |
109 | 109 | $objp = $db->fetch_object($result); |
110 | - $date=$db->jdate($objp->date_commande); |
|
111 | - $datem=$db->jdate($objp->tms); |
|
110 | + $date = $db->jdate($objp->date_commande); |
|
111 | + $datem = $db->jdate($objp->tms); |
|
112 | 112 | $thirdpartytmp->id = $objp->socid; |
113 | 113 | $thirdpartytmp->name = $objp->name; |
114 | 114 | $thirdpartytmp->fournisseur = 1; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $urlo = DOL_URL_ROOT."/fourn/commande/card.php?id=".$objp->rowid; |
119 | 119 | $urls = DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid; |
120 | 120 | |
121 | - $tooltip = $langs->trans('SupplierOrder') . ': ' . $objp->ref; |
|
121 | + $tooltip = $langs->trans('SupplierOrder').': '.$objp->ref; |
|
122 | 122 | $this->info_box_contents[$line][] = array( |
123 | 123 | 'td' => 'align="left" width="16"', |
124 | 124 | 'logo' => $this->boximg, |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | |
147 | 147 | $this->info_box_contents[$line][] = array( |
148 | 148 | 'td' => 'class="right"', |
149 | - 'text' => dol_print_date($date,'day'), |
|
149 | + 'text' => dol_print_date($date, 'day'), |
|
150 | 150 | ); |
151 | 151 | |
152 | 152 | $this->info_box_contents[$line][] = array( |
153 | 153 | 'td' => 'align="right" width="18"', |
154 | - 'text' => $supplierorderstatic->LibStatut($objp->fk_statut,3), |
|
154 | + 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), |
|
155 | 155 | ); |
156 | 156 | |
157 | 157 | $line++; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @param int $nooutput No print, only return string |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
192 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
193 | 193 | { |
194 | 194 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
195 | 195 | } |
@@ -90,13 +90,22 @@ discard block |
||
90 | 90 | $sql.= " c.fk_statut"; |
91 | 91 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
92 | 92 | $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; |
93 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
93 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
94 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
95 | + } |
|
94 | 96 | $sql.= " WHERE c.fk_soc = s.rowid"; |
95 | 97 | $sql.= " AND c.entity = ".$conf->entity; |
96 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
97 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
98 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
99 | - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
98 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
99 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
100 | + } |
|
101 | + if ($user->societe_id) { |
|
102 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
103 | + } |
|
104 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { |
|
105 | + $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
106 | + } else { |
|
107 | + $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
108 | + } |
|
100 | 109 | $sql.= $db->plimit($max, 0); |
101 | 110 | |
102 | 111 | $result = $db->query($sql); |
@@ -157,11 +166,12 @@ discard block |
||
157 | 166 | $line++; |
158 | 167 | } |
159 | 168 | |
160 | - if ($num == 0) |
|
161 | - $this->info_box_contents[$line][0] = array( |
|
169 | + if ($num == 0) { |
|
170 | + $this->info_box_contents[$line][0] = array( |
|
162 | 171 | 'td' => 'align="center"', |
163 | 172 | 'text' => $langs->trans("NoSupplierOrder"), |
164 | 173 | ); |
174 | + } |
|
165 | 175 | |
166 | 176 | $db->free($result); |
167 | 177 | } else { |
@@ -171,8 +181,7 @@ discard block |
||
171 | 181 | 'text' => ($db->error().' sql='.$sql), |
172 | 182 | ); |
173 | 183 | } |
174 | - } |
|
175 | - else |
|
184 | + } else |
|
176 | 185 | { |
177 | 186 | $this->info_box_contents[0][0] = array( |
178 | 187 | 'td' => 'align="left" class="nohover opacitymedium"', |
@@ -32,149 +32,149 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class box_propales extends ModeleBoxes |
34 | 34 | { |
35 | - var $boxcode="lastpropals"; |
|
36 | - var $boximg="object_propal"; |
|
37 | - var $boxlabel="BoxLastProposals"; |
|
38 | - var $depends = array("propal"); // conf->propal->enabled |
|
35 | + var $boxcode="lastpropals"; |
|
36 | + var $boximg="object_propal"; |
|
37 | + var $boxlabel="BoxLastProposals"; |
|
38 | + var $depends = array("propal"); // conf->propal->enabled |
|
39 | 39 | |
40 | - var $db; |
|
41 | - var $param; |
|
40 | + var $db; |
|
41 | + var $param; |
|
42 | 42 | |
43 | - var $info_box_head = array(); |
|
44 | - var $info_box_contents = array(); |
|
43 | + var $info_box_head = array(); |
|
44 | + var $info_box_contents = array(); |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * Constructor |
|
49 | - * |
|
50 | - * @param DoliDB $db Database handler |
|
51 | - * @param string $param More parameters |
|
52 | - */ |
|
53 | - function __construct($db,$param) |
|
54 | - { |
|
55 | - global $user; |
|
47 | + /** |
|
48 | + * Constructor |
|
49 | + * |
|
50 | + * @param DoliDB $db Database handler |
|
51 | + * @param string $param More parameters |
|
52 | + */ |
|
53 | + function __construct($db,$param) |
|
54 | + { |
|
55 | + global $user; |
|
56 | 56 | |
57 | - $this->db=$db; |
|
57 | + $this->db=$db; |
|
58 | 58 | |
59 | - $this->hidden=! ($user->rights->propale->lire); |
|
60 | - } |
|
59 | + $this->hidden=! ($user->rights->propale->lire); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
62 | + /** |
|
63 | 63 | * Load data into info_box_contents array to show array later. |
64 | 64 | * |
65 | 65 | * @param int $max Maximum number of records to load |
66 | - * @return void |
|
67 | - */ |
|
68 | - function loadBox($max=5) |
|
69 | - { |
|
70 | - global $user, $langs, $db, $conf; |
|
71 | - |
|
72 | - $this->max=$max; |
|
73 | - |
|
74 | - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
75 | - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
76 | - $propalstatic=new Propal($db); |
|
77 | - $societestatic = new Societe($db); |
|
78 | - |
|
79 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."Propals",$max)); |
|
80 | - |
|
81 | - if ($user->rights->propale->lire) |
|
82 | - { |
|
83 | - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo,"; |
|
84 | - $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"; |
|
85 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
86 | - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
|
87 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | - $sql.= " WHERE p.fk_soc = s.rowid"; |
|
89 | - $sql.= " AND p.entity = ".$conf->entity; |
|
90 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; |
|
93 | - else $sql.= " ORDER BY p.tms DESC, p.ref DESC "; |
|
94 | - $sql.= $db->plimit($max, 0); |
|
95 | - |
|
96 | - $result = $db->query($sql); |
|
97 | - if ($result) |
|
98 | - { |
|
99 | - $num = $db->num_rows($result); |
|
100 | - $now=dol_now(); |
|
101 | - |
|
102 | - $line = 0; |
|
103 | - |
|
104 | - while ($line < $num) { |
|
105 | - $objp = $db->fetch_object($result); |
|
106 | - $date=$db->jdate($objp->dp); |
|
107 | - $datec=$db->jdate($objp->datec); |
|
108 | - $datem=$db->jdate($objp->tms); |
|
109 | - $dateterm=$db->jdate($objp->fin_validite); |
|
110 | - $dateclose=$db->jdate($objp->date_cloture); |
|
111 | - $propalstatic->id = $objp->rowid; |
|
112 | - $propalstatic->ref = $objp->ref; |
|
113 | - $propalstatic->total_ht = $objp->total_ht; |
|
114 | - $propalstatic->total_tva = $objp->total_tva; |
|
115 | - $propalstatic->total_ttc = $objp->total_ttc; |
|
116 | - $societestatic->id = $objp->socid; |
|
117 | - $societestatic->name = $objp->name; |
|
118 | - $societestatic->code_client = $objp->code_client; |
|
119 | - $societestatic->logo = $objp->logo; |
|
120 | - |
|
121 | - $late = ''; |
|
122 | - if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { |
|
123 | - $late = img_warning($langs->trans("Late")); |
|
124 | - } |
|
125 | - |
|
126 | - $this->info_box_contents[$line][] = array( |
|
127 | - 'td' => '', |
|
128 | - 'text' => $propalstatic->getNomUrl(1), |
|
129 | - 'text2'=> $late, |
|
130 | - 'asis' => 1, |
|
131 | - ); |
|
132 | - |
|
133 | - $this->info_box_contents[$line][] = array( |
|
134 | - 'td' => 'class="tdoverflowmax100"', |
|
135 | - 'text' => $societestatic->getNomUrl(1), |
|
136 | - 'asis' => 1, |
|
137 | - ); |
|
138 | - |
|
139 | - $this->info_box_contents[$line][] = array( |
|
140 | - 'td' => 'class="right"', |
|
141 | - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
|
142 | - ); |
|
143 | - |
|
144 | - $this->info_box_contents[$line][] = array( |
|
145 | - 'td' => 'class="right"', |
|
146 | - 'text' => dol_print_date($date,'day'), |
|
147 | - ); |
|
148 | - |
|
149 | - $this->info_box_contents[$line][] = array( |
|
150 | - 'td' => 'align="right" width="18"', |
|
151 | - 'text' => $propalstatic->LibStatut($objp->fk_statut,3), |
|
152 | - ); |
|
153 | - |
|
154 | - $line++; |
|
155 | - } |
|
156 | - |
|
157 | - if ($num==0) |
|
158 | - $this->info_box_contents[$line][0] = array( |
|
159 | - 'td' => 'align="center"', |
|
160 | - 'text'=>$langs->trans("NoRecordedProposals"), |
|
161 | - ); |
|
162 | - |
|
163 | - $db->free($result); |
|
164 | - } else { |
|
165 | - $this->info_box_contents[0][0] = array( |
|
166 | - 'td' => '', |
|
167 | - 'maxlength'=>500, |
|
168 | - 'text' => ($db->error().' sql='.$sql), |
|
169 | - ); |
|
170 | - } |
|
171 | - } else { |
|
172 | - $this->info_box_contents[0][0] = array( |
|
173 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
174 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
175 | - ); |
|
176 | - } |
|
177 | - } |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + function loadBox($max=5) |
|
69 | + { |
|
70 | + global $user, $langs, $db, $conf; |
|
71 | + |
|
72 | + $this->max=$max; |
|
73 | + |
|
74 | + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
75 | + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
76 | + $propalstatic=new Propal($db); |
|
77 | + $societestatic = new Societe($db); |
|
78 | + |
|
79 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."Propals",$max)); |
|
80 | + |
|
81 | + if ($user->rights->propale->lire) |
|
82 | + { |
|
83 | + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo,"; |
|
84 | + $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"; |
|
85 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
86 | + $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
|
87 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | + $sql.= " WHERE p.fk_soc = s.rowid"; |
|
89 | + $sql.= " AND p.entity = ".$conf->entity; |
|
90 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; |
|
93 | + else $sql.= " ORDER BY p.tms DESC, p.ref DESC "; |
|
94 | + $sql.= $db->plimit($max, 0); |
|
95 | + |
|
96 | + $result = $db->query($sql); |
|
97 | + if ($result) |
|
98 | + { |
|
99 | + $num = $db->num_rows($result); |
|
100 | + $now=dol_now(); |
|
101 | + |
|
102 | + $line = 0; |
|
103 | + |
|
104 | + while ($line < $num) { |
|
105 | + $objp = $db->fetch_object($result); |
|
106 | + $date=$db->jdate($objp->dp); |
|
107 | + $datec=$db->jdate($objp->datec); |
|
108 | + $datem=$db->jdate($objp->tms); |
|
109 | + $dateterm=$db->jdate($objp->fin_validite); |
|
110 | + $dateclose=$db->jdate($objp->date_cloture); |
|
111 | + $propalstatic->id = $objp->rowid; |
|
112 | + $propalstatic->ref = $objp->ref; |
|
113 | + $propalstatic->total_ht = $objp->total_ht; |
|
114 | + $propalstatic->total_tva = $objp->total_tva; |
|
115 | + $propalstatic->total_ttc = $objp->total_ttc; |
|
116 | + $societestatic->id = $objp->socid; |
|
117 | + $societestatic->name = $objp->name; |
|
118 | + $societestatic->code_client = $objp->code_client; |
|
119 | + $societestatic->logo = $objp->logo; |
|
120 | + |
|
121 | + $late = ''; |
|
122 | + if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { |
|
123 | + $late = img_warning($langs->trans("Late")); |
|
124 | + } |
|
125 | + |
|
126 | + $this->info_box_contents[$line][] = array( |
|
127 | + 'td' => '', |
|
128 | + 'text' => $propalstatic->getNomUrl(1), |
|
129 | + 'text2'=> $late, |
|
130 | + 'asis' => 1, |
|
131 | + ); |
|
132 | + |
|
133 | + $this->info_box_contents[$line][] = array( |
|
134 | + 'td' => 'class="tdoverflowmax100"', |
|
135 | + 'text' => $societestatic->getNomUrl(1), |
|
136 | + 'asis' => 1, |
|
137 | + ); |
|
138 | + |
|
139 | + $this->info_box_contents[$line][] = array( |
|
140 | + 'td' => 'class="right"', |
|
141 | + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
|
142 | + ); |
|
143 | + |
|
144 | + $this->info_box_contents[$line][] = array( |
|
145 | + 'td' => 'class="right"', |
|
146 | + 'text' => dol_print_date($date,'day'), |
|
147 | + ); |
|
148 | + |
|
149 | + $this->info_box_contents[$line][] = array( |
|
150 | + 'td' => 'align="right" width="18"', |
|
151 | + 'text' => $propalstatic->LibStatut($objp->fk_statut,3), |
|
152 | + ); |
|
153 | + |
|
154 | + $line++; |
|
155 | + } |
|
156 | + |
|
157 | + if ($num==0) |
|
158 | + $this->info_box_contents[$line][0] = array( |
|
159 | + 'td' => 'align="center"', |
|
160 | + 'text'=>$langs->trans("NoRecordedProposals"), |
|
161 | + ); |
|
162 | + |
|
163 | + $db->free($result); |
|
164 | + } else { |
|
165 | + $this->info_box_contents[0][0] = array( |
|
166 | + 'td' => '', |
|
167 | + 'maxlength'=>500, |
|
168 | + 'text' => ($db->error().' sql='.$sql), |
|
169 | + ); |
|
170 | + } |
|
171 | + } else { |
|
172 | + $this->info_box_contents[0][0] = array( |
|
173 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
174 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
175 | + ); |
|
176 | + } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | /** |
180 | 180 | * Method to show box |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * @param int $nooutput No print, only return string |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
188 | - { |
|
189 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
190 | - } |
|
187 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
188 | + { |
|
189 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
190 | + } |
|
191 | 191 | |
192 | 192 | } |
193 | 193 |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class box_propales extends ModeleBoxes |
34 | 34 | { |
35 | - var $boxcode="lastpropals"; |
|
36 | - var $boximg="object_propal"; |
|
37 | - var $boxlabel="BoxLastProposals"; |
|
38 | - var $depends = array("propal"); // conf->propal->enabled |
|
35 | + var $boxcode = "lastpropals"; |
|
36 | + var $boximg = "object_propal"; |
|
37 | + var $boxlabel = "BoxLastProposals"; |
|
38 | + var $depends = array("propal"); // conf->propal->enabled |
|
39 | 39 | |
40 | 40 | var $db; |
41 | 41 | var $param; |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | * @param DoliDB $db Database handler |
51 | 51 | * @param string $param More parameters |
52 | 52 | */ |
53 | - function __construct($db,$param) |
|
53 | + function __construct($db, $param) |
|
54 | 54 | { |
55 | 55 | global $user; |
56 | 56 | |
57 | - $this->db=$db; |
|
57 | + $this->db = $db; |
|
58 | 58 | |
59 | - $this->hidden=! ($user->rights->propale->lire); |
|
59 | + $this->hidden = !($user->rights->propale->lire); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -65,49 +65,49 @@ discard block |
||
65 | 65 | * @param int $max Maximum number of records to load |
66 | 66 | * @return void |
67 | 67 | */ |
68 | - function loadBox($max=5) |
|
68 | + function loadBox($max = 5) |
|
69 | 69 | { |
70 | 70 | global $user, $langs, $db, $conf; |
71 | 71 | |
72 | - $this->max=$max; |
|
72 | + $this->max = $max; |
|
73 | 73 | |
74 | 74 | include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
75 | 75 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
76 | - $propalstatic=new Propal($db); |
|
76 | + $propalstatic = new Propal($db); |
|
77 | 77 | $societestatic = new Societe($db); |
78 | 78 | |
79 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."Propals",$max)); |
|
79 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max)); |
|
80 | 80 | |
81 | 81 | if ($user->rights->propale->lire) |
82 | 82 | { |
83 | 83 | $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo,"; |
84 | - $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"; |
|
85 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
86 | - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
|
87 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | - $sql.= " WHERE p.fk_soc = s.rowid"; |
|
89 | - $sql.= " AND p.entity = ".$conf->entity; |
|
90 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; |
|
93 | - else $sql.= " ORDER BY p.tms DESC, p.ref DESC "; |
|
94 | - $sql.= $db->plimit($max, 0); |
|
84 | + $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"; |
|
85 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
86 | + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; |
|
87 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | + $sql .= " WHERE p.fk_soc = s.rowid"; |
|
89 | + $sql .= " AND p.entity = ".$conf->entity; |
|
90 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
91 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
92 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; |
|
93 | + else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; |
|
94 | + $sql .= $db->plimit($max, 0); |
|
95 | 95 | |
96 | 96 | $result = $db->query($sql); |
97 | 97 | if ($result) |
98 | 98 | { |
99 | 99 | $num = $db->num_rows($result); |
100 | - $now=dol_now(); |
|
100 | + $now = dol_now(); |
|
101 | 101 | |
102 | 102 | $line = 0; |
103 | 103 | |
104 | 104 | while ($line < $num) { |
105 | 105 | $objp = $db->fetch_object($result); |
106 | - $date=$db->jdate($objp->dp); |
|
107 | - $datec=$db->jdate($objp->datec); |
|
108 | - $datem=$db->jdate($objp->tms); |
|
109 | - $dateterm=$db->jdate($objp->fin_validite); |
|
110 | - $dateclose=$db->jdate($objp->date_cloture); |
|
106 | + $date = $db->jdate($objp->dp); |
|
107 | + $datec = $db->jdate($objp->datec); |
|
108 | + $datem = $db->jdate($objp->tms); |
|
109 | + $dateterm = $db->jdate($objp->fin_validite); |
|
110 | + $dateclose = $db->jdate($objp->date_cloture); |
|
111 | 111 | $propalstatic->id = $objp->rowid; |
112 | 112 | $propalstatic->ref = $objp->ref; |
113 | 113 | $propalstatic->total_ht = $objp->total_ht; |
@@ -143,18 +143,18 @@ discard block |
||
143 | 143 | |
144 | 144 | $this->info_box_contents[$line][] = array( |
145 | 145 | 'td' => 'class="right"', |
146 | - 'text' => dol_print_date($date,'day'), |
|
146 | + 'text' => dol_print_date($date, 'day'), |
|
147 | 147 | ); |
148 | 148 | |
149 | 149 | $this->info_box_contents[$line][] = array( |
150 | 150 | 'td' => 'align="right" width="18"', |
151 | - 'text' => $propalstatic->LibStatut($objp->fk_statut,3), |
|
151 | + 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), |
|
152 | 152 | ); |
153 | 153 | |
154 | 154 | $line++; |
155 | 155 | } |
156 | 156 | |
157 | - if ($num==0) |
|
157 | + if ($num == 0) |
|
158 | 158 | $this->info_box_contents[$line][0] = array( |
159 | 159 | 'td' => 'align="center"', |
160 | 160 | 'text'=>$langs->trans("NoRecordedProposals"), |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param int $nooutput No print, only return string |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
187 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
188 | 188 | { |
189 | 189 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
190 | 190 | } |
@@ -84,13 +84,22 @@ discard block |
||
84 | 84 | $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"; |
85 | 85 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
86 | 86 | $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
87 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
87 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
88 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
89 | + } |
|
88 | 90 | $sql.= " WHERE p.fk_soc = s.rowid"; |
89 | 91 | $sql.= " AND p.entity = ".$conf->entity; |
90 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
91 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
92 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY p.datep DESC, p.ref DESC "; |
|
93 | - else $sql.= " ORDER BY p.tms DESC, p.ref DESC "; |
|
92 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
93 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
94 | + } |
|
95 | + if($user->societe_id) { |
|
96 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
97 | + } |
|
98 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { |
|
99 | + $sql.= " ORDER BY p.datep DESC, p.ref DESC "; |
|
100 | + } else { |
|
101 | + $sql.= " ORDER BY p.tms DESC, p.ref DESC "; |
|
102 | + } |
|
94 | 103 | $sql.= $db->plimit($max, 0); |
95 | 104 | |
96 | 105 | $result = $db->query($sql); |
@@ -154,11 +163,12 @@ discard block |
||
154 | 163 | $line++; |
155 | 164 | } |
156 | 165 | |
157 | - if ($num==0) |
|
158 | - $this->info_box_contents[$line][0] = array( |
|
166 | + if ($num==0) { |
|
167 | + $this->info_box_contents[$line][0] = array( |
|
159 | 168 | 'td' => 'align="center"', |
160 | 169 | 'text'=>$langs->trans("NoRecordedProposals"), |
161 | 170 | ); |
171 | + } |
|
162 | 172 | |
163 | 173 | $db->free($result); |
164 | 174 | } else { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * Constructor |
50 | 50 | * |
51 | 51 | * @param DoliDB $db Database handler |
52 | - * @param string $param More parameters |
|
52 | + * @param string $param More parameters |
|
53 | 53 | */ |
54 | 54 | function __construct($db,$param='') |
55 | 55 | { |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | - * Load data for box to show them later |
|
69 | - * |
|
70 | - * @param int $max Maximum number of records to load |
|
71 | - * @return void |
|
68 | + * Load data for box to show them later |
|
69 | + * |
|
70 | + * @param int $max Maximum number of records to load |
|
71 | + * @return void |
|
72 | 72 | */ |
73 | 73 | function loadBox($max=5) |
74 | 74 | { |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | |
78 | 78 | $this->max=$max; |
79 | 79 | |
80 | - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
81 | - $thirdpartystatic=new Societe($db); |
|
80 | + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
81 | + $thirdpartystatic=new Societe($db); |
|
82 | 82 | |
83 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers",$max)); |
|
83 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers",$max)); |
|
84 | 84 | |
85 | 85 | if ($user->rights->societe->lire) |
86 | 86 | { |
@@ -116,24 +116,24 @@ discard block |
||
116 | 116 | $nbimpaye = $objp->nbfact - $objp->nbfactpaye; |
117 | 117 | |
118 | 118 | $this->info_box_contents[$line][] = array( |
119 | - 'td' => '', |
|
120 | - 'text' => $thirdpartystatic->getNomUrl(1), |
|
121 | - 'asis' => 1, |
|
119 | + 'td' => '', |
|
120 | + 'text' => $thirdpartystatic->getNomUrl(1), |
|
121 | + 'asis' => 1, |
|
122 | 122 | ); |
123 | 123 | |
124 | 124 | $this->info_box_contents[$line][] = array( |
125 | - 'td' => 'class="right"', |
|
126 | - 'text' => dol_print_date($datem, "day") |
|
125 | + 'td' => 'class="right"', |
|
126 | + 'text' => dol_print_date($datem, "day") |
|
127 | 127 | ); |
128 | 128 | |
129 | 129 | $this->info_box_contents[$line][] = array( |
130 | - 'td' => 'class="right"', |
|
131 | - 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') |
|
130 | + 'td' => 'class="right"', |
|
131 | + 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | $this->info_box_contents[$line][] = array( |
135 | - 'td' => 'align="right" width="18"', |
|
136 | - 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
135 | + 'td' => 'align="right" width="18"', |
|
136 | + 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
137 | 137 | ); |
138 | 138 | |
139 | 139 | $line++; |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | } |
146 | 146 | else { |
147 | 147 | $this->info_box_contents[0][0] = array( 'td' => '', |
148 | - 'maxlength'=>500, |
|
149 | - 'text' => ($db->error().' sql='.$sql)); |
|
148 | + 'maxlength'=>500, |
|
149 | + 'text' => ($db->error().' sql='.$sql)); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | else { |
153 | 153 | $this->info_box_contents[0][0] = array( |
154 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
154 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
155 | 155 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
156 | 156 | ); |
157 | 157 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * @param int $nooutput No print, only return string |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
170 | - { |
|
169 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
170 | + { |
|
171 | 171 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
172 | 172 | } |
173 | 173 | } |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class box_goodcustomers extends ModeleBoxes |
35 | 35 | { |
36 | - var $boxcode="goodcustomers"; |
|
37 | - var $boximg="object_company"; |
|
38 | - var $boxlabel="BoxGoodCustomers"; |
|
36 | + var $boxcode = "goodcustomers"; |
|
37 | + var $boximg = "object_company"; |
|
38 | + var $boxlabel = "BoxGoodCustomers"; |
|
39 | 39 | var $depends = array("societe"); |
40 | 40 | |
41 | 41 | var $db; |
@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | * @param DoliDB $db Database handler |
52 | 52 | * @param string $param More parameters |
53 | 53 | */ |
54 | - function __construct($db,$param='') |
|
54 | + function __construct($db, $param = '') |
|
55 | 55 | { |
56 | 56 | global $conf, $user; |
57 | 57 | |
58 | 58 | $this->db = $db; |
59 | 59 | |
60 | 60 | // disable box for such cases |
61 | - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option |
|
62 | - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database |
|
61 | + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option |
|
62 | + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled = 0; // not enabled by default. Very slow on large database |
|
63 | 63 | |
64 | - $this->hidden = ! ($user->rights->societe->lire); |
|
64 | + $this->hidden = !($user->rights->societe->lire); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,29 +70,29 @@ discard block |
||
70 | 70 | * @param int $max Maximum number of records to load |
71 | 71 | * @return void |
72 | 72 | */ |
73 | - function loadBox($max=5) |
|
73 | + function loadBox($max = 5) |
|
74 | 74 | { |
75 | 75 | global $user, $langs, $db, $conf; |
76 | 76 | $langs->load("boxes"); |
77 | 77 | |
78 | - $this->max=$max; |
|
78 | + $this->max = $max; |
|
79 | 79 | |
80 | 80 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
81 | - $thirdpartystatic=new Societe($db); |
|
81 | + $thirdpartystatic = new Societe($db); |
|
82 | 82 | |
83 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers",$max)); |
|
83 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); |
|
84 | 84 | |
85 | 85 | if ($user->rights->societe->lire) |
86 | 86 | { |
87 | 87 | |
88 | 88 | $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,"; |
89 | - $sql.= " count(*) as nbfact, sum(". $db->ifsql('f.paye=1','1','0').") as nbfactpaye"; |
|
90 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
|
91 | - $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
92 | - $sql.= ' AND s.rowid = f.fk_soc'; |
|
93 | - $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; |
|
94 | - $sql.= $db->order("nbfact","DESC"); |
|
95 | - $sql.= $db->plimit($max,0); |
|
89 | + $sql .= " count(*) as nbfact, sum(".$db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; |
|
90 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
|
91 | + $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
92 | + $sql .= ' AND s.rowid = f.fk_soc'; |
|
93 | + $sql .= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; |
|
94 | + $sql .= $db->order("nbfact", "DESC"); |
|
95 | + $sql .= $db->plimit($max, 0); |
|
96 | 96 | |
97 | 97 | dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); |
98 | 98 | $result = $db->query($sql); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | while ($line < $num) |
105 | 105 | { |
106 | 106 | $objp = $db->fetch_object($result); |
107 | - $datem=$db->jdate($objp->tms); |
|
107 | + $datem = $db->jdate($objp->tms); |
|
108 | 108 | $thirdpartystatic->id = $objp->rowid; |
109 | 109 | $thirdpartystatic->name = $objp->name; |
110 | 110 | $thirdpartystatic->code_client = $objp->code_client; |
@@ -128,23 +128,23 @@ discard block |
||
128 | 128 | |
129 | 129 | $this->info_box_contents[$line][] = array( |
130 | 130 | 'td' => 'class="right"', |
131 | - 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') |
|
131 | + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | $this->info_box_contents[$line][] = array( |
135 | 135 | 'td' => 'align="right" width="18"', |
136 | - 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
136 | + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) |
|
137 | 137 | ); |
138 | 138 | |
139 | 139 | $line++; |
140 | 140 | } |
141 | 141 | |
142 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
142 | + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoRecordedCustomers")); |
|
143 | 143 | |
144 | 144 | $db->free($result); |
145 | 145 | } |
146 | 146 | else { |
147 | - $this->info_box_contents[0][0] = array( 'td' => '', |
|
147 | + $this->info_box_contents[0][0] = array('td' => '', |
|
148 | 148 | 'maxlength'=>500, |
149 | 149 | 'text' => ($db->error().' sql='.$sql)); |
150 | 150 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param int $nooutput No print, only return string |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
169 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
170 | 170 | { |
171 | 171 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
172 | 172 | } |
@@ -58,8 +58,14 @@ discard block |
||
58 | 58 | $this->db = $db; |
59 | 59 | |
60 | 60 | // disable box for such cases |
61 | - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option |
|
62 | - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database |
|
61 | + if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { |
|
62 | + $this->enabled=0; |
|
63 | + } |
|
64 | + // disabled by this option |
|
65 | + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) { |
|
66 | + $this->enabled=0; |
|
67 | + } |
|
68 | + // not enabled by default. Very slow on large database |
|
63 | 69 | |
64 | 70 | $this->hidden = ! ($user->rights->societe->lire); |
65 | 71 | } |
@@ -139,17 +145,17 @@ discard block |
||
139 | 145 | $line++; |
140 | 146 | } |
141 | 147 | |
142 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
148 | + if ($num==0) { |
|
149 | + $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
150 | + } |
|
143 | 151 | |
144 | 152 | $db->free($result); |
145 | - } |
|
146 | - else { |
|
153 | + } else { |
|
147 | 154 | $this->info_box_contents[0][0] = array( 'td' => '', |
148 | 155 | 'maxlength'=>500, |
149 | 156 | 'text' => ($db->error().' sql='.$sql)); |
150 | 157 | } |
151 | - } |
|
152 | - else { |
|
158 | + } else { |
|
153 | 159 | $this->info_box_contents[0][0] = array( |
154 | 160 | 'td' => 'align="left" class="nohover opacitymedium"', |
155 | 161 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
@@ -32,159 +32,159 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class box_commandes extends ModeleBoxes |
34 | 34 | { |
35 | - var $boxcode="lastcustomerorders"; |
|
36 | - var $boximg="object_order"; |
|
37 | - var $boxlabel="BoxLastCustomerOrders"; |
|
38 | - var $depends = array("commande"); |
|
35 | + var $boxcode="lastcustomerorders"; |
|
36 | + var $boximg="object_order"; |
|
37 | + var $boxlabel="BoxLastCustomerOrders"; |
|
38 | + var $depends = array("commande"); |
|
39 | 39 | |
40 | 40 | var $db; |
41 | 41 | var $param; |
42 | 42 | |
43 | - var $info_box_head = array(); |
|
44 | - var $info_box_contents = array(); |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * Constructor |
|
49 | - * |
|
50 | - * @param DoliDB $db Database handler |
|
51 | - * @param string $param More parameters |
|
52 | - */ |
|
53 | - function __construct($db,$param) |
|
54 | - { |
|
55 | - global $user; |
|
56 | - |
|
57 | - $this->db=$db; |
|
58 | - |
|
59 | - $this->hidden=! ($user->rights->commande->lire); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Load data for box to show them later |
|
64 | - * |
|
65 | - * @param int $max Maximum number of records to load |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - function loadBox($max=5) |
|
69 | - { |
|
70 | - global $user, $langs, $db, $conf; |
|
71 | - |
|
72 | - $this->max = $max; |
|
73 | - |
|
74 | - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
75 | - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
76 | - |
|
77 | - $commandestatic = new Commande($db); |
|
78 | - $societestatic = new Societe($db); |
|
79 | - $userstatic = new User($db); |
|
80 | - |
|
81 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerOrders",$max)); |
|
82 | - |
|
83 | - if ($user->rights->commande->lire) |
|
84 | - { |
|
85 | - $sql = "SELECT s.nom as name"; |
|
86 | - $sql.= ", s.rowid as socid"; |
|
87 | - $sql.= ", s.code_client"; |
|
88 | - $sql.= ", s.logo"; |
|
89 | - $sql.= ", c.ref, c.tms"; |
|
90 | - $sql.= ", c.rowid"; |
|
91 | - $sql.= ", c.date_commande"; |
|
92 | - $sql.= ", c.ref_client"; |
|
93 | - $sql.= ", c.fk_statut"; |
|
94 | - $sql.= ", c.fk_user_valid"; |
|
95 | - $sql.= ", c.facture"; |
|
96 | - $sql.= ", c.total_ht"; |
|
97 | - $sql.= ", c.tva as total_tva"; |
|
98 | - $sql.= ", c.total_ttc"; |
|
99 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
100 | - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; |
|
101 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | - $sql.= " WHERE c.fk_soc = s.rowid"; |
|
103 | - $sql.= " AND c.entity = ".$conf->entity; |
|
104 | - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; |
|
105 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
106 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
107 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
108 | - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
109 | - $sql.= $db->plimit($max, 0); |
|
110 | - |
|
111 | - $result = $db->query($sql); |
|
112 | - if ($result) { |
|
113 | - $num = $db->num_rows($result); |
|
114 | - |
|
115 | - $line = 0; |
|
116 | - |
|
117 | - while ($line < $num) { |
|
118 | - $objp = $db->fetch_object($result); |
|
119 | - $date=$db->jdate($objp->date_commande); |
|
120 | - $datem=$db->jdate($objp->tms); |
|
121 | - $commandestatic->id = $objp->rowid; |
|
122 | - $commandestatic->ref = $objp->ref; |
|
123 | - $commandestatic->ref_client = $objp->ref_client; |
|
124 | - $commandestatic->total_ht = $objp->total_ht; |
|
125 | - $commandestatic->total_tva = $objp->total_tva; |
|
126 | - $commandestatic->total_ttc = $objp->total_ttc; |
|
127 | - $societestatic->id = $objp->socid; |
|
128 | - $societestatic->name = $objp->name; |
|
129 | - $societestatic->code_client = $objp->code_client; |
|
130 | - $societestatic->logo = $objp->logo; |
|
131 | - |
|
132 | - $this->info_box_contents[$line][] = array( |
|
133 | - 'td' => '', |
|
134 | - 'text' => $commandestatic->getNomUrl(1), |
|
135 | - 'asis' => 1, |
|
136 | - ); |
|
137 | - |
|
138 | - $this->info_box_contents[$line][] = array( |
|
139 | - 'td' => 'class="tdoverflowmax100"', |
|
140 | - 'text' => $societestatic->getNomUrl(1), |
|
141 | - 'asis' => 1, |
|
142 | - ); |
|
143 | - |
|
144 | - $this->info_box_contents[$line][] = array( |
|
145 | - 'td' => 'class="right"', |
|
146 | - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
|
147 | - ); |
|
148 | - |
|
149 | - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { |
|
150 | - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); |
|
151 | - $this->info_box_contents[$line][] = array( |
|
152 | - 'td' => 'class="right"', |
|
153 | - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), |
|
154 | - 'asis' => 1, |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - $this->info_box_contents[$line][] = array( |
|
159 | - 'td' => 'class="right"', |
|
160 | - 'text' => dol_print_date($date,'day'), |
|
161 | - ); |
|
162 | - |
|
163 | - $this->info_box_contents[$line][] = array( |
|
164 | - 'td' => 'align="right" width="18"', |
|
165 | - 'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3), |
|
166 | - ); |
|
167 | - |
|
168 | - $line++; |
|
169 | - } |
|
170 | - |
|
171 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedOrders")); |
|
172 | - |
|
173 | - $db->free($result); |
|
174 | - } else { |
|
175 | - $this->info_box_contents[0][0] = array( |
|
176 | - 'td' => '', |
|
177 | - 'maxlength'=>500, |
|
178 | - 'text' => ($db->error().' sql='.$sql), |
|
179 | - ); |
|
180 | - } |
|
181 | - } else { |
|
182 | - $this->info_box_contents[0][0] = array( |
|
183 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
184 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
185 | - ); |
|
186 | - } |
|
187 | - } |
|
43 | + var $info_box_head = array(); |
|
44 | + var $info_box_contents = array(); |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * Constructor |
|
49 | + * |
|
50 | + * @param DoliDB $db Database handler |
|
51 | + * @param string $param More parameters |
|
52 | + */ |
|
53 | + function __construct($db,$param) |
|
54 | + { |
|
55 | + global $user; |
|
56 | + |
|
57 | + $this->db=$db; |
|
58 | + |
|
59 | + $this->hidden=! ($user->rights->commande->lire); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Load data for box to show them later |
|
64 | + * |
|
65 | + * @param int $max Maximum number of records to load |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + function loadBox($max=5) |
|
69 | + { |
|
70 | + global $user, $langs, $db, $conf; |
|
71 | + |
|
72 | + $this->max = $max; |
|
73 | + |
|
74 | + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
|
75 | + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
76 | + |
|
77 | + $commandestatic = new Commande($db); |
|
78 | + $societestatic = new Societe($db); |
|
79 | + $userstatic = new User($db); |
|
80 | + |
|
81 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerOrders",$max)); |
|
82 | + |
|
83 | + if ($user->rights->commande->lire) |
|
84 | + { |
|
85 | + $sql = "SELECT s.nom as name"; |
|
86 | + $sql.= ", s.rowid as socid"; |
|
87 | + $sql.= ", s.code_client"; |
|
88 | + $sql.= ", s.logo"; |
|
89 | + $sql.= ", c.ref, c.tms"; |
|
90 | + $sql.= ", c.rowid"; |
|
91 | + $sql.= ", c.date_commande"; |
|
92 | + $sql.= ", c.ref_client"; |
|
93 | + $sql.= ", c.fk_statut"; |
|
94 | + $sql.= ", c.fk_user_valid"; |
|
95 | + $sql.= ", c.facture"; |
|
96 | + $sql.= ", c.total_ht"; |
|
97 | + $sql.= ", c.tva as total_tva"; |
|
98 | + $sql.= ", c.total_ttc"; |
|
99 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
100 | + $sql.= ", ".MAIN_DB_PREFIX."commande as c"; |
|
101 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | + $sql.= " WHERE c.fk_soc = s.rowid"; |
|
103 | + $sql.= " AND c.entity = ".$conf->entity; |
|
104 | + if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; |
|
105 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
106 | + if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
107 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
108 | + else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
109 | + $sql.= $db->plimit($max, 0); |
|
110 | + |
|
111 | + $result = $db->query($sql); |
|
112 | + if ($result) { |
|
113 | + $num = $db->num_rows($result); |
|
114 | + |
|
115 | + $line = 0; |
|
116 | + |
|
117 | + while ($line < $num) { |
|
118 | + $objp = $db->fetch_object($result); |
|
119 | + $date=$db->jdate($objp->date_commande); |
|
120 | + $datem=$db->jdate($objp->tms); |
|
121 | + $commandestatic->id = $objp->rowid; |
|
122 | + $commandestatic->ref = $objp->ref; |
|
123 | + $commandestatic->ref_client = $objp->ref_client; |
|
124 | + $commandestatic->total_ht = $objp->total_ht; |
|
125 | + $commandestatic->total_tva = $objp->total_tva; |
|
126 | + $commandestatic->total_ttc = $objp->total_ttc; |
|
127 | + $societestatic->id = $objp->socid; |
|
128 | + $societestatic->name = $objp->name; |
|
129 | + $societestatic->code_client = $objp->code_client; |
|
130 | + $societestatic->logo = $objp->logo; |
|
131 | + |
|
132 | + $this->info_box_contents[$line][] = array( |
|
133 | + 'td' => '', |
|
134 | + 'text' => $commandestatic->getNomUrl(1), |
|
135 | + 'asis' => 1, |
|
136 | + ); |
|
137 | + |
|
138 | + $this->info_box_contents[$line][] = array( |
|
139 | + 'td' => 'class="tdoverflowmax100"', |
|
140 | + 'text' => $societestatic->getNomUrl(1), |
|
141 | + 'asis' => 1, |
|
142 | + ); |
|
143 | + |
|
144 | + $this->info_box_contents[$line][] = array( |
|
145 | + 'td' => 'class="right"', |
|
146 | + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
|
147 | + ); |
|
148 | + |
|
149 | + if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { |
|
150 | + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); |
|
151 | + $this->info_box_contents[$line][] = array( |
|
152 | + 'td' => 'class="right"', |
|
153 | + 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), |
|
154 | + 'asis' => 1, |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + $this->info_box_contents[$line][] = array( |
|
159 | + 'td' => 'class="right"', |
|
160 | + 'text' => dol_print_date($date,'day'), |
|
161 | + ); |
|
162 | + |
|
163 | + $this->info_box_contents[$line][] = array( |
|
164 | + 'td' => 'align="right" width="18"', |
|
165 | + 'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3), |
|
166 | + ); |
|
167 | + |
|
168 | + $line++; |
|
169 | + } |
|
170 | + |
|
171 | + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedOrders")); |
|
172 | + |
|
173 | + $db->free($result); |
|
174 | + } else { |
|
175 | + $this->info_box_contents[0][0] = array( |
|
176 | + 'td' => '', |
|
177 | + 'maxlength'=>500, |
|
178 | + 'text' => ($db->error().' sql='.$sql), |
|
179 | + ); |
|
180 | + } |
|
181 | + } else { |
|
182 | + $this->info_box_contents[0][0] = array( |
|
183 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
184 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
185 | + ); |
|
186 | + } |
|
187 | + } |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Method to show box |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | * @param int $nooutput No print, only return string |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
198 | - { |
|
199 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
200 | - } |
|
197 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
198 | + { |
|
199 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
200 | + } |
|
201 | 201 | |
202 | 202 | } |
203 | 203 |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class box_commandes extends ModeleBoxes |
34 | 34 | { |
35 | - var $boxcode="lastcustomerorders"; |
|
36 | - var $boximg="object_order"; |
|
37 | - var $boxlabel="BoxLastCustomerOrders"; |
|
35 | + var $boxcode = "lastcustomerorders"; |
|
36 | + var $boximg = "object_order"; |
|
37 | + var $boxlabel = "BoxLastCustomerOrders"; |
|
38 | 38 | var $depends = array("commande"); |
39 | 39 | |
40 | 40 | var $db; |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | * @param DoliDB $db Database handler |
51 | 51 | * @param string $param More parameters |
52 | 52 | */ |
53 | - function __construct($db,$param) |
|
53 | + function __construct($db, $param) |
|
54 | 54 | { |
55 | 55 | global $user; |
56 | 56 | |
57 | - $this->db=$db; |
|
57 | + $this->db = $db; |
|
58 | 58 | |
59 | - $this->hidden=! ($user->rights->commande->lire); |
|
59 | + $this->hidden = !($user->rights->commande->lire); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param int $max Maximum number of records to load |
66 | 66 | * @return void |
67 | 67 | */ |
68 | - function loadBox($max=5) |
|
68 | + function loadBox($max = 5) |
|
69 | 69 | { |
70 | 70 | global $user, $langs, $db, $conf; |
71 | 71 | |
@@ -78,35 +78,35 @@ discard block |
||
78 | 78 | $societestatic = new Societe($db); |
79 | 79 | $userstatic = new User($db); |
80 | 80 | |
81 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerOrders",$max)); |
|
81 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); |
|
82 | 82 | |
83 | 83 | if ($user->rights->commande->lire) |
84 | 84 | { |
85 | 85 | $sql = "SELECT s.nom as name"; |
86 | - $sql.= ", s.rowid as socid"; |
|
87 | - $sql.= ", s.code_client"; |
|
88 | - $sql.= ", s.logo"; |
|
89 | - $sql.= ", c.ref, c.tms"; |
|
90 | - $sql.= ", c.rowid"; |
|
91 | - $sql.= ", c.date_commande"; |
|
92 | - $sql.= ", c.ref_client"; |
|
93 | - $sql.= ", c.fk_statut"; |
|
94 | - $sql.= ", c.fk_user_valid"; |
|
95 | - $sql.= ", c.facture"; |
|
96 | - $sql.= ", c.total_ht"; |
|
97 | - $sql.= ", c.tva as total_tva"; |
|
98 | - $sql.= ", c.total_ttc"; |
|
99 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
100 | - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; |
|
101 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | - $sql.= " WHERE c.fk_soc = s.rowid"; |
|
103 | - $sql.= " AND c.entity = ".$conf->entity; |
|
104 | - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; |
|
105 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
106 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
107 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
108 | - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
109 | - $sql.= $db->plimit($max, 0); |
|
86 | + $sql .= ", s.rowid as socid"; |
|
87 | + $sql .= ", s.code_client"; |
|
88 | + $sql .= ", s.logo"; |
|
89 | + $sql .= ", c.ref, c.tms"; |
|
90 | + $sql .= ", c.rowid"; |
|
91 | + $sql .= ", c.date_commande"; |
|
92 | + $sql .= ", c.ref_client"; |
|
93 | + $sql .= ", c.fk_statut"; |
|
94 | + $sql .= ", c.fk_user_valid"; |
|
95 | + $sql .= ", c.facture"; |
|
96 | + $sql .= ", c.total_ht"; |
|
97 | + $sql .= ", c.tva as total_tva"; |
|
98 | + $sql .= ", c.total_ttc"; |
|
99 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
100 | + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; |
|
101 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | + $sql .= " WHERE c.fk_soc = s.rowid"; |
|
103 | + $sql .= " AND c.entity = ".$conf->entity; |
|
104 | + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; |
|
105 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
106 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
107 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
108 | + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; |
|
109 | + $sql .= $db->plimit($max, 0); |
|
110 | 110 | |
111 | 111 | $result = $db->query($sql); |
112 | 112 | if ($result) { |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | |
117 | 117 | while ($line < $num) { |
118 | 118 | $objp = $db->fetch_object($result); |
119 | - $date=$db->jdate($objp->date_commande); |
|
120 | - $datem=$db->jdate($objp->tms); |
|
119 | + $date = $db->jdate($objp->date_commande); |
|
120 | + $datem = $db->jdate($objp->tms); |
|
121 | 121 | $commandestatic->id = $objp->rowid; |
122 | 122 | $commandestatic->ref = $objp->ref; |
123 | 123 | $commandestatic->ref_client = $objp->ref_client; |
@@ -146,29 +146,29 @@ discard block |
||
146 | 146 | 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), |
147 | 147 | ); |
148 | 148 | |
149 | - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { |
|
149 | + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { |
|
150 | 150 | if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); |
151 | 151 | $this->info_box_contents[$line][] = array( |
152 | 152 | 'td' => 'class="right"', |
153 | - 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), |
|
153 | + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), |
|
154 | 154 | 'asis' => 1, |
155 | 155 | ); |
156 | 156 | } |
157 | 157 | |
158 | 158 | $this->info_box_contents[$line][] = array( |
159 | 159 | 'td' => 'class="right"', |
160 | - 'text' => dol_print_date($date,'day'), |
|
160 | + 'text' => dol_print_date($date, 'day'), |
|
161 | 161 | ); |
162 | 162 | |
163 | 163 | $this->info_box_contents[$line][] = array( |
164 | 164 | 'td' => 'align="right" width="18"', |
165 | - 'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3), |
|
165 | + 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), |
|
166 | 166 | ); |
167 | 167 | |
168 | 168 | $line++; |
169 | 169 | } |
170 | 170 | |
171 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedOrders")); |
|
171 | + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoRecordedOrders")); |
|
172 | 172 | |
173 | 173 | $db->free($result); |
174 | 174 | } else { |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param int $nooutput No print, only return string |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
197 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
198 | 198 | { |
199 | 199 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
200 | 200 | } |
@@ -98,14 +98,25 @@ discard block |
||
98 | 98 | $sql.= ", c.total_ttc"; |
99 | 99 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
100 | 100 | $sql.= ", ".MAIN_DB_PREFIX."commande as c"; |
101 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
101 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
102 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
103 | + } |
|
102 | 104 | $sql.= " WHERE c.fk_soc = s.rowid"; |
103 | 105 | $sql.= " AND c.entity = ".$conf->entity; |
104 | - if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql.=" AND c.fk_statut = 1"; |
|
105 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
106 | - if ($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
107 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
108 | - else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
106 | + if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) { |
|
107 | + $sql.=" AND c.fk_statut = 1"; |
|
108 | + } |
|
109 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
110 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
111 | + } |
|
112 | + if ($user->societe_id) { |
|
113 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
114 | + } |
|
115 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { |
|
116 | + $sql.= " ORDER BY c.date_commande DESC, c.ref DESC "; |
|
117 | + } else { |
|
118 | + $sql.= " ORDER BY c.tms DESC, c.ref DESC "; |
|
119 | + } |
|
109 | 120 | $sql.= $db->plimit($max, 0); |
110 | 121 | |
111 | 122 | $result = $db->query($sql); |
@@ -147,7 +158,9 @@ discard block |
||
147 | 158 | ); |
148 | 159 | |
149 | 160 | if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { |
150 | - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); |
|
161 | + if ($objp->fk_user_valid > 0) { |
|
162 | + $userstatic->fetch($objp->fk_user_valid); |
|
163 | + } |
|
151 | 164 | $this->info_box_contents[$line][] = array( |
152 | 165 | 'td' => 'class="right"', |
153 | 166 | 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), |
@@ -168,7 +181,9 @@ discard block |
||
168 | 181 | $line++; |
169 | 182 | } |
170 | 183 | |
171 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedOrders")); |
|
184 | + if ($num==0) { |
|
185 | + $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedOrders")); |
|
186 | + } |
|
172 | 187 | |
173 | 188 | $db->free($result); |
174 | 189 | } else { |
@@ -31,34 +31,34 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class box_task extends ModeleBoxes |
33 | 33 | { |
34 | - var $boxcode="projet"; |
|
35 | - var $boximg="object_projecttask"; |
|
36 | - var $boxlabel; |
|
37 | - //var $depends = array("projet"); |
|
38 | - var $db; |
|
39 | - var $param; |
|
40 | - var $enabled = 0; // Disabled because bugged. |
|
41 | - |
|
42 | - var $info_box_head = array(); |
|
43 | - var $info_box_contents = array(); |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * Constructor |
|
48 | - * |
|
49 | - * @param DoliDB $db Database handler |
|
50 | - * @param string $param More parameters |
|
51 | - */ |
|
52 | - function __construct($db,$param='') |
|
53 | - { |
|
54 | - global $user, $langs; |
|
55 | - $langs->load("boxes"); |
|
56 | - $langs->load("projects"); |
|
57 | - $this->boxlabel="Tasks"; |
|
58 | - $this->db = $db; |
|
59 | - |
|
60 | - $this->hidden = ! ($user->rights->projet->lire); |
|
61 | - } |
|
34 | + var $boxcode="projet"; |
|
35 | + var $boximg="object_projecttask"; |
|
36 | + var $boxlabel; |
|
37 | + //var $depends = array("projet"); |
|
38 | + var $db; |
|
39 | + var $param; |
|
40 | + var $enabled = 0; // Disabled because bugged. |
|
41 | + |
|
42 | + var $info_box_head = array(); |
|
43 | + var $info_box_contents = array(); |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * Constructor |
|
48 | + * |
|
49 | + * @param DoliDB $db Database handler |
|
50 | + * @param string $param More parameters |
|
51 | + */ |
|
52 | + function __construct($db,$param='') |
|
53 | + { |
|
54 | + global $user, $langs; |
|
55 | + $langs->load("boxes"); |
|
56 | + $langs->load("projects"); |
|
57 | + $this->boxlabel="Tasks"; |
|
58 | + $this->db = $db; |
|
59 | + |
|
60 | + $this->hidden = ! ($user->rights->projet->lire); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Load data for box to show them later |
@@ -98,19 +98,19 @@ discard block |
||
98 | 98 | { |
99 | 99 | $num = $db->num_rows($result); |
100 | 100 | $i = 0; |
101 | - while ($i < $num) |
|
102 | - { |
|
103 | - $objp = $db->fetch_object($result); |
|
104 | - $this->info_box_contents[$i][] = array( |
|
105 | - 'td' => '', |
|
106 | - 'text' =>$langs->trans("Task")." ".$taskstatic->LibStatut($objp->fk_statut,0), |
|
107 | - ); |
|
108 | - |
|
109 | - $this->info_box_contents[$i][] = array( |
|
110 | - 'td' => 'class="right"', |
|
111 | - 'text' => $objp->nb." ".$langs->trans("Tasks"), |
|
112 | - 'url' => DOL_URL_ROOT."/projet/tasks/list.php?leftmenu=projects&viewstatut=".$objp->fk_statut, |
|
113 | - ); |
|
101 | + while ($i < $num) |
|
102 | + { |
|
103 | + $objp = $db->fetch_object($result); |
|
104 | + $this->info_box_contents[$i][] = array( |
|
105 | + 'td' => '', |
|
106 | + 'text' =>$langs->trans("Task")." ".$taskstatic->LibStatut($objp->fk_statut,0), |
|
107 | + ); |
|
108 | + |
|
109 | + $this->info_box_contents[$i][] = array( |
|
110 | + 'td' => 'class="right"', |
|
111 | + 'text' => $objp->nb." ".$langs->trans("Tasks"), |
|
112 | + 'url' => DOL_URL_ROOT."/projet/tasks/list.php?leftmenu=projects&viewstatut=".$objp->fk_statut, |
|
113 | + ); |
|
114 | 114 | $totalnb += $objp->nb; |
115 | 115 | $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => ConvertSecondToTime($objp->plannedtot,'all',25200,5)); |
116 | 116 | $totalplannedtot += $objp->plannedtot; |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class box_task extends ModeleBoxes |
33 | 33 | { |
34 | - var $boxcode="projet"; |
|
35 | - var $boximg="object_projecttask"; |
|
34 | + var $boxcode = "projet"; |
|
35 | + var $boximg = "object_projecttask"; |
|
36 | 36 | var $boxlabel; |
37 | 37 | //var $depends = array("projet"); |
38 | 38 | var $db; |
39 | 39 | var $param; |
40 | - var $enabled = 0; // Disabled because bugged. |
|
40 | + var $enabled = 0; // Disabled because bugged. |
|
41 | 41 | |
42 | 42 | var $info_box_head = array(); |
43 | 43 | var $info_box_contents = array(); |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | * @param DoliDB $db Database handler |
50 | 50 | * @param string $param More parameters |
51 | 51 | */ |
52 | - function __construct($db,$param='') |
|
52 | + function __construct($db, $param = '') |
|
53 | 53 | { |
54 | 54 | global $user, $langs; |
55 | 55 | $langs->load("boxes"); |
56 | 56 | $langs->load("projects"); |
57 | - $this->boxlabel="Tasks"; |
|
57 | + $this->boxlabel = "Tasks"; |
|
58 | 58 | $this->db = $db; |
59 | 59 | |
60 | - $this->hidden = ! ($user->rights->projet->lire); |
|
60 | + $this->hidden = !($user->rights->projet->lire); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | * @param int $max Maximum number of records to load |
67 | 67 | * @return void |
68 | 68 | */ |
69 | - function loadBox($max=5) |
|
69 | + function loadBox($max = 5) |
|
70 | 70 | { |
71 | 71 | global $conf, $user, $langs, $db; |
72 | 72 | |
73 | - $this->max=$max; |
|
73 | + $this->max = $max; |
|
74 | 74 | |
75 | 75 | $totalMnt = 0; |
76 | 76 | $totalnb = 0; |
77 | - $totalDuree=0; |
|
77 | + $totalDuree = 0; |
|
78 | 78 | include_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php"); |
79 | - $taskstatic=new Task($db); |
|
79 | + $taskstatic = new Task($db); |
|
80 | 80 | |
81 | 81 | |
82 | 82 | $textHead = $langs->trans("Tasks")." ".date("Y"); |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | if ($user->rights->projet->lire) { |
87 | 87 | // FIXME fk_statut on a task is not be used. We use the percent. This means this box is useless. |
88 | 88 | $sql = "SELECT pt.fk_statut, count(DISTINCT pt.rowid) as nb, sum(ptt.task_duration) as durationtot, sum(pt.planned_workload) as plannedtot"; |
89 | - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt"; |
|
90 | - $sql.= " WHERE pt.datec BETWEEN '".$this->db->idate(dol_get_first_day(date("Y"), 1))."' AND '".$this->db->idate(dol_get_last_day(date("Y"), 12))."'"; |
|
91 | - $sql.= " AND pt.rowid = ptt.fk_task"; |
|
92 | - $sql.= " GROUP BY pt.fk_statut "; |
|
93 | - $sql.= " ORDER BY pt.fk_statut DESC"; |
|
94 | - $sql.= $db->plimit($max, 0); |
|
89 | + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt"; |
|
90 | + $sql .= " WHERE pt.datec BETWEEN '".$this->db->idate(dol_get_first_day(date("Y"), 1))."' AND '".$this->db->idate(dol_get_last_day(date("Y"), 12))."'"; |
|
91 | + $sql .= " AND pt.rowid = ptt.fk_task"; |
|
92 | + $sql .= " GROUP BY pt.fk_statut "; |
|
93 | + $sql .= " ORDER BY pt.fk_statut DESC"; |
|
94 | + $sql .= $db->plimit($max, 0); |
|
95 | 95 | |
96 | 96 | $result = $db->query($sql); |
97 | 97 | if ($result) |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $objp = $db->fetch_object($result); |
104 | 104 | $this->info_box_contents[$i][] = array( |
105 | 105 | 'td' => '', |
106 | - 'text' =>$langs->trans("Task")." ".$taskstatic->LibStatut($objp->fk_statut,0), |
|
106 | + 'text' =>$langs->trans("Task")." ".$taskstatic->LibStatut($objp->fk_statut, 0), |
|
107 | 107 | ); |
108 | 108 | |
109 | 109 | $this->info_box_contents[$i][] = array( |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | 'url' => DOL_URL_ROOT."/projet/tasks/list.php?leftmenu=projects&viewstatut=".$objp->fk_statut, |
113 | 113 | ); |
114 | 114 | $totalnb += $objp->nb; |
115 | - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => ConvertSecondToTime($objp->plannedtot,'all',25200,5)); |
|
115 | + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => ConvertSecondToTime($objp->plannedtot, 'all', 25200, 5)); |
|
116 | 116 | $totalplannedtot += $objp->plannedtot; |
117 | - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => ConvertSecondToTime($objp->durationtot,'all',25200,5)); |
|
117 | + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => ConvertSecondToTime($objp->durationtot, 'all', 25200, 5)); |
|
118 | 118 | $totaldurationtot += $objp->durationtot; |
119 | 119 | |
120 | - $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', 'text' => $taskstatic->LibStatut($objp->fk_statut,3)); |
|
120 | + $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', 'text' => $taskstatic->LibStatut($objp->fk_statut, 3)); |
|
121 | 121 | |
122 | 122 | $i++; |
123 | 123 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | // Add the sum à the bottom of the boxes |
130 | 130 | $this->info_box_contents[$i][] = array('tr' => 'class="liste_total"', 'td' => '', 'text' => $langs->trans("Total")." ".$textHead); |
131 | 131 | $this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' ')." ".$langs->trans("Tasks")); |
132 | - $this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totalplannedtot,'all',25200,5)); |
|
133 | - $this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totaldurationtot,'all',25200,5)); |
|
132 | + $this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totalplannedtot, 'all', 25200, 5)); |
|
133 | + $this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totaldurationtot, 'all', 25200, 5)); |
|
134 | 134 | $this->info_box_contents[$i][] = array('td' => '', 'text' => ""); |
135 | 135 | |
136 | 136 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param int $nooutput No print, only return string |
144 | 144 | * @return string |
145 | 145 | */ |
146 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
146 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
147 | 147 | { |
148 | 148 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
149 | 149 | } |
@@ -121,8 +121,9 @@ |
||
121 | 121 | |
122 | 122 | $i++; |
123 | 123 | } |
124 | + } else { |
|
125 | + dol_print_error($this->db); |
|
124 | 126 | } |
125 | - else dol_print_error($this->db); |
|
126 | 127 | } |
127 | 128 | |
128 | 129 |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | */ |
54 | 54 | function __construct($db,$param) |
55 | 55 | { |
56 | - global $user; |
|
56 | + global $user; |
|
57 | 57 | |
58 | - $this->db=$db; |
|
58 | + $this->db=$db; |
|
59 | 59 | |
60 | - $this->hidden=! ($user->rights->societe->lire); |
|
60 | + $this->hidden=! ($user->rights->societe->lire); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Load data into info_box_contents array to show array later. |
65 | 65 | * |
66 | 66 | * @param int $max Maximum number of records to load |
67 | - * @return void |
|
67 | + * @return void |
|
68 | 68 | */ |
69 | 69 | function loadBox($max=5) |
70 | 70 | { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $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"; |
81 | 81 | $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile"; |
82 | 82 | $sql.= ", s.nom as socname, s.name_alias"; |
83 | - $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; |
|
83 | + $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; |
|
84 | 84 | $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
85 | 85 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; |
86 | 86 | if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
@@ -91,87 +91,87 @@ discard block |
||
91 | 91 | $sql.= $db->plimit($max, 0); |
92 | 92 | |
93 | 93 | $result = $db->query($sql); |
94 | - if ($result) { |
|
94 | + if ($result) { |
|
95 | 95 | $num = $db->num_rows($result); |
96 | 96 | |
97 | 97 | $contactstatic=new Contact($db); |
98 | 98 | $societestatic=new Societe($db); |
99 | 99 | |
100 | 100 | $line = 0; |
101 | - while ($line < $num) |
|
102 | - { |
|
101 | + while ($line < $num) |
|
102 | + { |
|
103 | 103 | $objp = $db->fetch_object($result); |
104 | 104 | $datec=$db->jdate($objp->datec); |
105 | 105 | $datem=$db->jdate($objp->tms); |
106 | 106 | |
107 | - $contactstatic->id=$objp->id; |
|
107 | + $contactstatic->id=$objp->id; |
|
108 | 108 | $contactstatic->lastname=$objp->lastname; |
109 | - $contactstatic->firstname=$objp->firstname; |
|
110 | - $contactstatic->civility_id=$objp->civility_id; |
|
109 | + $contactstatic->firstname=$objp->firstname; |
|
110 | + $contactstatic->civility_id=$objp->civility_id; |
|
111 | 111 | $contactstatic->statut=$objp->status; |
112 | - $contactstatic->phone_pro = $objp->phone; |
|
113 | - $contactstatic->phone_perso = $objp->phone_perso; |
|
114 | - $contactstatic->phone_mobile = $objp->phone_mobile; |
|
115 | - $contactstatic->address = $objp->address; |
|
116 | - $contactstatic->zip = $objp->zip; |
|
117 | - $contactstatic->town = $objp->town; |
|
112 | + $contactstatic->phone_pro = $objp->phone; |
|
113 | + $contactstatic->phone_perso = $objp->phone_perso; |
|
114 | + $contactstatic->phone_mobile = $objp->phone_mobile; |
|
115 | + $contactstatic->address = $objp->address; |
|
116 | + $contactstatic->zip = $objp->zip; |
|
117 | + $contactstatic->town = $objp->town; |
|
118 | 118 | |
119 | 119 | $societestatic->id = $objp->fk_soc; |
120 | - $societestatic->name = $objp->socname; |
|
121 | - $societestatic->name_alias = $objp->name_alias; |
|
122 | - $societestatic->code_client = $objp->code_client; |
|
123 | - $societestatic->code_fournisseur = $objp->code_fournisseur; |
|
124 | - $societestatic->client = $objp->client; |
|
125 | - $societestatic->fournisseur = $objp->fournisseur; |
|
126 | - |
|
127 | - $this->info_box_contents[$line][] = array( |
|
128 | - 'td' => '', |
|
129 | - 'text' => $contactstatic->getNomUrl(1), |
|
130 | - 'asis' => 1, |
|
131 | - ); |
|
132 | - |
|
133 | - $this->info_box_contents[$line][] = array( |
|
134 | - 'td' => '', |
|
135 | - 'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''), |
|
136 | - 'asis' => 1, |
|
137 | - ); |
|
138 | - |
|
139 | - $this->info_box_contents[$line][] = array( |
|
140 | - 'td' => 'class="right"', |
|
141 | - 'text' => dol_print_date($datem, "day"), |
|
142 | - ); |
|
143 | - |
|
144 | - $this->info_box_contents[$line][] = array( |
|
145 | - 'td' => 'align="right" class="nowrap" width="18"', |
|
146 | - 'text' => $contactstatic->getLibStatut(3), |
|
147 | - 'asis'=>1, |
|
148 | - ); |
|
149 | - |
|
150 | - $line++; |
|
151 | - } |
|
152 | - |
|
153 | - if ($num==0) |
|
154 | - $this->info_box_contents[$line][0] = array( |
|
155 | - 'td' => 'align="center"', |
|
156 | - 'text'=>$langs->trans("NoRecordedContacts"), |
|
157 | - ); |
|
158 | - |
|
159 | - $db->free($result); |
|
160 | - } else { |
|
161 | - $this->info_box_contents[0][0] = array( |
|
162 | - 'td' => '', |
|
163 | - 'maxlength'=>500, |
|
164 | - 'text' => ($db->error().' sql='.$sql), |
|
165 | - ); |
|
166 | - } |
|
167 | - } else { |
|
168 | - $this->info_box_contents[0][0] = array( |
|
169 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
170 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
171 | - ); |
|
172 | - } |
|
173 | - |
|
174 | - } |
|
120 | + $societestatic->name = $objp->socname; |
|
121 | + $societestatic->name_alias = $objp->name_alias; |
|
122 | + $societestatic->code_client = $objp->code_client; |
|
123 | + $societestatic->code_fournisseur = $objp->code_fournisseur; |
|
124 | + $societestatic->client = $objp->client; |
|
125 | + $societestatic->fournisseur = $objp->fournisseur; |
|
126 | + |
|
127 | + $this->info_box_contents[$line][] = array( |
|
128 | + 'td' => '', |
|
129 | + 'text' => $contactstatic->getNomUrl(1), |
|
130 | + 'asis' => 1, |
|
131 | + ); |
|
132 | + |
|
133 | + $this->info_box_contents[$line][] = array( |
|
134 | + 'td' => '', |
|
135 | + 'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''), |
|
136 | + 'asis' => 1, |
|
137 | + ); |
|
138 | + |
|
139 | + $this->info_box_contents[$line][] = array( |
|
140 | + 'td' => 'class="right"', |
|
141 | + 'text' => dol_print_date($datem, "day"), |
|
142 | + ); |
|
143 | + |
|
144 | + $this->info_box_contents[$line][] = array( |
|
145 | + 'td' => 'align="right" class="nowrap" width="18"', |
|
146 | + 'text' => $contactstatic->getLibStatut(3), |
|
147 | + 'asis'=>1, |
|
148 | + ); |
|
149 | + |
|
150 | + $line++; |
|
151 | + } |
|
152 | + |
|
153 | + if ($num==0) |
|
154 | + $this->info_box_contents[$line][0] = array( |
|
155 | + 'td' => 'align="center"', |
|
156 | + 'text'=>$langs->trans("NoRecordedContacts"), |
|
157 | + ); |
|
158 | + |
|
159 | + $db->free($result); |
|
160 | + } else { |
|
161 | + $this->info_box_contents[0][0] = array( |
|
162 | + 'td' => '', |
|
163 | + 'maxlength'=>500, |
|
164 | + 'text' => ($db->error().' sql='.$sql), |
|
165 | + ); |
|
166 | + } |
|
167 | + } else { |
|
168 | + $this->info_box_contents[0][0] = array( |
|
169 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
170 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
171 | + ); |
|
172 | + } |
|
173 | + |
|
174 | + } |
|
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Method to show box |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param int $nooutput No print, only return string |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
185 | - { |
|
184 | + function showBox($head = null, $contents = null, $nooutput=0) |
|
185 | + { |
|
186 | 186 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
187 | 187 | } |
188 | 188 |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class box_contacts extends ModeleBoxes |
35 | 35 | { |
36 | - var $boxcode="lastcontacts"; |
|
37 | - var $boximg="object_contact"; |
|
38 | - var $boxlabel="BoxLastContacts"; |
|
36 | + var $boxcode = "lastcontacts"; |
|
37 | + var $boximg = "object_contact"; |
|
38 | + var $boxlabel = "BoxLastContacts"; |
|
39 | 39 | var $depends = array("societe"); |
40 | 40 | |
41 | 41 | var $db; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | * @param DoliDB $db Database handler |
52 | 52 | * @param string $param More parameters |
53 | 53 | */ |
54 | - function __construct($db,$param) |
|
54 | + function __construct($db, $param) |
|
55 | 55 | { |
56 | 56 | global $user; |
57 | 57 | |
58 | - $this->db=$db; |
|
58 | + $this->db = $db; |
|
59 | 59 | |
60 | - $this->hidden=! ($user->rights->societe->lire); |
|
60 | + $this->hidden = !($user->rights->societe->lire); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,49 +66,49 @@ discard block |
||
66 | 66 | * @param int $max Maximum number of records to load |
67 | 67 | * @return void |
68 | 68 | */ |
69 | - function loadBox($max=5) |
|
69 | + function loadBox($max = 5) |
|
70 | 70 | { |
71 | 71 | global $user, $langs, $db, $conf; |
72 | 72 | $langs->load("boxes"); |
73 | 73 | |
74 | - $this->max=$max; |
|
74 | + $this->max = $max; |
|
75 | 75 | |
76 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts",$max)); |
|
76 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max)); |
|
77 | 77 | |
78 | 78 | if ($user->rights->societe->lire) |
79 | 79 | { |
80 | 80 | $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"; |
81 | - $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile"; |
|
82 | - $sql.= ", s.nom as socname, s.name_alias"; |
|
83 | - $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; |
|
84 | - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
|
85 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; |
|
86 | - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
87 | - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; |
|
88 | - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
89 | - if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; |
|
90 | - $sql.= " ORDER BY sp.tms DESC"; |
|
91 | - $sql.= $db->plimit($max, 0); |
|
81 | + $sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile"; |
|
82 | + $sql .= ", s.nom as socname, s.name_alias"; |
|
83 | + $sql .= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; |
|
84 | + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
|
85 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; |
|
86 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
87 | + $sql .= " WHERE sp.entity IN (".getEntity('societe').")"; |
|
88 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
89 | + if ($user->societe_id) $sql .= " AND sp.fk_soc = ".$user->societe_id; |
|
90 | + $sql .= " ORDER BY sp.tms DESC"; |
|
91 | + $sql .= $db->plimit($max, 0); |
|
92 | 92 | |
93 | 93 | $result = $db->query($sql); |
94 | 94 | if ($result) { |
95 | 95 | $num = $db->num_rows($result); |
96 | 96 | |
97 | - $contactstatic=new Contact($db); |
|
98 | - $societestatic=new Societe($db); |
|
97 | + $contactstatic = new Contact($db); |
|
98 | + $societestatic = new Societe($db); |
|
99 | 99 | |
100 | 100 | $line = 0; |
101 | 101 | while ($line < $num) |
102 | 102 | { |
103 | 103 | $objp = $db->fetch_object($result); |
104 | - $datec=$db->jdate($objp->datec); |
|
105 | - $datem=$db->jdate($objp->tms); |
|
106 | - |
|
107 | - $contactstatic->id=$objp->id; |
|
108 | - $contactstatic->lastname=$objp->lastname; |
|
109 | - $contactstatic->firstname=$objp->firstname; |
|
110 | - $contactstatic->civility_id=$objp->civility_id; |
|
111 | - $contactstatic->statut=$objp->status; |
|
104 | + $datec = $db->jdate($objp->datec); |
|
105 | + $datem = $db->jdate($objp->tms); |
|
106 | + |
|
107 | + $contactstatic->id = $objp->id; |
|
108 | + $contactstatic->lastname = $objp->lastname; |
|
109 | + $contactstatic->firstname = $objp->firstname; |
|
110 | + $contactstatic->civility_id = $objp->civility_id; |
|
111 | + $contactstatic->statut = $objp->status; |
|
112 | 112 | $contactstatic->phone_pro = $objp->phone; |
113 | 113 | $contactstatic->phone_perso = $objp->phone_perso; |
114 | 114 | $contactstatic->phone_mobile = $objp->phone_mobile; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $line++; |
151 | 151 | } |
152 | 152 | |
153 | - if ($num==0) |
|
153 | + if ($num == 0) |
|
154 | 154 | $this->info_box_contents[$line][0] = array( |
155 | 155 | 'td' => 'align="center"', |
156 | 156 | 'text'=>$langs->trans("NoRecordedContacts"), |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param int $nooutput No print, only return string |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
184 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
185 | 185 | { |
186 | 186 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
187 | 187 | } |
@@ -83,10 +83,16 @@ discard block |
||
83 | 83 | $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; |
84 | 84 | $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
85 | 85 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; |
86 | - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
86 | + if (! $user->rights->societe->client->voir && ! $user->societe_id) { |
|
87 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
88 | + } |
|
87 | 89 | $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; |
88 | - if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
89 | - if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; |
|
90 | + if (! $user->rights->societe->client->voir && ! $user->societe_id) { |
|
91 | + $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
92 | + } |
|
93 | + if ($user->societe_id) { |
|
94 | + $sql.= " AND sp.fk_soc = ".$user->societe_id; |
|
95 | + } |
|
90 | 96 | $sql.= " ORDER BY sp.tms DESC"; |
91 | 97 | $sql.= $db->plimit($max, 0); |
92 | 98 | |
@@ -150,11 +156,12 @@ discard block |
||
150 | 156 | $line++; |
151 | 157 | } |
152 | 158 | |
153 | - if ($num==0) |
|
154 | - $this->info_box_contents[$line][0] = array( |
|
159 | + if ($num==0) { |
|
160 | + $this->info_box_contents[$line][0] = array( |
|
155 | 161 | 'td' => 'align="center"', |
156 | 162 | 'text'=>$langs->trans("NoRecordedContacts"), |
157 | 163 | ); |
164 | + } |
|
158 | 165 | |
159 | 166 | $db->free($result); |
160 | 167 | } else { |