@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
35 | 35 | if (! empty($conf->projet->enabled)) { |
36 | - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
36 | + include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Load translation files required by the page |
@@ -77,35 +77,35 @@ discard block |
||
77 | 77 | // Project |
78 | 78 | if (! empty($conf->projet->enabled)) |
79 | 79 | { |
80 | - $langs->load("projects"); |
|
81 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
82 | - if ($user->rights->facture->creer) |
|
83 | - { |
|
84 | - if ($action != 'classify') |
|
85 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
86 | - $morehtmlref.=' : '; |
|
87 | - if ($action == 'classify') { |
|
88 | - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
89 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
90 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
91 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
93 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
94 | - $morehtmlref.='</form>'; |
|
95 | - } else { |
|
96 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
97 | - } |
|
98 | - } else { |
|
99 | - if (! empty($object->fk_project)) { |
|
100 | - $proj = new Project($db); |
|
101 | - $proj->fetch($object->fk_project); |
|
80 | + $langs->load("projects"); |
|
81 | + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
82 | + if ($user->rights->facture->creer) |
|
83 | + { |
|
84 | + if ($action != 'classify') |
|
85 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
86 | + $morehtmlref.=' : '; |
|
87 | + if ($action == 'classify') { |
|
88 | + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
89 | + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
90 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
91 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
93 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
94 | + $morehtmlref.='</form>'; |
|
95 | + } else { |
|
96 | + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
97 | + } |
|
98 | + } else { |
|
99 | + if (! empty($object->fk_project)) { |
|
100 | + $proj = new Project($db); |
|
101 | + $proj->fetch($object->fk_project); |
|
102 | 102 | $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
103 | - $morehtmlref.=$proj->ref; |
|
104 | - $morehtmlref.='</a>'; |
|
105 | - } else { |
|
106 | - $morehtmlref.=''; |
|
107 | - } |
|
108 | - } |
|
103 | + $morehtmlref.=$proj->ref; |
|
104 | + $morehtmlref.='</a>'; |
|
105 | + } else { |
|
106 | + $morehtmlref.=''; |
|
107 | + } |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | $morehtmlref.='</div>'; |
111 | 111 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
37 | 37 | if (! empty($conf->projet->enabled)) { |
38 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
38 | + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // Load translation files required by the page |
@@ -60,60 +60,60 @@ discard block |
||
60 | 60 | |
61 | 61 | if ($action == 'addcontact' && $user->rights->facture->creer) |
62 | 62 | { |
63 | - $result = $object->fetch($id); |
|
63 | + $result = $object->fetch($id); |
|
64 | 64 | |
65 | 65 | if ($result > 0 && $id > 0) |
66 | 66 | { |
67 | - $contactid = (GETPOST('userid') ? GETPOST('userid','int') : GETPOST('contactid','int')); |
|
68 | - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); |
|
67 | + $contactid = (GETPOST('userid') ? GETPOST('userid','int') : GETPOST('contactid','int')); |
|
68 | + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); |
|
69 | 69 | } |
70 | 70 | |
71 | - if ($result >= 0) |
|
72 | - { |
|
73 | - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
74 | - exit; |
|
75 | - } |
|
76 | - else |
|
77 | - { |
|
78 | - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
|
79 | - { |
|
80 | - $langs->load("errors"); |
|
81 | - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); |
|
82 | - } |
|
83 | - else |
|
84 | - { |
|
85 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
86 | - } |
|
87 | - } |
|
71 | + if ($result >= 0) |
|
72 | + { |
|
73 | + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
74 | + exit; |
|
75 | + } |
|
76 | + else |
|
77 | + { |
|
78 | + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
|
79 | + { |
|
80 | + $langs->load("errors"); |
|
81 | + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); |
|
82 | + } |
|
83 | + else |
|
84 | + { |
|
85 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
86 | + } |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // Toggle the status of a contact |
91 | 91 | else if ($action == 'swapstatut' && $user->rights->facture->creer) |
92 | 92 | { |
93 | - if ($object->fetch($id)) |
|
94 | - { |
|
95 | - $result=$object->swapContactStatus(GETPOST('ligne')); |
|
96 | - } |
|
97 | - else |
|
98 | - { |
|
99 | - dol_print_error($db); |
|
100 | - } |
|
93 | + if ($object->fetch($id)) |
|
94 | + { |
|
95 | + $result=$object->swapContactStatus(GETPOST('ligne')); |
|
96 | + } |
|
97 | + else |
|
98 | + { |
|
99 | + dol_print_error($db); |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Deletes a contact |
104 | 104 | else if ($action == 'deletecontact' && $user->rights->facture->creer) |
105 | 105 | { |
106 | - $object->fetch($id); |
|
107 | - $result = $object->delete_contact($lineid); |
|
108 | - |
|
109 | - if ($result >= 0) |
|
110 | - { |
|
111 | - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
112 | - exit; |
|
113 | - } |
|
114 | - else { |
|
115 | - dol_print_error($db); |
|
116 | - } |
|
106 | + $object->fetch($id); |
|
107 | + $result = $object->delete_contact($lineid); |
|
108 | + |
|
109 | + if ($result >= 0) |
|
110 | + { |
|
111 | + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); |
|
112 | + exit; |
|
113 | + } |
|
114 | + else { |
|
115 | + dol_print_error($db); |
|
116 | + } |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
@@ -139,82 +139,82 @@ discard block |
||
139 | 139 | |
140 | 140 | if ($id > 0 || ! empty($ref)) |
141 | 141 | { |
142 | - if ($object->fetch($id, $ref) > 0) |
|
143 | - { |
|
144 | - $object->fetch_thirdparty(); |
|
142 | + if ($object->fetch($id, $ref) > 0) |
|
143 | + { |
|
144 | + $object->fetch_thirdparty(); |
|
145 | 145 | |
146 | - $head = facture_prepare_head($object); |
|
146 | + $head = facture_prepare_head($object); |
|
147 | 147 | |
148 | - $totalpaye = $object->getSommePaiement(); |
|
148 | + $totalpaye = $object->getSommePaiement(); |
|
149 | 149 | |
150 | - dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), -1, 'bill'); |
|
150 | + dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), -1, 'bill'); |
|
151 | 151 | |
152 | - // Invoice content |
|
152 | + // Invoice content |
|
153 | 153 | |
154 | 154 | $linkback = '<a href="' . BASE_URI . '?controller=compta/facture&method=list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
155 | 155 | |
156 | - $morehtmlref='<div class="refidno">'; |
|
157 | - // Ref customer |
|
158 | - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
159 | - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
160 | - // Thirdparty |
|
161 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
162 | - // Project |
|
163 | - if (! empty($conf->projet->enabled)) |
|
164 | - { |
|
165 | - $langs->load("projects"); |
|
166 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
167 | - if ($user->rights->facture->creer) |
|
168 | - { |
|
169 | - if ($action != 'classify') |
|
170 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
171 | - $morehtmlref.=' : '; |
|
172 | - if ($action == 'classify') { |
|
173 | - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
174 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
175 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
176 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
177 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
178 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
179 | - $morehtmlref.='</form>'; |
|
180 | - } else { |
|
181 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
182 | - } |
|
183 | - } else { |
|
184 | - if (! empty($object->fk_project)) { |
|
185 | - $proj = new Project($db); |
|
186 | - $proj->fetch($object->fk_project); |
|
156 | + $morehtmlref='<div class="refidno">'; |
|
157 | + // Ref customer |
|
158 | + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
159 | + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
160 | + // Thirdparty |
|
161 | + $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
162 | + // Project |
|
163 | + if (! empty($conf->projet->enabled)) |
|
164 | + { |
|
165 | + $langs->load("projects"); |
|
166 | + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
167 | + if ($user->rights->facture->creer) |
|
168 | + { |
|
169 | + if ($action != 'classify') |
|
170 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
171 | + $morehtmlref.=' : '; |
|
172 | + if ($action == 'classify') { |
|
173 | + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
174 | + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
175 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
176 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
177 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
178 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
179 | + $morehtmlref.='</form>'; |
|
180 | + } else { |
|
181 | + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
182 | + } |
|
183 | + } else { |
|
184 | + if (! empty($object->fk_project)) { |
|
185 | + $proj = new Project($db); |
|
186 | + $proj->fetch($object->fk_project); |
|
187 | 187 | $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
188 | - $morehtmlref.=$proj->ref; |
|
189 | - $morehtmlref.='</a>'; |
|
190 | - } else { |
|
191 | - $morehtmlref.=''; |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
195 | - $morehtmlref.='</div>'; |
|
196 | - |
|
197 | - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
198 | - |
|
199 | - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); |
|
200 | - |
|
201 | - dol_fiche_end(); |
|
202 | - |
|
203 | - print '<br>'; |
|
204 | - |
|
205 | - // Contacts lines (modules that overwrite templates must declare this into descriptor) |
|
206 | - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); |
|
207 | - foreach($dirtpls as $reldir) |
|
208 | - { |
|
209 | - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); |
|
210 | - if ($res) break; |
|
211 | - } |
|
212 | - } |
|
213 | - else |
|
214 | - { |
|
215 | - // Record not found |
|
216 | - print "ErrorRecordNotFound"; |
|
217 | - } |
|
188 | + $morehtmlref.=$proj->ref; |
|
189 | + $morehtmlref.='</a>'; |
|
190 | + } else { |
|
191 | + $morehtmlref.=''; |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | + $morehtmlref.='</div>'; |
|
196 | + |
|
197 | + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
198 | + |
|
199 | + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); |
|
200 | + |
|
201 | + dol_fiche_end(); |
|
202 | + |
|
203 | + print '<br>'; |
|
204 | + |
|
205 | + // Contacts lines (modules that overwrite templates must declare this into descriptor) |
|
206 | + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); |
|
207 | + foreach($dirtpls as $reldir) |
|
208 | + { |
|
209 | + $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); |
|
210 | + if ($res) break; |
|
211 | + } |
|
212 | + } |
|
213 | + else |
|
214 | + { |
|
215 | + // Record not found |
|
216 | + print "ErrorRecordNotFound"; |
|
217 | + } |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | // End of page |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
40 | 40 | if (! empty($conf->projet->enabled)) { |
41 | - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
41 | + include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // Load translation files required by the page |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | // Security check |
55 | 55 | if ($user->societe_id) |
56 | 56 | { |
57 | - $socid = $user->societe_id; |
|
57 | + $socid = $user->societe_id; |
|
58 | 58 | } |
59 | 59 | $result=restrictedArea($user,'facture',$id,''); |
60 | 60 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | $object = new Facture($db); |
73 | 73 | if ($object->fetch($id)) |
74 | 74 | { |
75 | - $object->fetch_thirdparty(); |
|
76 | - $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
75 | + $object->fetch_thirdparty(); |
|
76 | + $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -96,102 +96,102 @@ discard block |
||
96 | 96 | |
97 | 97 | if ($id > 0 || ! empty($ref)) |
98 | 98 | { |
99 | - if ($object->fetch($id,$ref) > 0) |
|
100 | - { |
|
101 | - $object->fetch_thirdparty(); |
|
99 | + if ($object->fetch($id,$ref) > 0) |
|
100 | + { |
|
101 | + $object->fetch_thirdparty(); |
|
102 | 102 | |
103 | - $upload_dir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($object->ref); |
|
103 | + $upload_dir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($object->ref); |
|
104 | 104 | |
105 | - $head = facture_prepare_head($object); |
|
106 | - dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); |
|
105 | + $head = facture_prepare_head($object); |
|
106 | + dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); |
|
107 | 107 | |
108 | - $totalpaye = $object->getSommePaiement(); |
|
108 | + $totalpaye = $object->getSommePaiement(); |
|
109 | 109 | |
110 | - // Build file list |
|
111 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
112 | - $totalsize=0; |
|
113 | - foreach($filearray as $key => $file) |
|
114 | - { |
|
115 | - $totalsize+=$file['size']; |
|
116 | - } |
|
110 | + // Build file list |
|
111 | + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
112 | + $totalsize=0; |
|
113 | + foreach($filearray as $key => $file) |
|
114 | + { |
|
115 | + $totalsize+=$file['size']; |
|
116 | + } |
|
117 | 117 | |
118 | 118 | |
119 | - // Invoice content |
|
119 | + // Invoice content |
|
120 | 120 | |
121 | 121 | $linkback = '<a href="' . BASE_URI . '?controller=compta/facture&method=list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
122 | 122 | |
123 | - $morehtmlref='<div class="refidno">'; |
|
124 | - // Ref customer |
|
125 | - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
126 | - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
127 | - // Thirdparty |
|
128 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
129 | - // Project |
|
130 | - if (! empty($conf->projet->enabled)) |
|
131 | - { |
|
132 | - $langs->load("projects"); |
|
133 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
134 | - if ($user->rights->facture->creer) |
|
135 | - { |
|
136 | - if ($action != 'classify') |
|
137 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
138 | - $morehtmlref.=' : '; |
|
139 | - if ($action == 'classify') { |
|
140 | - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
141 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
142 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
143 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
144 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
145 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
146 | - $morehtmlref.='</form>'; |
|
147 | - } else { |
|
148 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
149 | - } |
|
150 | - } else { |
|
151 | - if (! empty($object->fk_project)) { |
|
152 | - $proj = new Project($db); |
|
153 | - $proj->fetch($object->fk_project); |
|
123 | + $morehtmlref='<div class="refidno">'; |
|
124 | + // Ref customer |
|
125 | + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
126 | + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
127 | + // Thirdparty |
|
128 | + $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
129 | + // Project |
|
130 | + if (! empty($conf->projet->enabled)) |
|
131 | + { |
|
132 | + $langs->load("projects"); |
|
133 | + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
134 | + if ($user->rights->facture->creer) |
|
135 | + { |
|
136 | + if ($action != 'classify') |
|
137 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
138 | + $morehtmlref.=' : '; |
|
139 | + if ($action == 'classify') { |
|
140 | + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
141 | + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
142 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
143 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
144 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
145 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
146 | + $morehtmlref.='</form>'; |
|
147 | + } else { |
|
148 | + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
149 | + } |
|
150 | + } else { |
|
151 | + if (! empty($object->fk_project)) { |
|
152 | + $proj = new Project($db); |
|
153 | + $proj->fetch($object->fk_project); |
|
154 | 154 | $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
155 | - $morehtmlref.=$proj->ref; |
|
156 | - $morehtmlref.='</a>'; |
|
157 | - } else { |
|
158 | - $morehtmlref.=''; |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - $morehtmlref.='</div>'; |
|
163 | - |
|
164 | - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
165 | - |
|
166 | - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); |
|
167 | - |
|
168 | - print '<div class="fichecenter">'; |
|
169 | - print '<div class="underbanner clearboth"></div>'; |
|
170 | - |
|
171 | - print '<table class="border" width="100%">'; |
|
172 | - |
|
173 | - print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; |
|
174 | - print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>'; |
|
175 | - print "</table>\n"; |
|
176 | - |
|
177 | - print "</div>\n"; |
|
178 | - |
|
179 | - dol_fiche_end(); |
|
180 | - |
|
181 | - $modulepart = 'facture'; |
|
182 | - $permission = $user->rights->facture->creer; |
|
183 | - $permtoedit = $user->rights->facture->creer; |
|
184 | - $param = '&id=' . $object->id; |
|
185 | - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
186 | - } |
|
187 | - else |
|
188 | - { |
|
189 | - dol_print_error($db); |
|
190 | - } |
|
155 | + $morehtmlref.=$proj->ref; |
|
156 | + $morehtmlref.='</a>'; |
|
157 | + } else { |
|
158 | + $morehtmlref.=''; |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + $morehtmlref.='</div>'; |
|
163 | + |
|
164 | + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
165 | + |
|
166 | + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); |
|
167 | + |
|
168 | + print '<div class="fichecenter">'; |
|
169 | + print '<div class="underbanner clearboth"></div>'; |
|
170 | + |
|
171 | + print '<table class="border" width="100%">'; |
|
172 | + |
|
173 | + print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; |
|
174 | + print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>'; |
|
175 | + print "</table>\n"; |
|
176 | + |
|
177 | + print "</div>\n"; |
|
178 | + |
|
179 | + dol_fiche_end(); |
|
180 | + |
|
181 | + $modulepart = 'facture'; |
|
182 | + $permission = $user->rights->facture->creer; |
|
183 | + $permtoedit = $user->rights->facture->creer; |
|
184 | + $param = '&id=' . $object->id; |
|
185 | + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
186 | + } |
|
187 | + else |
|
188 | + { |
|
189 | + dol_print_error($db); |
|
190 | + } |
|
191 | 191 | } |
192 | 192 | else |
193 | 193 | { |
194 | - print $langs->trans("ErrorUnknown"); |
|
194 | + print $langs->trans("ErrorUnknown"); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | // End of page |
@@ -43,58 +43,58 @@ discard block |
||
43 | 43 | |
44 | 44 | if ($action == 'createecheancier') { |
45 | 45 | |
46 | - $i=1; |
|
47 | - while($i <$object->nbterm+1){ |
|
48 | - |
|
49 | - $date = GETPOST('hi_date'.$i,'int'); |
|
50 | - $mens = GETPOST('mens'.$i); |
|
51 | - $int = GETPOST('hi_interets'.$i); |
|
52 | - $insurance = GETPOST('hi_insurance'.$i); |
|
53 | - |
|
54 | - $echeance = new LoanSchedule($db); |
|
55 | - |
|
56 | - $echeance->fk_loan = $object->id; |
|
57 | - $echeance->datec = dol_now(); |
|
58 | - $echeance->tms = dol_now(); |
|
59 | - $echeance->datep = $date; |
|
60 | - $echeance->amount_capital = $mens-$int; |
|
61 | - $echeance->amount_insurance = $insurance; |
|
62 | - $echeance->amount_interest = $int; |
|
63 | - $echeance->fk_typepayment = 3; |
|
64 | - $echeance->fk_bank = 0; |
|
65 | - $echeance->fk_user_creat = $user->id; |
|
66 | - $echeance->fk_user_modif = $user->id; |
|
67 | - $result=$echeance->create($user); |
|
68 | - if ($result<0) { |
|
69 | - setEventMessages($echeance->error, $echeance->errors,'errors'); |
|
70 | - } |
|
71 | - $i++; |
|
72 | - } |
|
46 | + $i=1; |
|
47 | + while($i <$object->nbterm+1){ |
|
48 | + |
|
49 | + $date = GETPOST('hi_date'.$i,'int'); |
|
50 | + $mens = GETPOST('mens'.$i); |
|
51 | + $int = GETPOST('hi_interets'.$i); |
|
52 | + $insurance = GETPOST('hi_insurance'.$i); |
|
53 | + |
|
54 | + $echeance = new LoanSchedule($db); |
|
55 | + |
|
56 | + $echeance->fk_loan = $object->id; |
|
57 | + $echeance->datec = dol_now(); |
|
58 | + $echeance->tms = dol_now(); |
|
59 | + $echeance->datep = $date; |
|
60 | + $echeance->amount_capital = $mens-$int; |
|
61 | + $echeance->amount_insurance = $insurance; |
|
62 | + $echeance->amount_interest = $int; |
|
63 | + $echeance->fk_typepayment = 3; |
|
64 | + $echeance->fk_bank = 0; |
|
65 | + $echeance->fk_user_creat = $user->id; |
|
66 | + $echeance->fk_user_modif = $user->id; |
|
67 | + $result=$echeance->create($user); |
|
68 | + if ($result<0) { |
|
69 | + setEventMessages($echeance->error, $echeance->errors,'errors'); |
|
70 | + } |
|
71 | + $i++; |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if ($action == 'updateecheancier') { |
76 | 76 | |
77 | - $i=1; |
|
78 | - while($i <$object->nbterm+1){ |
|
77 | + $i=1; |
|
78 | + while($i <$object->nbterm+1){ |
|
79 | 79 | |
80 | - $mens = GETPOST('mens'.$i); |
|
81 | - $int = GETPOST('hi_interets'.$i); |
|
82 | - $id = GETPOST('hi_rowid'.$i); |
|
83 | - $insurance = GETPOST('hi_insurance'.$i); |
|
80 | + $mens = GETPOST('mens'.$i); |
|
81 | + $int = GETPOST('hi_interets'.$i); |
|
82 | + $id = GETPOST('hi_rowid'.$i); |
|
83 | + $insurance = GETPOST('hi_insurance'.$i); |
|
84 | 84 | |
85 | - $echeance = new LoanSchedule($db); |
|
86 | - $echeance->fetch($id); |
|
87 | - $echeance->tms = dol_now(); |
|
88 | - $echeance->amount_capital = $mens-$int; |
|
89 | - $echeance->amount_insurance = $insurance; |
|
90 | - $echeance->amount_interest = $int; |
|
91 | - $echeance->fk_user_modif = $user->id; |
|
92 | - $result= $echeance->update($user,0); |
|
93 | - if ($result<0) { |
|
94 | - setEventMessages(null, $echeance->errors,'errors'); |
|
95 | - } |
|
96 | - $i++; |
|
97 | - } |
|
85 | + $echeance = new LoanSchedule($db); |
|
86 | + $echeance->fetch($id); |
|
87 | + $echeance->tms = dol_now(); |
|
88 | + $echeance->amount_capital = $mens-$int; |
|
89 | + $echeance->amount_insurance = $insurance; |
|
90 | + $echeance->amount_interest = $int; |
|
91 | + $echeance->fk_user_modif = $user->id; |
|
92 | + $result= $echeance->update($user,0); |
|
93 | + if ($result<0) { |
|
94 | + setEventMessages(null, $echeance->errors,'errors'); |
|
95 | + } |
|
96 | + $i++; |
|
97 | + } |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $echeance = new LoanSchedule($db); |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | print '<input type="hidden" name="loanid" value="' . $loanid . '">'; |
145 | 145 | if(count($echeance->lines)>0) |
146 | 146 | { |
147 | - print '<input type="hidden" name="action" value="updateecheancier">'; |
|
147 | + print '<input type="hidden" name="action" value="updateecheancier">'; |
|
148 | 148 | }else{ |
149 | - print '<input type="hidden" name="action" value="createecheancier">'; |
|
149 | + print '<input type="hidden" name="action" value="createecheancier">'; |
|
150 | 150 | } |
151 | 151 | print '<table class="border" width="100%">'; |
152 | 152 | print '<tr class="liste_titre">'; |
@@ -172,57 +172,57 @@ discard block |
||
172 | 172 | |
173 | 173 | if ($object->nbterm > 0 && count($echeance->lines)==0) |
174 | 174 | { |
175 | - $i=1; |
|
176 | - $capital = $object->capital; |
|
177 | - $insurance = $object->insurance_amount/$object->nbterm; |
|
178 | - $insurance = price2num($insurance, 'MT'); |
|
179 | - $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
|
180 | - while($i <$object->nbterm+1) |
|
181 | - { |
|
182 | - $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); |
|
183 | - $int = ($capital*($object->rate/12))/100; |
|
184 | - $int = price2num($int, 'MT'); |
|
185 | - $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
186 | - print '<tr>'; |
|
187 | - print '<td align="center" id="n'.$i.'">' . $i .'</td>'; |
|
188 | - print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . '</td>'; |
|
189 | - print '<td align="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">'; |
|
190 | - print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">'; |
|
191 | - print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
|
192 | - print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">'; |
|
193 | - print '</tr>'."\n"; |
|
194 | - $i++; |
|
195 | - $capital = $cap_rest; |
|
196 | - } |
|
175 | + $i=1; |
|
176 | + $capital = $object->capital; |
|
177 | + $insurance = $object->insurance_amount/$object->nbterm; |
|
178 | + $insurance = price2num($insurance, 'MT'); |
|
179 | + $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
|
180 | + while($i <$object->nbterm+1) |
|
181 | + { |
|
182 | + $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); |
|
183 | + $int = ($capital*($object->rate/12))/100; |
|
184 | + $int = price2num($int, 'MT'); |
|
185 | + $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
186 | + print '<tr>'; |
|
187 | + print '<td align="center" id="n'.$i.'">' . $i .'</td>'; |
|
188 | + print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . '</td>'; |
|
189 | + print '<td align="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">'; |
|
190 | + print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">'; |
|
191 | + print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
|
192 | + print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">'; |
|
193 | + print '</tr>'."\n"; |
|
194 | + $i++; |
|
195 | + $capital = $cap_rest; |
|
196 | + } |
|
197 | 197 | } |
198 | 198 | elseif(count($echeance->lines)>0) |
199 | 199 | { |
200 | - $i=1; |
|
201 | - $capital = $object->capital; |
|
202 | - $insurance = $object->insurance_amount/$object->nbterm; |
|
203 | - $insurance = price2num($insurance, 'MT'); |
|
204 | - $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
|
205 | - foreach ($echeance->lines as $line){ |
|
206 | - $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; |
|
207 | - $int = $line->amount_interest; |
|
208 | - $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
209 | - print '<tr>'; |
|
210 | - print '<td align="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>'; |
|
211 | - print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep,'day') . '</td>'; |
|
212 | - print '<td align="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">'; |
|
213 | - print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">'; |
|
214 | - if($line->datep > dol_now()){ |
|
215 | - print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
|
216 | - }else{ |
|
217 | - print '<td align="center">' . price($mens) . ' €</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">'; |
|
218 | - } |
|
200 | + $i=1; |
|
201 | + $capital = $object->capital; |
|
202 | + $insurance = $object->insurance_amount/$object->nbterm; |
|
203 | + $insurance = price2num($insurance, 'MT'); |
|
204 | + $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
|
205 | + foreach ($echeance->lines as $line){ |
|
206 | + $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; |
|
207 | + $int = $line->amount_interest; |
|
208 | + $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
209 | + print '<tr>'; |
|
210 | + print '<td align="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>'; |
|
211 | + print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep,'day') . '</td>'; |
|
212 | + print '<td align="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">'; |
|
213 | + print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">'; |
|
214 | + if($line->datep > dol_now()){ |
|
215 | + print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
|
216 | + }else{ |
|
217 | + print '<td align="center">' . price($mens) . ' €</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">'; |
|
218 | + } |
|
219 | 219 | |
220 | - print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">'; |
|
220 | + print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">'; |
|
221 | 221 | print '<td align="center"><a class="butAction" href="' . BASE_URL . '?controller=loan/payment&method=payment&id=' . $object->id . '&action=create">' . $langs->trans('DoPayment') . '</a></td>'; |
222 | - print '</tr>'."\n"; |
|
223 | - $i++; |
|
224 | - $capital = $cap_rest; |
|
225 | - } |
|
222 | + print '</tr>'."\n"; |
|
223 | + $i++; |
|
224 | + $capital = $cap_rest; |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | print '</table>'; |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | print '<input type="hidden" name="loanid" value="' . $loanid . '">'; |
151 | 151 | if(count($echeance->lines)>0) |
152 | 152 | { |
153 | - print '<input type="hidden" name="action" value="updateecheancier">'; |
|
153 | + print '<input type="hidden" name="action" value="updateecheancier">'; |
|
154 | 154 | }else{ |
155 | - print '<input type="hidden" name="action" value="createecheancier">'; |
|
155 | + print '<input type="hidden" name="action" value="createecheancier">'; |
|
156 | 156 | } |
157 | 157 | print '<table class="border" width="100%">'; |
158 | 158 | print '<tr class="liste_titre">'; |
@@ -178,68 +178,68 @@ discard block |
||
178 | 178 | |
179 | 179 | if ($object->nbterm > 0 && count($echeance->lines)==0) |
180 | 180 | { |
181 | - $i=1; |
|
182 | - $capital = $object->capital; |
|
183 | - $insurance = $object->insurance_amount/$object->nbterm; |
|
184 | - $insurance = price2num($insurance, 'MT'); |
|
185 | - $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
|
186 | - while($i <$object->nbterm+1) |
|
187 | - { |
|
188 | - $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); |
|
189 | - $int = ($capital*($object->rate/12))/100; |
|
190 | - $int = price2num($int, 'MT'); |
|
191 | - $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); |
|
192 | - $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
193 | - print '<tr>'; |
|
194 | - print '<td align="center" id="n'.$i.'">' . $i .'</td>'; |
|
195 | - print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . '</td>'; |
|
196 | - print '<td align="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">'; |
|
197 | - print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">'; |
|
198 | - print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
|
199 | - print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">'; |
|
200 | - print '</tr>'."\n"; |
|
201 | - $i++; |
|
202 | - $capital = $cap_rest; |
|
203 | - } |
|
181 | + $i=1; |
|
182 | + $capital = $object->capital; |
|
183 | + $insurance = $object->insurance_amount/$object->nbterm; |
|
184 | + $insurance = price2num($insurance, 'MT'); |
|
185 | + $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
|
186 | + while($i <$object->nbterm+1) |
|
187 | + { |
|
188 | + $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); |
|
189 | + $int = ($capital*($object->rate/12))/100; |
|
190 | + $int = price2num($int, 'MT'); |
|
191 | + $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); |
|
192 | + $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
193 | + print '<tr>'; |
|
194 | + print '<td align="center" id="n'.$i.'">' . $i .'</td>'; |
|
195 | + print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . '</td>'; |
|
196 | + print '<td align="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0),0,'',1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">'; |
|
197 | + print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">'; |
|
198 | + print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
|
199 | + print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">'; |
|
200 | + print '</tr>'."\n"; |
|
201 | + $i++; |
|
202 | + $capital = $cap_rest; |
|
203 | + } |
|
204 | 204 | } |
205 | 205 | elseif(count($echeance->lines)>0) |
206 | 206 | { |
207 | - $i=1; |
|
208 | - $capital = $object->capital; |
|
209 | - $insurance = $object->insurance_amount/$object->nbterm; |
|
210 | - $insurance = price2num($insurance, 'MT'); |
|
211 | - $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
|
212 | - $printed = false; |
|
213 | - foreach ($echeance->lines as $line){ |
|
214 | - $mens = $line->amount_capital+$line->amount_interest; |
|
215 | - $int = $line->amount_interest; |
|
216 | - $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); |
|
217 | - $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
207 | + $i=1; |
|
208 | + $capital = $object->capital; |
|
209 | + $insurance = $object->insurance_amount/$object->nbterm; |
|
210 | + $insurance = price2num($insurance, 'MT'); |
|
211 | + $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
|
212 | + $printed = false; |
|
213 | + foreach ($echeance->lines as $line){ |
|
214 | + $mens = $line->amount_capital+$line->amount_interest; |
|
215 | + $int = $line->amount_interest; |
|
216 | + $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); |
|
217 | + $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
218 | 218 | |
219 | - print '<tr>'; |
|
220 | - print '<td align="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>'; |
|
221 | - print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep,'day') . '</td>'; |
|
222 | - print '<td align="center" id="insurance'.$i.'">'.price($insu,0,'',1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . $insu . '">'; |
|
223 | - print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">'; |
|
224 | - if($line->datep > dol_now() && empty($line->fk_bank)){ |
|
225 | - print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
|
226 | - }else{ |
|
227 | - print '<td align="center">' . price($mens) . ' €</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">'; |
|
228 | - } |
|
219 | + print '<tr>'; |
|
220 | + print '<td align="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>'; |
|
221 | + print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep,'day') . '</td>'; |
|
222 | + print '<td align="center" id="insurance'.$i.'">'.price($insu,0,'',1).' €</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . $insu . '">'; |
|
223 | + print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">'; |
|
224 | + if($line->datep > dol_now() && empty($line->fk_bank)){ |
|
225 | + print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
|
226 | + }else{ |
|
227 | + print '<td align="center">' . price($mens) . ' €</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">'; |
|
228 | + } |
|
229 | 229 | |
230 | - print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">'; |
|
231 | - print '<td align="center">'; |
|
232 | - if (!empty($line->fk_bank)) print $langs->trans('Paid'); |
|
233 | - elseif (!$printed) |
|
234 | - { |
|
230 | + print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">'; |
|
231 | + print '<td align="center">'; |
|
232 | + if (!empty($line->fk_bank)) print $langs->trans('Paid'); |
|
233 | + elseif (!$printed) |
|
234 | + { |
|
235 | 235 | print '<a class="butAction" href="' . BASE_URI . '?controller=loan/payment&method=payment.php&id=' . $object->id . '&action=create&line_id=' . $line->id . '">' . $langs->trans('DoPayment') . '</a>'; |
236 | - $printed = true; |
|
237 | - } |
|
238 | - print '</td>'; |
|
239 | - print '</tr>'."\n"; |
|
240 | - $i++; |
|
241 | - $capital = $cap_rest; |
|
242 | - } |
|
236 | + $printed = true; |
|
237 | + } |
|
238 | + print '</td>'; |
|
239 | + print '</tr>'."\n"; |
|
240 | + $i++; |
|
241 | + $capital = $cap_rest; |
|
242 | + } |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | print '</table>'; |