@@ -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 |
@@ -30,50 +30,50 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 32 | 32 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 33 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 33 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
| 35 | 35 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
| 36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
| 37 | 37 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 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 | -if (! empty($conf->projet->enabled)) { |
|
| 41 | - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 40 | +if (!empty($conf->projet->enabled)) { |
|
| 41 | + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Load translation files required by the page |
| 45 | 45 | $langs->loadLangs(array('propal', 'compta', 'other', 'bills', 'companies')); |
| 46 | 46 | |
| 47 | 47 | |
| 48 | -$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility |
|
| 49 | -$ref=GETPOST('ref','alpha'); |
|
| 50 | -$socid=GETPOST('socid','int'); |
|
| 51 | -$action=GETPOST('action','alpha'); |
|
| 52 | -$confirm=GETPOST('confirm', 'alpha'); |
|
| 48 | +$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility |
|
| 49 | +$ref = GETPOST('ref', 'alpha'); |
|
| 50 | +$socid = GETPOST('socid', 'int'); |
|
| 51 | +$action = GETPOST('action', 'alpha'); |
|
| 52 | +$confirm = GETPOST('confirm', 'alpha'); |
|
| 53 | 53 | |
| 54 | 54 | // Security check |
| 55 | 55 | if ($user->societe_id) |
| 56 | 56 | { |
| 57 | 57 | $socid = $user->societe_id; |
| 58 | 58 | } |
| 59 | -$result=restrictedArea($user,'facture',$id,''); |
|
| 59 | +$result = restrictedArea($user, 'facture', $id, ''); |
|
| 60 | 60 | |
| 61 | 61 | // Get parameters |
| 62 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
| 63 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
| 64 | -$page = GETPOST("page",'int'); |
|
| 62 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
| 63 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
| 64 | +$page = GETPOST("page", 'int'); |
|
| 65 | 65 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 66 | 66 | $offset = $conf->liste_limit * $page; |
| 67 | 67 | $pageprev = $page - 1; |
| 68 | 68 | $pagenext = $page + 1; |
| 69 | -if (! $sortorder) $sortorder="ASC"; |
|
| 70 | -if (! $sortfield) $sortfield="name"; |
|
| 69 | +if (!$sortorder) $sortorder = "ASC"; |
|
| 70 | +if (!$sortfield) $sortfield = "name"; |
|
| 71 | 71 | |
| 72 | 72 | $object = new Facture($db); |
| 73 | 73 | if ($object->fetch($id)) |
| 74 | 74 | { |
| 75 | 75 | $object->fetch_thirdparty(); |
| 76 | - $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
| 76 | + $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
@@ -81,22 +81,22 @@ discard block |
||
| 81 | 81 | * Actions |
| 82 | 82 | */ |
| 83 | 83 | |
| 84 | -require_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; |
|
| 84 | +require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; |
|
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | /* |
| 88 | 88 | * View |
| 89 | 89 | */ |
| 90 | 90 | |
| 91 | -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Documents'); |
|
| 91 | +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Documents'); |
|
| 92 | 92 | $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; |
| 93 | 93 | llxHeader('', $title, $helpurl); |
| 94 | 94 | |
| 95 | 95 | $form = new Form($db); |
| 96 | 96 | |
| 97 | -if ($id > 0 || ! empty($ref)) |
|
| 97 | +if ($id > 0 || !empty($ref)) |
|
| 98 | 98 | { |
| 99 | - if ($object->fetch($id,$ref) > 0) |
|
| 99 | + if ($object->fetch($id, $ref) > 0) |
|
| 100 | 100 | { |
| 101 | 101 | $object->fetch_thirdparty(); |
| 102 | 102 | |
@@ -108,60 +108,60 @@ discard block |
||
| 108 | 108 | $totalpaye = $object->getSommePaiement(); |
| 109 | 109 | |
| 110 | 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) |
|
| 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 | 114 | { |
| 115 | - $totalsize+=$file['size']; |
|
| 115 | + $totalsize += $file['size']; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | // Invoice content |
| 120 | 120 | |
| 121 | - $linkback = '<a href="' . BASE_URI . '?controller=compta/facture&method=list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
| 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">'; |
|
| 123 | + $morehtmlref = '<div class="refidno">'; |
|
| 124 | 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); |
|
| 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 | 127 | // Thirdparty |
| 128 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
| 128 | + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); |
|
| 129 | 129 | // Project |
| 130 | - if (! empty($conf->projet->enabled)) |
|
| 130 | + if (!empty($conf->projet->enabled)) |
|
| 131 | 131 | { |
| 132 | 132 | $langs->load("projects"); |
| 133 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 133 | + $morehtmlref .= '<br>'.$langs->trans('Project').' '; |
|
| 134 | 134 | if ($user->rights->facture->creer) |
| 135 | 135 | { |
| 136 | 136 | if ($action != 'classify') |
| 137 | 137 | //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
| 138 | - $morehtmlref.=' : '; |
|
| 138 | + $morehtmlref .= ' : '; |
|
| 139 | 139 | if ($action == 'classify') { |
| 140 | 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>'; |
|
| 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 | 147 | } else { |
| 148 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 148 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | - if (! empty($object->fk_project)) { |
|
| 151 | + if (!empty($object->fk_project)) { |
|
| 152 | 152 | $proj = new Project($db); |
| 153 | 153 | $proj->fetch($object->fk_project); |
| 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>'; |
|
| 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 | 157 | } else { |
| 158 | - $morehtmlref.=''; |
|
| 158 | + $morehtmlref .= ''; |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | - $morehtmlref.='</div>'; |
|
| 162 | + $morehtmlref .= '</div>'; |
|
| 163 | 163 | |
| 164 | - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
| 164 | + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
| 165 | 165 | |
| 166 | 166 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); |
| 167 | 167 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | print '<table class="border" width="100%">'; |
| 172 | 172 | |
| 173 | 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>'; |
|
| 174 | + print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>'; |
|
| 175 | 175 | print "</table>\n"; |
| 176 | 176 | |
| 177 | 177 | print "</div>\n"; |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | $modulepart = 'facture'; |
| 182 | 182 | $permission = $user->rights->facture->creer; |
| 183 | 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'; |
|
| 184 | + $param = '&id='.$object->id; |
|
| 185 | + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 186 | 186 | } |
| 187 | 187 | else |
| 188 | 188 | { |
@@ -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>'; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 26 | 26 | |
| 27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 29 | 29 | |
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; |
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; |
@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; |
| 34 | 34 | |
| 35 | 35 | $loanid = GETPOST('loanid', 'int'); |
| 36 | -$action = GETPOST('action','aZ09'); |
|
| 36 | +$action = GETPOST('action', 'aZ09'); |
|
| 37 | 37 | |
| 38 | 38 | $object = new Loan($db); |
| 39 | 39 | $object->fetch($loanid); |
| 40 | 40 | |
| 41 | 41 | // Load translation files required by the page |
| 42 | -$langs->loadLangs(array("compta","bills","loan")); |
|
| 42 | +$langs->loadLangs(array("compta", "bills", "loan")); |
|
| 43 | 43 | |
| 44 | 44 | if ($action == 'createecheancier') { |
| 45 | 45 | |
| 46 | - $i=1; |
|
| 47 | - while($i <$object->nbterm+1){ |
|
| 46 | + $i = 1; |
|
| 47 | + while ($i < $object->nbterm + 1) { |
|
| 48 | 48 | |
| 49 | - $date = GETPOST('hi_date'.$i,'int'); |
|
| 49 | + $date = GETPOST('hi_date'.$i, 'int'); |
|
| 50 | 50 | $mens = GETPOST('mens'.$i); |
| 51 | 51 | $int = GETPOST('hi_interets'.$i); |
| 52 | 52 | $insurance = GETPOST('hi_insurance'.$i); |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | $echeance->datec = dol_now(); |
| 58 | 58 | $echeance->tms = dol_now(); |
| 59 | 59 | $echeance->datep = $date; |
| 60 | - $echeance->amount_capital = $mens-$int; |
|
| 60 | + $echeance->amount_capital = $mens - $int; |
|
| 61 | 61 | $echeance->amount_insurance = $insurance; |
| 62 | 62 | $echeance->amount_interest = $int; |
| 63 | 63 | $echeance->fk_typepayment = 3; |
| 64 | 64 | $echeance->fk_bank = 0; |
| 65 | 65 | $echeance->fk_user_creat = $user->id; |
| 66 | 66 | $echeance->fk_user_modif = $user->id; |
| 67 | - $result=$echeance->create($user); |
|
| 68 | - if ($result<0) { |
|
| 69 | - setEventMessages($echeance->error, $echeance->errors,'errors'); |
|
| 67 | + $result = $echeance->create($user); |
|
| 68 | + if ($result < 0) { |
|
| 69 | + setEventMessages($echeance->error, $echeance->errors, 'errors'); |
|
| 70 | 70 | } |
| 71 | 71 | $i++; |
| 72 | 72 | } |
@@ -74,8 +74,8 @@ discard block |
||
| 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 | 80 | $mens = GETPOST('mens'.$i); |
| 81 | 81 | $int = GETPOST('hi_interets'.$i); |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | $echeance = new LoanSchedule($db); |
| 86 | 86 | $echeance->fetch($id); |
| 87 | 87 | $echeance->tms = dol_now(); |
| 88 | - $echeance->amount_capital = $mens-$int; |
|
| 88 | + $echeance->amount_capital = $mens - $int; |
|
| 89 | 89 | $echeance->amount_insurance = $insurance; |
| 90 | 90 | $echeance->amount_interest = $int; |
| 91 | 91 | $echeance->fk_user_modif = $user->id; |
| 92 | - $result= $echeance->update($user,0); |
|
| 93 | - if ($result<0) { |
|
| 94 | - setEventMessages(null, $echeance->errors,'errors'); |
|
| 92 | + $result = $echeance->update($user, 0); |
|
| 93 | + if ($result < 0) { |
|
| 94 | + setEventMessages(null, $echeance->errors, 'errors'); |
|
| 95 | 95 | } |
| 96 | 96 | $i++; |
| 97 | 97 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $echeance->fetchAll($object->id); |
| 102 | 102 | |
| 103 | 103 | top_htmlhead('', ''); |
| 104 | -$var = ! $var; |
|
| 104 | +$var = !$var; |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | 107 | ?> |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $.ajax({ |
| 118 | 118 | dataType: 'json', |
| 119 | 119 | url: 'calcmens.php', |
| 120 | - data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate/100;?> , nbterm : <?php echo $object->nbterm;?>}, |
|
| 120 | + data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate / 100; ?> , nbterm : <?php echo $object->nbterm; ?>}, |
|
| 121 | 121 | success: function(data) { |
| 122 | 122 | $.each(data, function(index, element) { |
| 123 | 123 | var idcap_res='#hi_capital'+index; |
@@ -139,19 +139,19 @@ discard block |
||
| 139 | 139 | <?php |
| 140 | 140 | |
| 141 | 141 | |
| 142 | -print '<form name="createecheancier" action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; |
|
| 143 | -print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
|
| 144 | -print '<input type="hidden" name="loanid" value="' . $loanid . '">'; |
|
| 145 | -if(count($echeance->lines)>0) |
|
| 142 | +print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
| 143 | +print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 144 | +print '<input type="hidden" name="loanid" value="'.$loanid.'">'; |
|
| 145 | +if (count($echeance->lines) > 0) |
|
| 146 | 146 | { |
| 147 | 147 | print '<input type="hidden" name="action" value="updateecheancier">'; |
| 148 | -}else{ |
|
| 148 | +} else { |
|
| 149 | 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">'; |
| 153 | 153 | $colspan = 6; |
| 154 | -if (count($echeance->lines)>0) $colspan++; |
|
| 154 | +if (count($echeance->lines) > 0) $colspan++; |
|
| 155 | 155 | print '<th align="center" colspan="'.$colspan.'">'; |
| 156 | 156 | print $langs->trans("FinancialCommitment"); |
| 157 | 157 | print '</th>'; |
@@ -167,58 +167,58 @@ discard block |
||
| 167 | 167 | print ' ('.price2num($object->capital).')'; |
| 168 | 168 | print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">'; |
| 169 | 169 | print '</th>'; |
| 170 | -if (count($echeance->lines)>0) print '<th>'.$langs->trans('DoPayment').'</th>'; |
|
| 170 | +if (count($echeance->lines) > 0) print '<th>'.$langs->trans('DoPayment').'</th>'; |
|
| 171 | 171 | print '</tr>'."\n"; |
| 172 | 172 | |
| 173 | -if ($object->nbterm > 0 && count($echeance->lines)==0) |
|
| 173 | +if ($object->nbterm > 0 && count($echeance->lines) == 0) |
|
| 174 | 174 | { |
| 175 | - $i=1; |
|
| 175 | + $i = 1; |
|
| 176 | 176 | $capital = $object->capital; |
| 177 | - $insurance = $object->insurance_amount/$object->nbterm; |
|
| 177 | + $insurance = $object->insurance_amount / $object->nbterm; |
|
| 178 | 178 | $insurance = price2num($insurance, 'MT'); |
| 179 | 179 | $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
| 180 | - while($i <$object->nbterm+1) |
|
| 180 | + while ($i < $object->nbterm + 1) |
|
| 181 | 181 | { |
| 182 | - $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); |
|
| 183 | - $int = ($capital*($object->rate/12))/100; |
|
| 182 | + $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT'); |
|
| 183 | + $int = ($capital * ($object->rate / 12)) / 100; |
|
| 184 | 184 | $int = price2num($int, 'MT'); |
| 185 | - $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
| 185 | + $cap_rest = price2num($capital - ($mens - $int), 'MT'); |
|
| 186 | 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 . '">'; |
|
| 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 | 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 . '">'; |
|
| 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 | 193 | print '</tr>'."\n"; |
| 194 | 194 | $i++; |
| 195 | 195 | $capital = $cap_rest; |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | -elseif(count($echeance->lines)>0) |
|
| 198 | +elseif (count($echeance->lines) > 0) |
|
| 199 | 199 | { |
| 200 | - $i=1; |
|
| 200 | + $i = 1; |
|
| 201 | 201 | $capital = $object->capital; |
| 202 | - $insurance = $object->insurance_amount/$object->nbterm; |
|
| 202 | + $insurance = $object->insurance_amount / $object->nbterm; |
|
| 203 | 203 | $insurance = price2num($insurance, 'MT'); |
| 204 | 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; |
|
| 205 | + foreach ($echeance->lines as $line) { |
|
| 206 | + $mens = $line->amount_capital + $line->amount_insurance + $line->amount_interest; |
|
| 207 | 207 | $int = $line->amount_interest; |
| 208 | - $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
| 208 | + $cap_rest = price2num($capital - ($mens - $int), 'MT'); |
|
| 209 | 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()){ |
|
| 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 | 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 . '">'; |
|
| 216 | + } else { |
|
| 217 | + print '<td align="center">'.price($mens).' €</td><input type="hidden" name="mens'.$i.'" id ="mens'.$i.'" value="'.$mens.'">'; |
|
| 218 | 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 . '">'; |
|
| 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>'; |
|
| 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 | + 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 | 222 | print '</tr>'."\n"; |
| 223 | 223 | $i++; |
| 224 | 224 | $capital = $cap_rest; |
@@ -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>'; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 29 | 29 | |
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; |
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; |
@@ -33,27 +33,27 @@ discard block |
||
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; |
| 34 | 34 | |
| 35 | 35 | $loanid = GETPOST('loanid', 'int'); |
| 36 | -$action = GETPOST('action','aZ09'); |
|
| 36 | +$action = GETPOST('action', 'aZ09'); |
|
| 37 | 37 | |
| 38 | 38 | $object = new Loan($db); |
| 39 | 39 | $object->fetch($loanid); |
| 40 | 40 | |
| 41 | 41 | // Load translation files required by the page |
| 42 | -$langs->loadLangs(array("compta","bills","loan")); |
|
| 42 | +$langs->loadLangs(array("compta", "bills", "loan")); |
|
| 43 | 43 | |
| 44 | -$title = $langs->trans("Loan") . ' - ' . $langs->trans("Card"); |
|
| 44 | +$title = $langs->trans("Loan").' - '.$langs->trans("Card"); |
|
| 45 | 45 | $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; |
| 46 | -llxHeader("",$title,$help_url); |
|
| 46 | +llxHeader("", $title, $help_url); |
|
| 47 | 47 | |
| 48 | -$head=loan_prepare_head($object); |
|
| 48 | +$head = loan_prepare_head($object); |
|
| 49 | 49 | dol_fiche_head($head, 'FinancialCommitment', $langs->trans("Loan"), -1, 'bill'); |
| 50 | 50 | |
| 51 | 51 | if ($action == 'createecheancier') { |
| 52 | 52 | |
| 53 | - $i=1; |
|
| 54 | - while($i <$object->nbterm+1){ |
|
| 53 | + $i = 1; |
|
| 54 | + while ($i < $object->nbterm + 1) { |
|
| 55 | 55 | |
| 56 | - $date = GETPOST('hi_date'.$i,'int'); |
|
| 56 | + $date = GETPOST('hi_date'.$i, 'int'); |
|
| 57 | 57 | $mens = GETPOST('mens'.$i); |
| 58 | 58 | $int = GETPOST('hi_interets'.$i); |
| 59 | 59 | $insurance = GETPOST('hi_insurance'.$i); |
@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | $echeance->datec = dol_now(); |
| 65 | 65 | $echeance->tms = dol_now(); |
| 66 | 66 | $echeance->datep = $date; |
| 67 | - $echeance->amount_capital = $mens-$int; |
|
| 67 | + $echeance->amount_capital = $mens - $int; |
|
| 68 | 68 | $echeance->amount_insurance = $insurance; |
| 69 | 69 | $echeance->amount_interest = $int; |
| 70 | 70 | $echeance->fk_typepayment = 3; |
| 71 | 71 | $echeance->fk_bank = 0; |
| 72 | 72 | $echeance->fk_user_creat = $user->id; |
| 73 | 73 | $echeance->fk_user_modif = $user->id; |
| 74 | - $result=$echeance->create($user); |
|
| 75 | - if ($result<0) { |
|
| 76 | - setEventMessages($echeance->error, $echeance->errors,'errors'); |
|
| 74 | + $result = $echeance->create($user); |
|
| 75 | + if ($result < 0) { |
|
| 76 | + setEventMessages($echeance->error, $echeance->errors, 'errors'); |
|
| 77 | 77 | } |
| 78 | 78 | $i++; |
| 79 | 79 | } |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | if ($action == 'updateecheancier') { |
| 83 | 83 | |
| 84 | - $i=1; |
|
| 85 | - while($i <$object->nbterm+1){ |
|
| 84 | + $i = 1; |
|
| 85 | + while ($i < $object->nbterm + 1) { |
|
| 86 | 86 | |
| 87 | 87 | $mens = GETPOST('mens'.$i); |
| 88 | 88 | $int = GETPOST('hi_interets'.$i); |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | $echeance = new LoanSchedule($db); |
| 93 | 93 | $echeance->fetch($id); |
| 94 | 94 | $echeance->tms = dol_now(); |
| 95 | - $echeance->amount_capital = $mens-$int; |
|
| 95 | + $echeance->amount_capital = $mens - $int; |
|
| 96 | 96 | $echeance->amount_insurance = $insurance; |
| 97 | 97 | $echeance->amount_interest = $int; |
| 98 | 98 | $echeance->fk_user_modif = $user->id; |
| 99 | - $result= $echeance->update($user,0); |
|
| 100 | - if ($result<0) { |
|
| 101 | - setEventMessages(null, $echeance->errors,'errors'); |
|
| 99 | + $result = $echeance->update($user, 0); |
|
| 100 | + if ($result < 0) { |
|
| 101 | + setEventMessages(null, $echeance->errors, 'errors'); |
|
| 102 | 102 | } |
| 103 | 103 | $i++; |
| 104 | 104 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $echeance = new LoanSchedule($db); |
| 108 | 108 | $echeance->fetchAll($object->id); |
| 109 | 109 | |
| 110 | -$var = ! $var; |
|
| 110 | +$var = !$var; |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | ?> |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $.ajax({ |
| 124 | 124 | dataType: 'json', |
| 125 | 125 | url: 'calcmens.php', |
| 126 | - data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate/100;?> , nbterm : <?php echo $object->nbterm;?>}, |
|
| 126 | + data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate / 100; ?> , nbterm : <?php echo $object->nbterm; ?>}, |
|
| 127 | 127 | success: function(data) { |
| 128 | 128 | $.each(data, function(index, element) { |
| 129 | 129 | var idcap_res='#hi_capital'+index; |
@@ -145,19 +145,19 @@ discard block |
||
| 145 | 145 | <?php |
| 146 | 146 | |
| 147 | 147 | |
| 148 | -print '<form name="createecheancier" action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; |
|
| 149 | -print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
|
| 150 | -print '<input type="hidden" name="loanid" value="' . $loanid . '">'; |
|
| 151 | -if(count($echeance->lines)>0) |
|
| 148 | +print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
| 149 | +print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 150 | +print '<input type="hidden" name="loanid" value="'.$loanid.'">'; |
|
| 151 | +if (count($echeance->lines) > 0) |
|
| 152 | 152 | { |
| 153 | 153 | print '<input type="hidden" name="action" value="updateecheancier">'; |
| 154 | -}else{ |
|
| 154 | +} else { |
|
| 155 | 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">'; |
| 159 | 159 | $colspan = 6; |
| 160 | -if (count($echeance->lines)>0) $colspan++; |
|
| 160 | +if (count($echeance->lines) > 0) $colspan++; |
|
| 161 | 161 | print '<th align="center" colspan="'.$colspan.'">'; |
| 162 | 162 | print $langs->trans("FinancialCommitment"); |
| 163 | 163 | print '</th>'; |
@@ -173,66 +173,66 @@ discard block |
||
| 173 | 173 | print ' ('.price2num($object->capital).')'; |
| 174 | 174 | print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">'; |
| 175 | 175 | print '</th>'; |
| 176 | -if (count($echeance->lines)>0) print '<th>'.$langs->trans('DoPayment').'</th>'; |
|
| 176 | +if (count($echeance->lines) > 0) print '<th>'.$langs->trans('DoPayment').'</th>'; |
|
| 177 | 177 | print '</tr>'."\n"; |
| 178 | 178 | |
| 179 | -if ($object->nbterm > 0 && count($echeance->lines)==0) |
|
| 179 | +if ($object->nbterm > 0 && count($echeance->lines) == 0) |
|
| 180 | 180 | { |
| 181 | - $i=1; |
|
| 181 | + $i = 1; |
|
| 182 | 182 | $capital = $object->capital; |
| 183 | - $insurance = $object->insurance_amount/$object->nbterm; |
|
| 183 | + $insurance = $object->insurance_amount / $object->nbterm; |
|
| 184 | 184 | $insurance = price2num($insurance, 'MT'); |
| 185 | 185 | $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
| 186 | - while($i <$object->nbterm+1) |
|
| 186 | + while ($i < $object->nbterm + 1) |
|
| 187 | 187 | { |
| 188 | - $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate/100, $object->nbterm-$i+1), 'MT'); |
|
| 189 | - $int = ($capital*($object->rate/12))/100; |
|
| 188 | + $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT'); |
|
| 189 | + $int = ($capital * ($object->rate / 12)) / 100; |
|
| 190 | 190 | $int = price2num($int, 'MT'); |
| 191 | - $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); |
|
| 192 | - $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
| 191 | + $insu = ($insurance + (($i == 1) ? $regulInsurance : 0)); |
|
| 192 | + $cap_rest = price2num($capital - ($mens - $int), 'MT'); |
|
| 193 | 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 . '">'; |
|
| 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 | 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 . '">'; |
|
| 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 | 200 | print '</tr>'."\n"; |
| 201 | 201 | $i++; |
| 202 | 202 | $capital = $cap_rest; |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | -elseif(count($echeance->lines)>0) |
|
| 205 | +elseif (count($echeance->lines) > 0) |
|
| 206 | 206 | { |
| 207 | - $i=1; |
|
| 207 | + $i = 1; |
|
| 208 | 208 | $capital = $object->capital; |
| 209 | - $insurance = $object->insurance_amount/$object->nbterm; |
|
| 209 | + $insurance = $object->insurance_amount / $object->nbterm; |
|
| 210 | 210 | $insurance = price2num($insurance, 'MT'); |
| 211 | 211 | $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); |
| 212 | 212 | $printed = false; |
| 213 | - foreach ($echeance->lines as $line){ |
|
| 214 | - $mens = $line->amount_capital+$line->amount_interest; |
|
| 213 | + foreach ($echeance->lines as $line) { |
|
| 214 | + $mens = $line->amount_capital + $line->amount_interest; |
|
| 215 | 215 | $int = $line->amount_interest; |
| 216 | - $insu = ($insurance+(($i == 1) ? $regulInsurance : 0)); |
|
| 217 | - $cap_rest = price2num($capital - ($mens-$int), 'MT'); |
|
| 216 | + $insu = ($insurance + (($i == 1) ? $regulInsurance : 0)); |
|
| 217 | + $cap_rest = price2num($capital - ($mens - $int), 'MT'); |
|
| 218 | 218 | |
| 219 | 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)){ |
|
| 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 | 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 . '">'; |
|
| 226 | + } else { |
|
| 227 | + print '<td align="center">'.price($mens).' €</td><input type="hidden" name="mens'.$i.'" id ="mens'.$i.'" value="'.$mens.'">'; |
|
| 228 | 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 . '">'; |
|
| 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 | 231 | print '<td align="center">'; |
| 232 | 232 | if (!empty($line->fk_bank)) print $langs->trans('Paid'); |
| 233 | 233 | elseif (!$printed) |
| 234 | 234 | { |
| 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>'; |
|
| 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 | 236 | $printed = true; |
| 237 | 237 | } |
| 238 | 238 | print '</td>'; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | print '</table>'; |
| 246 | 246 | print '</br>'; |
| 247 | 247 | print '</br>'; |
| 248 | -if (count($echeance->lines)==0) $label = $langs->trans("Create"); |
|
| 248 | +if (count($echeance->lines) == 0) $label = $langs->trans("Create"); |
|
| 249 | 249 | else $label = $langs->trans("Save"); |
| 250 | 250 | print '<div align="center"><input class="button" type="submit" value="'.$label.'"></div>'; |
| 251 | 251 | print '</form>'; |
@@ -151,13 +151,15 @@ discard block |
||
| 151 | 151 | if(count($echeance->lines)>0) |
| 152 | 152 | { |
| 153 | 153 | print '<input type="hidden" name="action" value="updateecheancier">'; |
| 154 | -}else{ |
|
| 154 | +} else{ |
|
| 155 | 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">'; |
| 159 | 159 | $colspan = 6; |
| 160 | -if (count($echeance->lines)>0) $colspan++; |
|
| 160 | +if (count($echeance->lines)>0) { |
|
| 161 | + $colspan++; |
|
| 162 | +} |
|
| 161 | 163 | print '<th align="center" colspan="'.$colspan.'">'; |
| 162 | 164 | print $langs->trans("FinancialCommitment"); |
| 163 | 165 | print '</th>'; |
@@ -173,7 +175,9 @@ discard block |
||
| 173 | 175 | print ' ('.price2num($object->capital).')'; |
| 174 | 176 | print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">'; |
| 175 | 177 | print '</th>'; |
| 176 | -if (count($echeance->lines)>0) print '<th>'.$langs->trans('DoPayment').'</th>'; |
|
| 178 | +if (count($echeance->lines)>0) { |
|
| 179 | + print '<th>'.$langs->trans('DoPayment').'</th>'; |
|
| 180 | +} |
|
| 177 | 181 | print '</tr>'."\n"; |
| 178 | 182 | |
| 179 | 183 | if ($object->nbterm > 0 && count($echeance->lines)==0) |
@@ -201,8 +205,7 @@ discard block |
||
| 201 | 205 | $i++; |
| 202 | 206 | $capital = $cap_rest; |
| 203 | 207 | } |
| 204 | -} |
|
| 205 | -elseif(count($echeance->lines)>0) |
|
| 208 | +} elseif(count($echeance->lines)>0) |
|
| 206 | 209 | { |
| 207 | 210 | $i=1; |
| 208 | 211 | $capital = $object->capital; |
@@ -223,14 +226,15 @@ discard block |
||
| 223 | 226 | 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 | 227 | if($line->datep > dol_now() && empty($line->fk_bank)){ |
| 225 | 228 | print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>'; |
| 226 | - }else{ |
|
| 229 | + } else{ |
|
| 227 | 230 | print '<td align="center">' . price($mens) . ' €</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">'; |
| 228 | 231 | } |
| 229 | 232 | |
| 230 | 233 | 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 | 234 | print '<td align="center">'; |
| 232 | - if (!empty($line->fk_bank)) print $langs->trans('Paid'); |
|
| 233 | - elseif (!$printed) |
|
| 235 | + if (!empty($line->fk_bank)) { |
|
| 236 | + print $langs->trans('Paid'); |
|
| 237 | + } elseif (!$printed) |
|
| 234 | 238 | { |
| 235 | 239 | 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 | 240 | $printed = true; |
@@ -245,8 +249,11 @@ discard block |
||
| 245 | 249 | print '</table>'; |
| 246 | 250 | print '</br>'; |
| 247 | 251 | print '</br>'; |
| 248 | -if (count($echeance->lines)==0) $label = $langs->trans("Create"); |
|
| 249 | -else $label = $langs->trans("Save"); |
|
| 252 | +if (count($echeance->lines)==0) { |
|
| 253 | + $label = $langs->trans("Create"); |
|
| 254 | +} else { |
|
| 255 | + $label = $langs->trans("Save"); |
|
| 256 | +} |
|
| 250 | 257 | print '<div align="center"><input class="button" type="submit" value="'.$label.'"></div>'; |
| 251 | 258 | print '</form>'; |
| 252 | 259 | |