diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 10e542acf1d..c7bf362ab7d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load('bills'); $langs->load('compta'); +$langs->load('admin'); // Security check $id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int')); @@ -148,14 +149,14 @@ if ($action == 'add') $remin=GETPOST('remin'); $nb_gen_max=GETPOST('nb_gen_max', 'int'); //if (empty($nb_gen_max)) $nb_gen_max =0; - + if (GETPOST('frequency')) { - if (empty($reyear) || empty($remonth) || empty($reday)) + if (empty($reyear) || empty($remonth) || empty($reday)) { setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors'); $action = "create"; - $error++; + $error++; } if ($nb_gen_max === '') { @@ -171,14 +172,14 @@ if ($action == 'add') $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); $object->usenewprice = GETPOST('usenewprice'); - + $object->frequency = $frequency; $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); $object->nb_gen_max = $nb_gen_max; $object->auto_validate = GETPOST('auto_validate', 'int'); - + $object->fk_project = $projectid; - + $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); $object->date_when = $date_next_execution; @@ -187,9 +188,9 @@ if ($action == 'add') { $srcObject = new Facture($db); $srcObject->fetch(GETPOST('facid','int')); - + $srcObject->fetchObjectLinked(); - + if (! empty($srcObject->linkedObjectsIds['contrat'])) { $contractidid = reset($srcObject->linkedObjectsIds['contrat']); @@ -199,12 +200,12 @@ if ($action == 'add') $object->linked_objects[$object->origin] = $object->origin_id; } } - + $db->begin(); $oldinvoice = new Facture($db); $oldinvoice->fetch($id); - + $result = $object->create($user, $oldinvoice->id); if ($result > 0) { @@ -222,18 +223,18 @@ if ($action == 'add') setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; } - + if (! $error) { $db->commit(); - + header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id); exit; } else { $db->rollback(); - + $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; @@ -311,16 +312,16 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->factu $object->fetch_thirdparty(); $db->begin(); - + $line=new FactureLigneRec($db); - + // For triggers $line->id = $lineid; - + if ($line->delete() > 0) { $result=$object->update_price(1); - + if ($result > 0) { $db->commit(); @@ -401,7 +402,7 @@ if ($action == 'addline' && $user->rights->facture->creer) setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); $error ++; } - + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { $ret = $object->fetch($id); if ($ret < 0) { @@ -435,7 +436,7 @@ if ($action == 'addline' && $user->rights->facture->creer) $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) $tva_npr=0; - + $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; $price_min = $prod->price_min; @@ -542,7 +543,7 @@ if ($action == 'addline' && $user->rights->facture->creer) $type = GETPOST('type'); $fk_unit= GETPOST('units', 'alpha'); } - + // Margin $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value @@ -550,7 +551,7 @@ if ($action == 'addline' && $user->rights->facture->creer) // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); - + $info_bits = 0; if ($tva_npr) $info_bits |= 0x01; @@ -582,7 +583,7 @@ if ($action == 'addline' && $user->rights->facture->creer) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); }*/ $object->fetch($object->id); // Reload lines - + unset($_POST['prod_entry_mode']); unset($_POST['qty']); @@ -745,7 +746,7 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' }*/ $object->fetch($object->id); // Reload lines - + unset($_POST['qty']); unset($_POST['type']); unset($_POST['productid']); @@ -820,7 +821,7 @@ $companystatic = new Societe($db); $now = dol_now(); $tmparray=dol_getdate($now); $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day - + /* * Create mode @@ -832,11 +833,11 @@ if ($action == 'create') $object = new Facture($db); // Source invoice $product_static = new Product($db); $formproject = new FormProjets($db); - + if ($object->fetch($id, $ref) > 0) { $result = $object->getLinesArray(); - + print '
\n"; dol_fiche_end(); - + /** * Barre d'actions @@ -1363,15 +1364,15 @@ else } print ''; - - + + print ''; } @@ -1416,7 +1417,7 @@ else else if ($year_date_when > 0) { $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'"; - } + } $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -1424,15 +1425,15 @@ else $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - + $sql.= $db->order($sortfield, $sortorder); $sql.= $db->plimit($limit+1,$offset); - + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - + $param='&socid='.$socid; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; @@ -1457,9 +1458,9 @@ else $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - + print '