@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | // Load translation files required by the page |
35 | 35 | $langs->load("categories"); |
36 | 36 | |
37 | -if (!$user->rights->categorie->lire) accessforbidden(); |
|
37 | +if (!$user->rights->categorie->lire) { |
|
38 | + accessforbidden(); |
|
39 | +} |
|
38 | 40 | |
39 | 41 | $id = GETPOST('id', 'int'); |
40 | 42 | $type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT); |
@@ -42,7 +44,10 @@ discard block |
||
42 | 44 | $nosearch = GETPOST('nosearch', 'int'); |
43 | 45 | |
44 | 46 | $categstatic = new Categorie($db); |
45 | -if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility |
|
47 | +if (is_numeric($type)) { |
|
48 | + $type = Categorie::$MAP_ID_TO_CODE[$type]; |
|
49 | +} |
|
50 | +// For backward compatibility |
|
46 | 51 | |
47 | 52 | |
48 | 53 | /* |
@@ -54,11 +59,15 @@ discard block |
||
54 | 59 | $moreparam = ($nosearch ? '&nosearch=1' : ''); |
55 | 60 | |
56 | 61 | $typetext = $type; |
57 | -if ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans('AccountsCategoriesArea'); |
|
58 | -elseif ($type == Categorie::TYPE_WAREHOUSE) $title = $langs->trans('StocksCategoriesArea'); |
|
59 | -elseif ($type == Categorie::TYPE_ACTIONCOMM) $title = $langs->trans('ActionCommCategoriesArea'); |
|
60 | -elseif ($type == Categorie::TYPE_WEBSITE_PAGE) $title = $langs->trans('WebsitePagesCategoriesArea'); |
|
61 | -else { |
|
62 | +if ($type == Categorie::TYPE_ACCOUNT) { |
|
63 | + $title = $langs->trans('AccountsCategoriesArea'); |
|
64 | +} elseif ($type == Categorie::TYPE_WAREHOUSE) { |
|
65 | + $title = $langs->trans('StocksCategoriesArea'); |
|
66 | +} elseif ($type == Categorie::TYPE_ACTIONCOMM) { |
|
67 | + $title = $langs->trans('ActionCommCategoriesArea'); |
|
68 | +} elseif ($type == Categorie::TYPE_WEBSITE_PAGE) { |
|
69 | + $title = $langs->trans('WebsitePagesCategoriesArea'); |
|
70 | +} else { |
|
62 | 71 | $title = $langs->trans(ucfirst($type).'sCategoriesArea'); |
63 | 72 | } |
64 | 73 | |
@@ -127,7 +136,9 @@ discard block |
||
127 | 136 | print "\t</tr>\n"; |
128 | 137 | } |
129 | 138 | print "</table>"; |
130 | - } else print ' '; |
|
139 | + } else { |
|
140 | + print ' '; |
|
141 | + } |
|
131 | 142 | |
132 | 143 | print '</div></div>'; |
133 | 144 | } |
@@ -144,11 +155,19 @@ discard block |
||
144 | 155 | // Load possible missing includes |
145 | 156 | if ($conf->global->CATEGORY_SHOW_COUNTS) |
146 | 157 | { |
147 | - if ($type == Categorie::TYPE_MEMBER) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
148 | - if ($type == Categorie::TYPE_ACCOUNT) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
149 | - if ($type == Categorie::TYPE_PROJECT) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
150 | - if ($type == Categorie::TYPE_USER) require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
|
151 | -} |
|
158 | + if ($type == Categorie::TYPE_MEMBER) { |
|
159 | + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
160 | + } |
|
161 | + if ($type == Categorie::TYPE_ACCOUNT) { |
|
162 | + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
|
163 | + } |
|
164 | + if ($type == Categorie::TYPE_PROJECT) { |
|
165 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
166 | + } |
|
167 | + if ($type == Categorie::TYPE_USER) { |
|
168 | + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
|
169 | + } |
|
170 | + } |
|
152 | 171 | |
153 | 172 | // Define data (format for treeview) |
154 | 173 | $data = array(); |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | // Security check |
34 | 34 | $socid = GETPOST('socid', 'int'); |
35 | -if ($user->socid) $socid = $user->socid; |
|
35 | +if ($user->socid) { |
|
36 | + $socid = $user->socid; |
|
37 | +} |
|
36 | 38 | $result = restrictedArea($user, 'loan', '', '', ''); |
37 | 39 | |
38 | 40 | $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; |
@@ -48,8 +50,12 @@ discard block |
||
48 | 50 | $loan_static = new Loan($db); |
49 | 51 | $extrafields = new ExtraFields($db); |
50 | 52 | |
51 | -if (!$sortfield) $sortfield = "l.rowid"; |
|
52 | -if (!$sortorder) $sortorder = "DESC"; |
|
53 | +if (!$sortfield) { |
|
54 | + $sortfield = "l.rowid"; |
|
55 | +} |
|
56 | +if (!$sortorder) { |
|
57 | + $sortorder = "DESC"; |
|
58 | +} |
|
53 | 59 | |
54 | 60 | $search_ref = GETPOST('search_ref', 'int'); |
55 | 61 | $search_label = GETPOST('search_label', 'alpha'); |
@@ -68,14 +74,18 @@ discard block |
||
68 | 74 | |
69 | 75 | $parameters = array(); |
70 | 76 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
71 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
77 | +if ($reshook < 0) { |
|
78 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
79 | +} |
|
72 | 80 | |
73 | 81 | if (empty($reshook)) |
74 | 82 | { |
75 | 83 | // Purge search criteria |
76 | - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
84 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { |
|
85 | + // All tests are required to be compatible with all browsers |
|
77 | 86 | { |
78 | 87 | $search_ref = ""; |
88 | + } |
|
79 | 89 | $search_label = ""; |
80 | 90 | $search_amount = ""; |
81 | 91 | } |
@@ -97,9 +107,15 @@ discard block |
||
97 | 107 | $sql .= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; |
98 | 108 | $sql .= " ON l.rowid = pl.fk_loan"; |
99 | 109 | $sql .= " WHERE l.entity = ".$conf->entity; |
100 | -if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1); |
|
101 | -if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref); |
|
102 | -if ($search_label) $sql .= natural_search("l.label", $search_label); |
|
110 | +if ($search_amount) { |
|
111 | + $sql .= natural_search("l.capital", $search_amount, 1); |
|
112 | +} |
|
113 | +if ($search_ref) { |
|
114 | + $sql .= " AND l.rowid = ".$db->escape($search_ref); |
|
115 | +} |
|
116 | +if ($search_label) { |
|
117 | + $sql .= natural_search("l.label", $search_label); |
|
118 | +} |
|
103 | 119 | $sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend"; |
104 | 120 | $sql .= $db->order($sortfield, $sortorder); |
105 | 121 | |
@@ -109,9 +125,11 @@ discard block |
||
109 | 125 | { |
110 | 126 | $resql = $db->query($sql); |
111 | 127 | $nbtotalofrecords = $db->num_rows($resql); |
112 | - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 |
|
128 | + if (($page * $limit) > $nbtotalofrecords) { |
|
129 | + // if total of record found is smaller than page * limit, goto and load page 0 |
|
113 | 130 | { |
114 | 131 | $page = 0; |
132 | + } |
|
115 | 133 | $offset = 0; |
116 | 134 | } |
117 | 135 | } |
@@ -121,7 +139,9 @@ discard block |
||
121 | 139 | { |
122 | 140 | $num = $nbtotalofrecords; |
123 | 141 | } else { |
124 | - if ($limit) $sql .= $db->plimit($limit + 1, $offset); |
|
142 | + if ($limit) { |
|
143 | + $sql .= $db->plimit($limit + 1, $offset); |
|
144 | + } |
|
125 | 145 | |
126 | 146 | $resql = $db->query($sql); |
127 | 147 | if (!$resql) |
@@ -143,19 +163,35 @@ discard block |
||
143 | 163 | $i = 0; |
144 | 164 | |
145 | 165 | $param = ''; |
146 | - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
147 | - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); |
|
148 | - if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); |
|
149 | - if ($search_label) $param .= "&search_label=".urlencode($search_label); |
|
150 | - if ($search_amount) $param .= "&search_amount=".urlencode($search_amount); |
|
151 | - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
166 | + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
167 | + $param .= '&contextpage='.urlencode($contextpage); |
|
168 | + } |
|
169 | + if ($limit > 0 && $limit != $conf->liste_limit) { |
|
170 | + $param .= '&limit='.urlencode($limit); |
|
171 | + } |
|
172 | + if ($search_ref) { |
|
173 | + $param .= "&search_ref=".urlencode($search_ref); |
|
174 | + } |
|
175 | + if ($search_label) { |
|
176 | + $param .= "&search_label=".urlencode($search_label); |
|
177 | + } |
|
178 | + if ($search_amount) { |
|
179 | + $param .= "&search_amount=".urlencode($search_amount); |
|
180 | + } |
|
181 | + if ($optioncss != '') { |
|
182 | + $param .= '&optioncss='.urlencode($optioncss); |
|
183 | + } |
|
152 | 184 | |
153 | 185 | $url = DOL_URL_ROOT.'/loan/card.php?action=create'; |
154 | - if (!empty($socid)) $url .= '&socid='.$socid; |
|
186 | + if (!empty($socid)) { |
|
187 | + $url .= '&socid='.$socid; |
|
188 | + } |
|
155 | 189 | $newcardbutton = dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', $url, '', $user->rights->loan->write); |
156 | 190 | |
157 | 191 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
158 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
192 | + if ($optioncss != '') { |
|
193 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
194 | + } |
|
159 | 195 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
160 | 196 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
161 | 197 | print '<input type="hidden" name="action" value="list">'; |
@@ -204,7 +240,10 @@ discard block |
||
204 | 240 | while ($i < ($limit ? min($num, $limit) : $num)) |
205 | 241 | { |
206 | 242 | $obj = $db->fetch_object($resql); |
207 | - if (empty($obj)) break; // Should not happen |
|
243 | + if (empty($obj)) { |
|
244 | + break; |
|
245 | + } |
|
246 | + // Should not happen |
|
208 | 247 | |
209 | 248 | $loan_static->id = $obj->rowid; |
210 | 249 | $loan_static->ref = $obj->rowid; |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | // Security check |
31 | 31 | $socid = GETPOST('socid', 'int'); |
32 | -if ($user->socid) $socid = $user->socid; |
|
32 | +if ($user->socid) { |
|
33 | + $socid = $user->socid; |
|
34 | +} |
|
33 | 35 | $result = restrictedArea($user, 'tax', '', '', 'charges'); |
34 | 36 | $ltt = GETPOST("localTaxType", 'int'); |
35 | 37 | |
@@ -43,7 +45,9 @@ discard block |
||
43 | 45 | $localtax_static = new Localtax($db); |
44 | 46 | |
45 | 47 | $url = DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt; |
46 | -if (!empty($socid)) $url .= '&socid='.$socid; |
|
48 | +if (!empty($socid)) { |
|
49 | + $url .= '&socid='.$socid; |
|
50 | +} |
|
47 | 51 | $newcardbutton = dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); |
48 | 52 | |
49 | 53 | print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'title_accountancy'); |
@@ -25,21 +25,43 @@ |
||
25 | 25 | * \brief File for The Web App |
26 | 26 | */ |
27 | 27 | |
28 | -if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
29 | -if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
30 | -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
31 | -if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
32 | -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
33 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
34 | -if (!defined('NOLOGIN')) define('NOLOGIN', '1'); |
|
35 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
36 | -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
37 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
28 | +if (!defined('NOREQUIREUSER')) { |
|
29 | + define('NOREQUIREUSER', '1'); |
|
30 | +} |
|
31 | +if (!defined('NOREQUIREDB')) { |
|
32 | + define('NOREQUIREDB', '1'); |
|
33 | +} |
|
34 | +if (!defined('NOREQUIRESOC')) { |
|
35 | + define('NOREQUIRESOC', '1'); |
|
36 | +} |
|
37 | +if (!defined('NOREQUIRETRAN')) { |
|
38 | + define('NOREQUIRETRAN', '1'); |
|
39 | +} |
|
40 | +if (!defined('NOCSRFCHECK')) { |
|
41 | + define('NOCSRFCHECK', '1'); |
|
42 | +} |
|
43 | +if (!defined('NOTOKENRENEWAL')) { |
|
44 | + define('NOTOKENRENEWAL', '1'); |
|
45 | +} |
|
46 | +if (!defined('NOLOGIN')) { |
|
47 | + define('NOLOGIN', '1'); |
|
48 | +} |
|
49 | +if (!defined('NOREQUIREMENU')) { |
|
50 | + define('NOREQUIREMENU', '1'); |
|
51 | +} |
|
52 | +if (!defined('NOREQUIREHTML')) { |
|
53 | + define('NOREQUIREHTML', '1'); |
|
54 | +} |
|
55 | +if (!defined('NOREQUIREAJAX')) { |
|
56 | + define('NOREQUIREAJAX', '1'); |
|
57 | +} |
|
38 | 58 | |
39 | 59 | require_once __DIR__.'/../../main.inc.php'; |
40 | 60 | |
41 | 61 | $appli = constant('DOL_APPLICATION_TITLE'); |
42 | -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_APPLICATION_TITLE; |
|
62 | +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { |
|
63 | + $appli = $conf->global->MAIN_APPLICATION_TITLE; |
|
64 | +} |
|
43 | 65 | |
44 | 66 | top_httphead('text/json'); |
45 | 67 |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | // Security check |
38 | 38 | $socid = GETPOST('socid', 'int'); |
39 | 39 | $status = GETPOST('status', 'int'); |
40 | -if ($user->socid) $socid = $user->socid; |
|
40 | +if ($user->socid) { |
|
41 | + $socid = $user->socid; |
|
42 | +} |
|
41 | 43 | $result = restrictedArea($user, 'prelevement', '', '', 'bons'); |
42 | 44 | |
43 | 45 | $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search |
@@ -58,8 +60,12 @@ discard block |
||
58 | 60 | $offset = $limit * $page; |
59 | 61 | $pageprev = $page - 1; |
60 | 62 | $pagenext = $page + 1; |
61 | -if (!$sortorder) $sortorder = "DESC"; |
|
62 | -if (!$sortfield) $sortfield = "f.ref"; |
|
63 | +if (!$sortorder) { |
|
64 | + $sortorder = "DESC"; |
|
65 | +} |
|
66 | +if (!$sortfield) { |
|
67 | + $sortfield = "f.ref"; |
|
68 | +} |
|
63 | 69 | |
64 | 70 | $massactionbutton = ''; |
65 | 71 | |
@@ -72,12 +78,16 @@ discard block |
||
72 | 78 | |
73 | 79 | $parameters = array('socid' => $socid, 'limit' => $limit, 'page' => $page, 'offset' => $offset); |
74 | 80 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
75 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
81 | +if ($reshook < 0) { |
|
82 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
83 | +} |
|
76 | 84 | |
77 | 85 | // Purge search criteria |
78 | -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
86 | +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { |
|
87 | + // All tests are required to be compatible with all browsers |
|
79 | 88 | { |
80 | 89 | $search_facture = ''; |
90 | +} |
|
81 | 91 | $search_societe = ''; |
82 | 92 | $search_array_options = array(); |
83 | 93 | } |
@@ -123,14 +133,24 @@ discard block |
||
123 | 133 | } |
124 | 134 | $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
125 | 135 | $sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; |
126 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
136 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
137 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
138 | +} |
|
127 | 139 | $sql .= " WHERE s.rowid = f.fk_soc"; |
128 | 140 | $sql .= " AND f.entity IN (".getEntity('invoice').")"; |
129 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
130 | -if ($socid) $sql .= " AND f.fk_soc = ".$socid; |
|
131 | -if (!$status) $sql .= " AND pfd.traite = 0"; |
|
141 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
142 | + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
143 | +} |
|
144 | +if ($socid) { |
|
145 | + $sql .= " AND f.fk_soc = ".$socid; |
|
146 | +} |
|
147 | +if (!$status) { |
|
148 | + $sql .= " AND pfd.traite = 0"; |
|
149 | +} |
|
132 | 150 | $sql .= " AND pfd.ext_payment_id IS NULL"; |
133 | -if ($status) $sql .= " AND pfd.traite = ".$status; |
|
151 | +if ($status) { |
|
152 | + $sql .= " AND pfd.traite = ".$status; |
|
153 | +} |
|
134 | 154 | $sql .= " AND f.total_ttc > 0"; |
135 | 155 | if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) |
136 | 156 | { |
@@ -141,8 +161,12 @@ discard block |
||
141 | 161 | } else { |
142 | 162 | $sql .= " AND pfd.fk_facture_fourn = f.rowid"; |
143 | 163 | } |
144 | -if ($search_facture) $sql .= natural_search("f.ref", $search_facture); |
|
145 | -if ($search_societe) $sql .= natural_search("s.nom", $search_societe); |
|
164 | +if ($search_facture) { |
|
165 | + $sql .= natural_search("f.ref", $search_facture); |
|
166 | +} |
|
167 | +if ($search_societe) { |
|
168 | + $sql .= natural_search("s.nom", $search_societe); |
|
169 | +} |
|
146 | 170 | $sql .= $db->order($sortfield, $sortorder); |
147 | 171 | |
148 | 172 | // Count total nb of records |
@@ -151,9 +175,11 @@ discard block |
||
151 | 175 | { |
152 | 176 | $resql = $db->query($sql); |
153 | 177 | $nbtotalofrecords = $db->num_rows($resql); |
154 | - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 |
|
178 | + if (($page * $limit) > $nbtotalofrecords) { |
|
179 | + // if total of record found is smaller than page * limit, goto and load page 0 |
|
155 | 180 | { |
156 | 181 | $page = 0; |
182 | + } |
|
157 | 183 | $offset = 0; |
158 | 184 | } |
159 | 185 | } |
@@ -182,7 +208,9 @@ discard block |
||
182 | 208 | } |
183 | 209 | |
184 | 210 | print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="searchFormList" name="searchFormList">'; |
185 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
211 | +if ($optioncss != '') { |
|
212 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
213 | +} |
|
186 | 214 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
187 | 215 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
188 | 216 | print '<input type="hidden" name="action" value="list">'; |
@@ -229,7 +257,10 @@ discard block |
||
229 | 257 | while ($i < min($num, $limit)) |
230 | 258 | { |
231 | 259 | $obj = $db->fetch_object($resql); |
232 | - if (empty($obj)) break; // Should not happen |
|
260 | + if (empty($obj)) { |
|
261 | + break; |
|
262 | + } |
|
263 | + // Should not happen |
|
233 | 264 | |
234 | 265 | $invoicestatic->fetch($obj->rowid); |
235 | 266 |
@@ -27,8 +27,9 @@ discard block |
||
27 | 27 | // Load translation files required by the page |
28 | 28 | $langs->loadLangs(array('admin', 'hrm')); |
29 | 29 | |
30 | -if (!$user->admin) |
|
30 | +if (!$user->admin) { |
|
31 | 31 | accessforbidden(); |
32 | +} |
|
32 | 33 | |
33 | 34 | $error = 0; |
34 | 35 | |
@@ -52,8 +53,12 @@ discard block |
||
52 | 53 | $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; |
53 | 54 | $sortorder = GETPOST("sortorder", 'alpha'); |
54 | 55 | $sortfield = GETPOST("sortfield", 'alpha'); |
55 | -if (!$sortorder) $sortorder = "DESC"; |
|
56 | -if (!$sortfield) $sortfield = "e.rowid"; |
|
56 | +if (!$sortorder) { |
|
57 | + $sortorder = "DESC"; |
|
58 | +} |
|
59 | +if (!$sortfield) { |
|
60 | + $sortfield = "e.rowid"; |
|
61 | +} |
|
57 | 62 | |
58 | 63 | if (empty($page) || $page == -1) { |
59 | 64 | $page = 0; |
@@ -152,7 +152,9 @@ discard block |
||
152 | 152 | $this->zip = trim($this->zip); |
153 | 153 | $this->town = trim($this->town); |
154 | 154 | |
155 | - if (empty($this->ref)) $this->ref = '(PROV)'; |
|
155 | + if (empty($this->ref)) { |
|
156 | + $this->ref = '(PROV)'; |
|
157 | + } |
|
156 | 158 | |
157 | 159 | $this->db->begin(); |
158 | 160 | |
@@ -354,8 +356,12 @@ discard block |
||
354 | 356 | } |
355 | 357 | |
356 | 358 | $statusType = 'status'.$status; |
357 | - if ($status == self::STATUS_OPEN) $statusType = 'status4'; |
|
358 | - if ($status == self::STATUS_CLOSED) $statusType = 'status6'; |
|
359 | + if ($status == self::STATUS_OPEN) { |
|
360 | + $statusType = 'status4'; |
|
361 | + } |
|
362 | + if ($status == self::STATUS_CLOSED) { |
|
363 | + $statusType = 'status6'; |
|
364 | + } |
|
359 | 365 | |
360 | 366 | return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); |
361 | 367 | } |
@@ -425,9 +431,15 @@ discard block |
||
425 | 431 | $label = '<u>'.$langs->trans("Establishment").'</u>'; |
426 | 432 | $label .= '<br>'.$langs->trans("Label").': '.$this->label; |
427 | 433 | |
428 | - if ($withpicto) $result .= ($link.img_object($label, $picto).$linkend); |
|
429 | - if ($withpicto && $withpicto != 2) $result .= ' '; |
|
430 | - if ($withpicto != 2) $result .= $link.$this->label.$linkend; |
|
434 | + if ($withpicto) { |
|
435 | + $result .= ($link.img_object($label, $picto).$linkend); |
|
436 | + } |
|
437 | + if ($withpicto && $withpicto != 2) { |
|
438 | + $result .= ' '; |
|
439 | + } |
|
440 | + if ($withpicto != 2) { |
|
441 | + $result .= $link.$this->label.$linkend; |
|
442 | + } |
|
431 | 443 | return $result; |
432 | 444 | } |
433 | 445 | |
@@ -441,10 +453,14 @@ discard block |
||
441 | 453 | global $mysoc; |
442 | 454 | |
443 | 455 | // We return country code of bank account |
444 | - if (!empty($this->country_code)) return $this->country_code; |
|
456 | + if (!empty($this->country_code)) { |
|
457 | + return $this->country_code; |
|
458 | + } |
|
445 | 459 | |
446 | 460 | // We return country code of managed company |
447 | - if (!empty($mysoc->country_code)) return $mysoc->country_code; |
|
461 | + if (!empty($mysoc->country_code)) { |
|
462 | + return $mysoc->country_code; |
|
463 | + } |
|
448 | 464 | |
449 | 465 | return ''; |
450 | 466 | } |
@@ -51,13 +51,16 @@ discard block |
||
51 | 51 | $date_endday = GETPOST('date_endday'); |
52 | 52 | $date_endyear = GETPOST('date_endyear'); |
53 | 53 | $in_bookkeeping = GETPOST('in_bookkeeping'); |
54 | -if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; |
|
54 | +if ($in_bookkeeping == '') { |
|
55 | + $in_bookkeeping = 'notyet'; |
|
56 | +} |
|
55 | 57 | |
56 | 58 | $now = dol_now(); |
57 | 59 | |
58 | 60 | // Security check |
59 | -if ($user->socid > 0) |
|
61 | +if ($user->socid > 0) { |
|
60 | 62 | accessforbidden(); |
63 | +} |
|
61 | 64 | |
62 | 65 | $hookmanager->initHooks(array('purchasesjournal')); |
63 | 66 | $parameters = array(); |
@@ -88,9 +91,11 @@ discard block |
||
88 | 91 | $pastmonth = $dates['pastmonth']; |
89 | 92 | } |
90 | 93 | |
91 | -if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form |
|
94 | +if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) { |
|
95 | + // We define date_start and date_end, only if we did not submit the form |
|
92 | 96 | { |
93 | 97 | $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); |
98 | +} |
|
94 | 99 | $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); |
95 | 100 | } |
96 | 101 | |
@@ -111,8 +116,9 @@ discard block |
||
111 | 116 | } else { |
112 | 117 | $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")"; |
113 | 118 | } |
114 | -if ($date_start && $date_end) |
|
119 | +if ($date_start && $date_end) { |
|
115 | 120 | $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
121 | +} |
|
116 | 122 | // Define begin binding date |
117 | 123 | if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { |
118 | 124 | $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; |
@@ -156,9 +162,9 @@ discard block |
||
156 | 162 | |
157 | 163 | $compta_prod = $obj->compte; |
158 | 164 | if (empty($compta_prod)) { |
159 | - if ($obj->product_type == 0) |
|
160 | - $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; |
|
161 | - else { |
|
165 | + if ($obj->product_type == 0) { |
|
166 | + $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; |
|
167 | + } else { |
|
162 | 168 | $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; |
163 | 169 | } |
164 | 170 | } |
@@ -189,19 +195,31 @@ discard block |
||
189 | 195 | //$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; |
190 | 196 | |
191 | 197 | // Avoid warnings |
192 | - if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; |
|
193 | - if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; |
|
194 | - if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
195 | - if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
196 | - if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
198 | + if (!isset($tabttc[$obj->rowid][$compta_soc])) { |
|
199 | + $tabttc[$obj->rowid][$compta_soc] = 0; |
|
200 | + } |
|
201 | + if (!isset($tabht[$obj->rowid][$compta_prod])) { |
|
202 | + $tabht[$obj->rowid][$compta_prod] = 0; |
|
203 | + } |
|
204 | + if (!isset($tabtva[$obj->rowid][$compta_tva])) { |
|
205 | + $tabtva[$obj->rowid][$compta_tva] = 0; |
|
206 | + } |
|
207 | + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) { |
|
208 | + $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
209 | + } |
|
210 | + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) { |
|
211 | + $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
212 | + } |
|
197 | 213 | |
198 | 214 | $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; |
199 | 215 | $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; |
200 | 216 | $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; |
201 | - if (!empty($line->tva_npr)) // Add an entry for counterpart |
|
217 | + if (!empty($line->tva_npr)) { |
|
218 | + // Add an entry for counterpart |
|
202 | 219 | { |
203 | 220 | $tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva; |
204 | 221 | } |
222 | + } |
|
205 | 223 | $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; |
206 | 224 | $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; |
207 | 225 | $tabcompany[$obj->rowid] = array( |
@@ -233,8 +251,10 @@ discard block |
||
233 | 251 | { |
234 | 252 | $errorforinvoice[$key] = 'somelinesarenotbound'; |
235 | 253 | } |
236 | - } else dol_print_error($db); |
|
237 | -} |
|
254 | + } else { |
|
255 | + dol_print_error($db); |
|
256 | + } |
|
257 | + } |
|
238 | 258 | //var_dump($errorforinvoice);exit; |
239 | 259 | |
240 | 260 | |
@@ -278,7 +298,9 @@ discard block |
||
278 | 298 | { |
279 | 299 | $replacedinvoice = 1; |
280 | 300 | $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. |
281 | - if ($alreadydispatched) $replacedinvoice = 2; |
|
301 | + if ($alreadydispatched) { |
|
302 | + $replacedinvoice = 2; |
|
303 | + } |
|
282 | 304 | } |
283 | 305 | |
284 | 306 | // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted) |
@@ -331,9 +353,11 @@ discard block |
||
331 | 353 | |
332 | 354 | $result = $bookkeeping->create($user); |
333 | 355 | if ($result < 0) { |
334 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
356 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
357 | + // Already exists |
|
335 | 358 | { |
336 | 359 | $error++; |
360 | + } |
|
337 | 361 | $errorforline++; |
338 | 362 | $errorforinvoice[$key] = 'alreadyjournalized'; |
339 | 363 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
@@ -381,9 +405,11 @@ discard block |
||
381 | 405 | |
382 | 406 | $result = $bookkeeping->create($user); |
383 | 407 | if ($result < 0) { |
384 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
408 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
409 | + // Already exists |
|
385 | 410 | { |
386 | 411 | $error++; |
412 | + } |
|
387 | 413 | $errorforline++; |
388 | 414 | $errorforinvoice[$key] = 'alreadyjournalized'; |
389 | 415 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
@@ -406,8 +432,12 @@ discard block |
||
406 | 432 | foreach ($listoftax as $numtax) |
407 | 433 | { |
408 | 434 | $arrayofvat = $tabtva; |
409 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
410 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
435 | + if ($numtax == 1) { |
|
436 | + $arrayofvat = $tablocaltax1; |
|
437 | + } |
|
438 | + if ($numtax == 2) { |
|
439 | + $arrayofvat = $tablocaltax2; |
|
440 | + } |
|
411 | 441 | |
412 | 442 | foreach ($arrayofvat[$key] as $k => $mt) { |
413 | 443 | if ($mt) { |
@@ -442,9 +472,11 @@ discard block |
||
442 | 472 | |
443 | 473 | $result = $bookkeeping->create($user); |
444 | 474 | if ($result < 0) { |
445 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
475 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
476 | + // Already exists |
|
446 | 477 | { |
447 | 478 | $error++; |
479 | + } |
|
448 | 480 | $errorforline++; |
449 | 481 | $errorforinvoice[$key] = 'alreadyjournalized'; |
450 | 482 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
@@ -493,9 +525,11 @@ discard block |
||
493 | 525 | |
494 | 526 | $result = $bookkeeping->create($user); |
495 | 527 | if ($result < 0) { |
496 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
528 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
529 | + // Already exists |
|
497 | 530 | { |
498 | 531 | $error++; |
532 | + } |
|
499 | 533 | $errorforline++; |
500 | 534 | $errorforinvoice[$key] = 'alreadyjournalized'; |
501 | 535 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
@@ -604,7 +638,9 @@ discard block |
||
604 | 638 | { |
605 | 639 | $replacedinvoice = 1; |
606 | 640 | $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. |
607 | - if ($alreadydispatched) $replacedinvoice = 2; |
|
641 | + if ($alreadydispatched) { |
|
642 | + $replacedinvoice = 2; |
|
643 | + } |
|
608 | 644 | } |
609 | 645 | |
610 | 646 | // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted) |
@@ -657,8 +693,12 @@ discard block |
||
657 | 693 | $listoftax = array(0, 1, 2); |
658 | 694 | foreach ($listoftax as $numtax) { |
659 | 695 | $arrayofvat = $tabtva; |
660 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
661 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
696 | + if ($numtax == 1) { |
|
697 | + $arrayofvat = $tablocaltax1; |
|
698 | + } |
|
699 | + if ($numtax == 2) { |
|
700 | + $arrayofvat = $tablocaltax2; |
|
701 | + } |
|
662 | 702 | |
663 | 703 | foreach ($arrayofvat[$key] as $k => $mt) { |
664 | 704 | if ($mt) { |
@@ -733,12 +773,17 @@ discard block |
||
733 | 773 | print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); |
734 | 774 | } |
735 | 775 | print '<div class="tabsAction tabsActionNoBottom">'; |
736 | - if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
776 | + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { |
|
777 | + print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
778 | + } |
|
737 | 779 | if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { |
738 | 780 | print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
739 | 781 | } else { |
740 | - if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
741 | - else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
782 | + if ($in_bookkeeping == 'notyet') { |
|
783 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
784 | + } else { |
|
785 | + print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
786 | + } |
|
742 | 787 | } |
743 | 788 | print '</div>'; |
744 | 789 | |
@@ -806,7 +851,9 @@ discard block |
||
806 | 851 | { |
807 | 852 | $replacedinvoice = 1; |
808 | 853 | $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. |
809 | - if ($alreadydispatched) $replacedinvoice = 2; |
|
854 | + if ($alreadydispatched) { |
|
855 | + $replacedinvoice = 2; |
|
856 | + } |
|
810 | 857 | } |
811 | 858 | |
812 | 859 | // If not already into bookkeeping, we won't add it, if yes, add the counterpart ???. |
@@ -863,7 +910,9 @@ discard block |
||
863 | 910 | if (($accountoshow == "") || $accountoshow == 'NotDefined') |
864 | 911 | { |
865 | 912 | print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>'; |
866 | - } else print $accountoshow; |
|
913 | + } else { |
|
914 | + print $accountoshow; |
|
915 | + } |
|
867 | 916 | print '</td>'; |
868 | 917 | // Subledger account |
869 | 918 | print "<td>"; |
@@ -871,7 +920,9 @@ discard block |
||
871 | 920 | if (($accountoshow == "") || $accountoshow == 'NotDefined') |
872 | 921 | { |
873 | 922 | print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
874 | - } else print $accountoshow; |
|
923 | + } else { |
|
924 | + print $accountoshow; |
|
925 | + } |
|
875 | 926 | print '</td>'; |
876 | 927 | print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount")."</td>"; |
877 | 928 | print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
@@ -894,7 +945,9 @@ discard block |
||
894 | 945 | if (($accountoshow == "") || $accountoshow == 'NotDefined') |
895 | 946 | { |
896 | 947 | print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>'; |
897 | - } else print $accountoshow; |
|
948 | + } else { |
|
949 | + print $accountoshow; |
|
950 | + } |
|
898 | 951 | print "</td>"; |
899 | 952 | // Subledger account |
900 | 953 | print "<td>"; |
@@ -911,8 +964,12 @@ discard block |
||
911 | 964 | $listoftax = array(0, 1, 2); |
912 | 965 | foreach ($listoftax as $numtax) { |
913 | 966 | $arrayofvat = $tabtva; |
914 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
915 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
967 | + if ($numtax == 1) { |
|
968 | + $arrayofvat = $tablocaltax1; |
|
969 | + } |
|
970 | + if ($numtax == 2) { |
|
971 | + $arrayofvat = $tablocaltax2; |
|
972 | + } |
|
916 | 973 | |
917 | 974 | foreach ($arrayofvat[$key] as $k => $mt) { |
918 | 975 | if ($mt) { |
@@ -926,7 +983,9 @@ discard block |
||
926 | 983 | if (($accountoshow == "") || $accountoshow == 'NotDefined') |
927 | 984 | { |
928 | 985 | print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Purchase").')</span>'; |
929 | - } else print $accountoshow; |
|
986 | + } else { |
|
987 | + print $accountoshow; |
|
988 | + } |
|
930 | 989 | print "</td>"; |
931 | 990 | // Subledger account |
932 | 991 | print "<td>"; |
@@ -956,7 +1015,9 @@ discard block |
||
956 | 1015 | if ($accountoshow == '' || $accountoshow == 'NotDefined') |
957 | 1016 | { |
958 | 1017 | print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>'; |
959 | - } else print $accountoshow; |
|
1018 | + } else { |
|
1019 | + print $accountoshow; |
|
1020 | + } |
|
960 | 1021 | print '</td>'; |
961 | 1022 | // Subledger account |
962 | 1023 | print "<td>"; |
@@ -53,13 +53,16 @@ discard block |
||
53 | 53 | $date_endday = GETPOST('date_endday'); |
54 | 54 | $date_endyear = GETPOST('date_endyear'); |
55 | 55 | $in_bookkeeping = GETPOST('in_bookkeeping'); |
56 | -if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; |
|
56 | +if ($in_bookkeeping == '') { |
|
57 | + $in_bookkeeping = 'notyet'; |
|
58 | +} |
|
57 | 59 | |
58 | 60 | $now = dol_now(); |
59 | 61 | |
60 | 62 | // Security check |
61 | -if ($user->socid > 0) |
|
63 | +if ($user->socid > 0) { |
|
62 | 64 | accessforbidden(); |
65 | +} |
|
63 | 66 | |
64 | 67 | $hookmanager->initHooks(array('sellsjournal')); |
65 | 68 | $parameters = array(); |
@@ -91,9 +94,11 @@ discard block |
||
91 | 94 | $pastmonth = $dates['pastmonth']; |
92 | 95 | } |
93 | 96 | |
94 | -if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form |
|
97 | +if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) { |
|
98 | + // We define date_start and date_end, only if we did not submit the form |
|
95 | 99 | { |
96 | 100 | $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); |
101 | +} |
|
97 | 102 | $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); |
98 | 103 | } |
99 | 104 | |
@@ -115,8 +120,9 @@ discard block |
||
115 | 120 | $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; |
116 | 121 | } |
117 | 122 | $sql .= " AND fd.product_type IN (0,1)"; |
118 | -if ($date_start && $date_end) |
|
123 | +if ($date_start && $date_end) { |
|
119 | 124 | $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
125 | +} |
|
120 | 126 | // Define begin binding date |
121 | 127 | if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { |
122 | 128 | $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; |
@@ -162,9 +168,9 @@ discard block |
||
162 | 168 | |
163 | 169 | $compta_prod = $obj->compte; |
164 | 170 | if (empty($compta_prod)) { |
165 | - if ($obj->product_type == 0) |
|
166 | - $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; |
|
167 | - else { |
|
171 | + if ($obj->product_type == 0) { |
|
172 | + $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; |
|
173 | + } else { |
|
168 | 174 | $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; |
169 | 175 | } |
170 | 176 | } |
@@ -207,15 +213,28 @@ discard block |
||
207 | 213 | //$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid; |
208 | 214 | |
209 | 215 | // Avoid warnings |
210 | - if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; |
|
211 | - if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; |
|
212 | - if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; |
|
213 | - if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
214 | - if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
216 | + if (!isset($tabttc[$obj->rowid][$compta_soc])) { |
|
217 | + $tabttc[$obj->rowid][$compta_soc] = 0; |
|
218 | + } |
|
219 | + if (!isset($tabht[$obj->rowid][$compta_prod])) { |
|
220 | + $tabht[$obj->rowid][$compta_prod] = 0; |
|
221 | + } |
|
222 | + if (!isset($tabtva[$obj->rowid][$compta_tva])) { |
|
223 | + $tabtva[$obj->rowid][$compta_tva] = 0; |
|
224 | + } |
|
225 | + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) { |
|
226 | + $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; |
|
227 | + } |
|
228 | + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) { |
|
229 | + $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; |
|
230 | + } |
|
215 | 231 | |
216 | 232 | $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; |
217 | 233 | $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; |
218 | - if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR |
|
234 | + if (empty($line->tva_npr)) { |
|
235 | + $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; |
|
236 | + } |
|
237 | + // We ignore line if VAT is a NPR |
|
219 | 238 | $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio; |
220 | 239 | $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio; |
221 | 240 | $tabcompany[$obj->rowid] = array( |
@@ -247,8 +266,10 @@ discard block |
||
247 | 266 | { |
248 | 267 | $errorforinvoice[$key] = 'somelinesarenotbound'; |
249 | 268 | } |
250 | - } else dol_print_error($db); |
|
251 | -} |
|
269 | + } else { |
|
270 | + dol_print_error($db); |
|
271 | + } |
|
272 | + } |
|
252 | 273 | //var_dump($errorforinvoice);exit; |
253 | 274 | |
254 | 275 | |
@@ -289,7 +310,9 @@ discard block |
||
289 | 310 | { |
290 | 311 | $replacedinvoice = 1; |
291 | 312 | $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. |
292 | - if ($alreadydispatched) $replacedinvoice = 2; |
|
313 | + if ($alreadydispatched) { |
|
314 | + $replacedinvoice = 2; |
|
315 | + } |
|
293 | 316 | } |
294 | 317 | |
295 | 318 | // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted) |
@@ -342,9 +365,11 @@ discard block |
||
342 | 365 | |
343 | 366 | $result = $bookkeeping->create($user); |
344 | 367 | if ($result < 0) { |
345 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
368 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
369 | + // Already exists |
|
346 | 370 | { |
347 | 371 | $error++; |
372 | + } |
|
348 | 373 | $errorforline++; |
349 | 374 | $errorforinvoice[$key] = 'alreadyjournalized'; |
350 | 375 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
@@ -392,9 +417,11 @@ discard block |
||
392 | 417 | |
393 | 418 | $result = $bookkeeping->create($user); |
394 | 419 | if ($result < 0) { |
395 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
420 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
421 | + // Already exists |
|
396 | 422 | { |
397 | 423 | $error++; |
424 | + } |
|
398 | 425 | $errorforline++; |
399 | 426 | $errorforinvoice[$key] = 'alreadyjournalized'; |
400 | 427 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
@@ -416,8 +443,12 @@ discard block |
||
416 | 443 | foreach ($listoftax as $numtax) |
417 | 444 | { |
418 | 445 | $arrayofvat = $tabtva; |
419 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
420 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
446 | + if ($numtax == 1) { |
|
447 | + $arrayofvat = $tablocaltax1; |
|
448 | + } |
|
449 | + if ($numtax == 2) { |
|
450 | + $arrayofvat = $tablocaltax2; |
|
451 | + } |
|
421 | 452 | |
422 | 453 | foreach ($arrayofvat[$key] as $k => $mt) { |
423 | 454 | if ($mt) { |
@@ -452,9 +483,11 @@ discard block |
||
452 | 483 | |
453 | 484 | $result = $bookkeeping->create($user); |
454 | 485 | if ($result < 0) { |
455 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists |
|
486 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { |
|
487 | + // Already exists |
|
456 | 488 | { |
457 | 489 | $error++; |
490 | + } |
|
458 | 491 | $errorforline++; |
459 | 492 | $errorforinvoice[$key] = 'alreadyjournalized'; |
460 | 493 | //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
@@ -563,7 +596,9 @@ discard block |
||
563 | 596 | { |
564 | 597 | $replacedinvoice = 1; |
565 | 598 | $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. |
566 | - if ($alreadydispatched) $replacedinvoice = 2; |
|
599 | + if ($alreadydispatched) { |
|
600 | + $replacedinvoice = 2; |
|
601 | + } |
|
567 | 602 | } |
568 | 603 | |
569 | 604 | // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted) |
@@ -616,8 +651,12 @@ discard block |
||
616 | 651 | $listoftax = array(0, 1, 2); |
617 | 652 | foreach ($listoftax as $numtax) { |
618 | 653 | $arrayofvat = $tabtva; |
619 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
620 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
654 | + if ($numtax == 1) { |
|
655 | + $arrayofvat = $tablocaltax1; |
|
656 | + } |
|
657 | + if ($numtax == 2) { |
|
658 | + $arrayofvat = $tablocaltax2; |
|
659 | + } |
|
621 | 660 | |
622 | 661 | foreach ($arrayofvat[$key] as $k => $mt) { |
623 | 662 | if ($mt) { |
@@ -651,9 +690,9 @@ discard block |
||
651 | 690 | $exportlink = ''; |
652 | 691 | $builddate = dol_now(); |
653 | 692 | $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
654 | - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) |
|
655 | - $description .= $langs->trans("DepositsAreNotIncluded"); |
|
656 | - else { |
|
693 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
|
694 | + $description .= $langs->trans("DepositsAreNotIncluded"); |
|
695 | + } else { |
|
657 | 696 | $description .= $langs->trans("DepositsAreIncluded"); |
658 | 697 | } |
659 | 698 | |
@@ -672,12 +711,17 @@ discard block |
||
672 | 711 | print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); |
673 | 712 | } |
674 | 713 | print '<div class="tabsAction tabsActionNoBottom">'; |
675 | - if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
714 | + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { |
|
715 | + print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
716 | + } |
|
676 | 717 | if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { |
677 | 718 | print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
678 | 719 | } else { |
679 | - if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
680 | - else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
720 | + if ($in_bookkeeping == 'notyet') { |
|
721 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
722 | + } else { |
|
723 | + print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
724 | + } |
|
681 | 725 | } |
682 | 726 | print '</div>'; |
683 | 727 | |
@@ -743,7 +787,9 @@ discard block |
||
743 | 787 | { |
744 | 788 | $replacedinvoice = 1; |
745 | 789 | $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. |
746 | - if ($alreadydispatched) $replacedinvoice = 2; |
|
790 | + if ($alreadydispatched) { |
|
791 | + $replacedinvoice = 2; |
|
792 | + } |
|
747 | 793 | } |
748 | 794 | |
749 | 795 | // If not already into bookkeeping, we won't add it, if yes, add the counterpart ???. |
@@ -801,7 +847,9 @@ discard block |
||
801 | 847 | if (($accountoshow == "") || $accountoshow == 'NotDefined') |
802 | 848 | { |
803 | 849 | print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>'; |
804 | - } else print $accountoshow; |
|
850 | + } else { |
|
851 | + print $accountoshow; |
|
852 | + } |
|
805 | 853 | print '</td>'; |
806 | 854 | // Subledger account |
807 | 855 | print "<td>"; |
@@ -809,7 +857,9 @@ discard block |
||
809 | 857 | if (($accountoshow == "") || $accountoshow == 'NotDefined') |
810 | 858 | { |
811 | 859 | print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
812 | - } else print $accountoshow; |
|
860 | + } else { |
|
861 | + print $accountoshow; |
|
862 | + } |
|
813 | 863 | print '</td>'; |
814 | 864 | print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>"; |
815 | 865 | print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>"; |
@@ -833,7 +883,9 @@ discard block |
||
833 | 883 | if (($accountoshow == "") || $accountoshow == 'NotDefined') |
834 | 884 | { |
835 | 885 | print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>'; |
836 | - } else print $accountoshow; |
|
886 | + } else { |
|
887 | + print $accountoshow; |
|
888 | + } |
|
837 | 889 | print "</td>"; |
838 | 890 | // Subledger account |
839 | 891 | print "<td>"; |
@@ -851,8 +903,12 @@ discard block |
||
851 | 903 | foreach ($listoftax as $numtax) |
852 | 904 | { |
853 | 905 | $arrayofvat = $tabtva; |
854 | - if ($numtax == 1) $arrayofvat = $tablocaltax1; |
|
855 | - if ($numtax == 2) $arrayofvat = $tablocaltax2; |
|
906 | + if ($numtax == 1) { |
|
907 | + $arrayofvat = $tablocaltax1; |
|
908 | + } |
|
909 | + if ($numtax == 2) { |
|
910 | + $arrayofvat = $tablocaltax2; |
|
911 | + } |
|
856 | 912 | |
857 | 913 | foreach ($arrayofvat[$key] as $k => $mt) { |
858 | 914 | if ($mt) { |
@@ -866,7 +922,9 @@ discard block |
||
866 | 922 | if (($accountoshow == "") || $accountoshow == 'NotDefined') |
867 | 923 | { |
868 | 924 | print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')</span>'; |
869 | - } else print $accountoshow; |
|
925 | + } else { |
|
926 | + print $accountoshow; |
|
927 | + } |
|
870 | 928 | print "</td>"; |
871 | 929 | // Subledger account |
872 | 930 | print "<td>"; |