34require 
'../../main.inc.php';
 
   35require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
 
   36require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
 
   37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
 
   38if (isModEnabled(
'project')) {
 
   39  include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
 
   42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
 
   43require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
 
   44require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
 
   45require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
 
   48$langs->loadLangs(array(
'bills', 
'companies', 
'compta', 
'admin', 
'other', 
'products', 
'banks'));
 
   50$action     = 
GETPOST(
'action', 
'alpha');
 
   51$massaction = 
GETPOST(
'massaction', 
'alpha');
 
   52$show_files = 
GETPOST(
'show_files', 
'int');
 
   53$confirm    = 
GETPOST(
'confirm', 
'alpha');
 
   54$cancel     = 
GETPOST(
'cancel', 
'alpha');
 
   55$toselect   = 
GETPOST(
'toselect', 
'array');
 
   56$contextpage = 
GETPOST(
'contextpage', 
'aZ') ?
GETPOST(
'contextpage', 
'aZ') : 
'invoicetemplatelist'; 
 
   60$lineid = 
GETPOST(
'lineid', 
'int');
 
   63  $socid = $user->socid;
 
   65$objecttype = 
'facture_rec';
 
   66if ($action == 
"create" || $action == 
"add") {
 
   69$projectid = 
GETPOST(
'projectid', 
'int');
 
   71$year_date_when = 
GETPOST(
'year_date_when');
 
   72$month_date_when = 
GETPOST(
'month_date_when');
 
   74$limit = 
GETPOST(
'limit', 
'int') ?
GETPOST(
'limit', 
'int') : $conf->liste_limit;
 
   75$sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   76$sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
   77$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) : 
GETPOST(
"page", 
'int');
 
   78if (empty($page) || $page == -1) {
 
   81$offset = $limit * $page;
 
   86  $sortfield = 
'f.titre';
 
   92if (($id > 0 || $ref) && $action != 
'create' && $action != 
'add') {
 
   93  $ret = $object->fetch($id, $ref);
 
  103$hookmanager->initHooks(array(
'invoicereccard', 
'globalcard'));
 
  107$extrafields->fetch_name_optionals_label($object->table_element);
 
  109$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, 
'', 
'search_');
 
  111$permissionnote = $user->hasRight(
'facture', 
'creer'); 
 
  112$permissiondellink = $user->hasRight(
'facture', 
'creer'); 
 
  113$permissiontoedit = $user->hasRight(
'facture', 
'creer'); 
 
  115$usercanread = $user->hasRight(
'facture', 
'lire');
 
  116$usercancreate = $user->hasRight(
'facture', 
'creer');
 
  117$usercanissuepayment = $user->hasRight(
'facture', 
'paiement');
 
  118$usercandelete = $user->hasRight(
'facture', 
'supprimer');
 
  119$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate)));
 
  120$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send);
 
  121$usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen);
 
  122$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate)));
 
  124$usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
 
  125$usercancreatemargin = $user->hasRight(
"margins", 
"creer");
 
  126$usercanreadallmargin = $user->hasRight(
"margins", 
"liretous");
 
  127$usercancreatewithdrarequest = $user->hasRight(
"prelevement", 
"bons", 
"creer");
 
  133$result = 
restrictedArea($user, 
'facture', $object->id, $objecttype);
 
  140if (
GETPOST(
'cancel', 
'alpha')) {
 
  144if (!
GETPOST(
'confirmmassaction', 
'alpha') && $massaction != 
'presend' && $massaction != 
'confirm_presend') {
 
  148$parameters = array();
 
  149$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action); 
 
  154if (empty($reshook)) {
 
  155  if (
GETPOST(
'cancel', 
'alpha')) {
 
  160  include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
 
  163  include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php'; 
 
  165  include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php'; 
 
  167  include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php'; 
 
  178  if ($action == 
'add') {
 
  179    if (!
GETPOST(
'title', 
'alphanohtml')) {
 
  180      setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")), 
null, 
'errors');
 
  185    $frequency = 
GETPOST(
'frequency', 
'int');
 
  186    $reyear = 
GETPOST(
'reyear', 
'int');
 
  187    $remonth = 
GETPOST(
'remonth', 
'int');
 
  188    $reday = 
GETPOST(
'reday', 
'int');
 
  189    $rehour = 
GETPOST(
'rehour', 
'int');
 
  190    $remin = 
GETPOST(
'remin', 
'int');
 
  191    $nb_gen_max = 
GETPOST(
'nb_gen_max', 
'int');
 
  194    if (
GETPOST(
'frequency', 
'int')) {
 
  195      if (empty($reyear) || empty($remonth) || empty($reday)) {
 
  196        setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")), 
null, 
'errors');
 
  208      $object->titre = 
GETPOST(
'title', 
'alphanohtml'); 
 
  209      $object->title = 
GETPOST(
'title', 
'alphanohtml');
 
  210      $object->note_private = 
GETPOST(
'note_private', 
'restricthtml');
 
  211      $object->note_public = 
GETPOST(
'note_public', 
'restricthtml');
 
  212      $object->model_pdf = 
GETPOST(
'modelpdf', 
'alphanohtml');
 
  213      $object->usenewprice = 
GETPOST(
'usenewprice', 
'alphanohtml');
 
  215      $object->mode_reglement_id = 
GETPOST(
'mode_reglement_id', 
'int');
 
  216      $object->cond_reglement_id = 
GETPOST(
'cond_reglement_id', 
'int');
 
  218      $object->frequency = $frequency;
 
  219      $object->unit_frequency = 
GETPOST(
'unit_frequency', 
'alpha');
 
  220      $object->nb_gen_max = $nb_gen_max;
 
  221      $object->auto_validate = 
GETPOST(
'auto_validate', 
'int');
 
  222      $object->generate_pdf = 
GETPOST(
'generate_pdf', 
'int');
 
  223      $object->fk_project = $projectid;
 
  225      $date_next_execution = 
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
 
  226      $object->date_when = $date_next_execution;
 
  229      if (
GETPOST(
'facid', 
'int') > 0) {
 
  231        $srcObject->fetch(
GETPOST(
'facid', 
'int'));
 
  233        $srcObject->fetchObjectLinked();
 
  235        if (!empty($srcObject->linkedObjectsIds[
'contrat'])) {
 
  236          $contractidid = reset($srcObject->linkedObjectsIds[
'contrat']);
 
  238          $object->origin = 
'contrat';
 
  239          $object->origin_id = $contractidid;
 
  240          $object->linked_objects[$object->origin] = $object->origin_id;
 
  246      $oldinvoice = 
new Facture($db);
 
  247      $oldinvoice->fetch(
GETPOST(
'facid', 
'int'));
 
  249      $result = $object->create($user, $oldinvoice->id);
 
  251        $result = $oldinvoice->delete($user, 1);
 
  266        header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?facid='.$object->id);
 
  277  if ($action == 
'confirm_delete' && $confirm == 
'yes' && $user->rights->facture->supprimer) {
 
  278    $object->delete($user);
 
  280    header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php');
 
  287  if ($action == 
'setconditions' && $user->hasRight(
'facture', 
'creer')) {
 
  288    $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id', 
'int'));
 
  289  } elseif ($action == 
'setmode' && $user->hasRight(
'facture', 
'creer')) {
 
  291    $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id', 
'int'));
 
  292  } elseif ($action == 
'classin' && $user->hasRight(
'facture', 
'creer')) {
 
  294    $object->setProject(
GETPOST(
'projectid', 
'int'));
 
  295  } elseif ($action == 
'setref' && $user->hasRight(
'facture', 
'creer')) {
 
  298    $result = $object->setValueFrom(
'titre', $ref, 
'', 
null, 
'text', 
'', $user, 
'BILLREC_MODIFY');
 
  300      $object->titre = $ref; 
 
  301      $object->title = $ref;
 
  302      $object->ref = $object->title;
 
  305      if ($object->error == 
'DB_ERROR_RECORD_ALREADY_EXISTS') {
 
  306        $langs->load(
"errors");
 
  307        setEventMessages($langs->trans(
'ErrorRefAlreadyExists', $ref), 
null, 
'errors');
 
  312  } elseif ($action == 
'setbankaccount' && $user->hasRight(
'facture', 
'creer')) {
 
  314    $result = $object->setBankAccount(
GETPOST(
'fk_account', 
'int'));
 
  315  } elseif ($action == 
'setfrequency' && $user->hasRight(
'facture', 
'creer')) {
 
  317    $object->setFrequencyAndUnit(
GETPOST(
'frequency', 
'int'), 
GETPOST(
'unit_frequency', 
'alpha'));
 
  318  } elseif ($action == 
'setdate_when' && $user->hasRight(
'facture', 
'creer')) {
 
  322      $object->setNextDate($date);
 
  324  } elseif ($action == 
'setnb_gen_max' && $user->hasRight(
'facture', 
'creer')) {
 
  326    $object->setMaxPeriod(
GETPOST(
'nb_gen_max', 
'int'));
 
  327  } elseif ($action == 
'setauto_validate' && $user->hasRight(
'facture', 
'creer')) {
 
  329    $object->setAutoValidate(
GETPOST(
'auto_validate', 
'int'));
 
  330  } elseif ($action == 
'setgenerate_pdf' && $user->hasRight(
'facture', 
'creer')) {
 
  332    $object->setGeneratepdf(
GETPOST(
'generate_pdf', 
'int'));
 
  333  } elseif ($action == 
'setmodelpdf' && $user->hasRight(
'facture', 
'creer')) {
 
  335    $object->setModelpdf(
GETPOST(
'modelpdf', 
'alpha'));
 
  336  } elseif ($action == 
'disable' && $user->hasRight(
'facture', 
'creer')) {
 
  342    $res = $object->setValueFrom(
'suspended', 1);
 
  353  } elseif ($action == 
'enable' && $user->hasRight(
'facture', 
'creer')) {
 
  359    $res = $object->setValueFrom(
'suspended', 0);
 
  370  } elseif ($action == 
'setmulticurrencycode' && $usercancreate) {
 
  372    $result = $object->setMulticurrencyCode(
GETPOST(
'multicurrency_code', 
'alpha'));
 
  373  } elseif ($action == 
'setmulticurrencyrate' && $usercancreate) {
 
  375    $result = $object->setMulticurrencyRate(
price2num(
GETPOST(
'multicurrency_tx')), 
GETPOST(
'calculation_mode', 
'int'));
 
  379  if ($action == 
'confirm_deleteline' && $confirm == 
'yes' && $user->hasRight(
'facture', 
'creer')) {
 
  381    $object->fetch_thirdparty();
 
  390    if ($line->delete($user) > 0) {
 
  391      $result = $object->update_price(1);
 
  395        $object->fetch($object->id); 
 
  404  } elseif ($action == 
'update_extras') {
 
  408    $ret = $extrafields->setOptionalsFromPost(
null, $object, 
GETPOST(
'attribute', 
'restricthtml'));
 
  414      $result = $object->insertExtraFields(
'BILLREC_MODIFY');
 
  423  if ($action == 
'addline' && $user->hasRight(
'facture', 
'creer')) {
 
  424    $langs->load(
'errors');
 
  429    $product_desc = (GETPOSTISSET(
'dp_desc') ? 
GETPOST(
'dp_desc', 
'restricthtml') : 
'');
 
  432    $prod_entry_mode = 
GETPOST(
'prod_entry_mode', 
'alpha');
 
  433    if ($prod_entry_mode == 
'free') {
 
  436      $idprod = 
GETPOST(
'idprod', 
'int');
 
  438      if (!empty($conf->global->MAIN_DISABLE_FREE_LINES) && $idprod <= 0) {
 
  439        setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")), 
null, 
'errors');
 
  444    $tva_tx = (
GETPOST(
'tva_tx', 
'alpha') ? 
GETPOST(
'tva_tx', 
'alpha') : 0);
 
  448    if (empty($remise_percent)) {
 
  453    $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
 
  454    $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
 
  456    if (is_array($extralabelsline)) {
 
  458      foreach ($extralabelsline as $key => $value) {
 
  459        unset($_POST[
"options_".$key.$predef]);
 
  463    if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
 
  464      setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')), 
null, 
'errors');
 
  467    if ($prod_entry_mode == 
'free' && (empty($idprod) || $idprod < 0) && 
GETPOST(
'type') < 0) {
 
  468      setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')), 
null, 
'errors');
 
  471    if ($prod_entry_mode == 
'free' && (empty($idprod) || $idprod < 0) && (!($price_ht >= 0) || $price_ht == 
'')) {  
 
  472      setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")), 
null, 
'errors');
 
  476      setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')), 
null, 
'errors');
 
  479    if ($prod_entry_mode == 
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
 
  480      setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')), 
null, 
'errors');
 
  484      $langs->load(
"errors");
 
  485      setEventMessages($langs->trans(
'ErrorQtyForCustomerInvoiceCantBeNegative'), 
null, 
'errors');
 
  489    if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
 
  490      $ret = $object->fetch($id);
 
  495      $ret = $object->fetch_thirdparty();
 
  500      $price_base_type = (
GETPOST(
'price_base_type', 
'alpha') ? 
GETPOST(
'price_base_type', 
'alpha') : 
'HT');
 
  511      if (!empty($idprod) && $idprod > 0) {
 
  513        $prod->fetch($idprod);
 
  515        $label = ((
GETPOST(
'product_label') && 
GETPOST(
'product_label') != $prod->label) ? 
GETPOST(
'product_label') : 
'');
 
  527        $datapriceofproduct = $prod->getSellPrice($mysoc, $object->thirdparty, $pqp);
 
  529        $pu_ht = $datapriceofproduct[
'pu_ht'];
 
  530        $pu_ttc = $datapriceofproduct[
'pu_ttc'];
 
  531        $price_min = $datapriceofproduct[
'price_min'];
 
  532        $price_base_type = empty($datapriceofproduct[
'price_base_type']) ? 
'HT' : $datapriceofproduct[
'price_base_type'];
 
  536        $tmpvat = (float) 
price2num(preg_replace(
'/\s*\(.*\)/', 
'', $tva_tx));
 
  537        $tmpprodvat = 
price2num(preg_replace(
'/\s*\(.*\)/', 
'', $prod->tva_tx));
 
  540        if (!empty($price_ht)) {
 
  542          $pu_ttc = 
price2num($pu_ht * (1 + ($tmpvat / 100)), 
'MU');
 
  543        } elseif ($tmpvat != $tmpprodvat) {
 
  546          if ($price_base_type != 
'HT') {
 
  547            $pu_ht = 
price2num($pu_ttc / (1 + ($tmpvat / 100)), 
'MU');
 
  549            $pu_ttc = 
price2num($pu_ht * (1 + ($tmpvat / 100)), 
'MU');
 
  556        if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
 
  557          $outputlangs = $langs;
 
  559          if (empty($newlang) && 
GETPOST(
'lang_id', 
'aZ09')) {
 
  560            $newlang = 
GETPOST(
'lang_id', 
'aZ09');
 
  562          if (empty($newlang)) {
 
  563            $newlang = $object->thirdparty->default_lang;
 
  565          if (!empty($newlang)) {
 
  567            $outputlangs->setDefaultLang($newlang);
 
  570          $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] [
"description"])) ? $prod->multilangs [$outputlangs->defaultlang] [
"description"] : $prod->
description;
 
  572          $desc = $prod->description;
 
  578        if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
 
  581          if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
 
  582            $outputlangs = $langs;
 
  584            if (empty($newlang) && 
GETPOST(
'lang_id', 
'alpha')) {
 
  585              $newlang = 
GETPOST(
'lang_id', 
'alpha');
 
  587            if (empty($newlang)) {
 
  588              $newlang = $object->thirdparty->default_lang;
 
  590            if (!empty($newlang)) {
 
  592              $outputlangs->setDefaultLang($newlang);
 
  593              $outputlangs->load(
'products');
 
  595            if (!empty($prod->customcode)) {
 
  596              $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
 
  598            if (!empty($prod->customcode) && !empty($prod->country_code)) {
 
  601            if (!empty($prod->country_code)) {
 
  602              $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
 
  605            if (!empty($prod->customcode)) {
 
  606              $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
 
  608            if (!empty($prod->customcode) && !empty($prod->country_code)) {
 
  611            if (!empty($prod->country_code)) {
 
  612              $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
 
  620        $fk_unit = $prod->fk_unit;
 
  624        $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
 
  625        $tva_tx = str_replace(
'*', 
'', $tva_tx);
 
  626        if (empty($tva_tx)) {
 
  629        $label = (
GETPOST(
'product_label') ? 
GETPOST(
'product_label') : 
'');
 
  630        $desc = $product_desc;
 
  632        $fk_unit = 
GETPOST(
'units', 
'alpha');
 
  635      $date_start_fill = 
GETPOST(
'date_start_fill', 
'int');
 
  636      $date_end_fill = 
GETPOST(
'date_end_fill', 
'int');
 
  643      $localtax1_tx = 
get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
 
  644      $localtax2_tx = 
get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
 
  651      if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($pu_ht) * (1 - 
price2num($remise_percent) / 100) < 
price2num($price_min)))) {
 
  652        $mesg = $langs->trans(
"CantBeLessThanMinPrice", 
price(
price2num($price_min, 
'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
 
  656        $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, 
'', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
 
  677          $object->fetch($object->id); 
 
  679          unset($_POST[
'prod_entry_mode']);
 
  681          unset($_POST[
'qty']);
 
  682          unset($_POST[
'type']);
 
  683          unset($_POST[
'remise_percent']);
 
  684          unset($_POST[
'price_ht']);
 
  685          unset($_POST[
'multicurrency_price_ht']);
 
  686          unset($_POST[
'price_ttc']);
 
  687          unset($_POST[
'tva_tx']);
 
  688          unset($_POST[
'product_ref']);
 
  689          unset($_POST[
'product_label']);
 
  690          unset($_POST[
'product_desc']);
 
  691          unset($_POST[
'fournprice']);
 
  692          unset($_POST[
'buying_price']);
 
  693          unset($_POST[
'np_marginRate']);
 
  694          unset($_POST[
'np_markRate']);
 
  695          unset($_POST[
'dp_desc']);
 
  696          unset($_POST[
'idprod']);
 
  697          unset($_POST[
'units']);
 
  699          unset($_POST[
'date_starthour']);
 
  700          unset($_POST[
'date_startmin']);
 
  701          unset($_POST[
'date_startsec']);
 
  702          unset($_POST[
'date_startday']);
 
  703          unset($_POST[
'date_startmonth']);
 
  704          unset($_POST[
'date_startyear']);
 
  705          unset($_POST[
'date_endhour']);
 
  706          unset($_POST[
'date_endmin']);
 
  707          unset($_POST[
'date_endsec']);
 
  708          unset($_POST[
'date_endday']);
 
  709          unset($_POST[
'date_endmonth']);
 
  710          unset($_POST[
'date_endyear']);
 
  712          unset($_POST[
'date_start_fill']);
 
  713          unset($_POST[
'date_end_fill']);
 
  715          unset($_POST[
'situations']);
 
  716          unset($_POST[
'progress']);
 
  724  } elseif ($action == 
'updateline' && $usercancreate && !
GETPOST(
'cancel', 
'alpha')) {
 
  725    if (!$object->fetch($id) > 0) {
 
  728    $object->fetch_thirdparty();
 
  743    if (preg_match(
'/\*/', $vat_rate)) {
 
  748    $vat_rate = str_replace(
'*', 
'', $vat_rate);
 
  749    $localtax1_rate = 
get_localtax($vat_rate, 1, $object->thirdparty);
 
  750    $localtax2_rate = 
get_localtax($vat_rate, 2, $object->thirdparty);
 
  757    $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
 
  758    $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
 
  761    if ($objectline->fetch(
GETPOST(
'lineid', 
'int'))) {
 
  762      $objectline->array_options = $array_options;
 
  763      $result = $objectline->insertExtraFields();
 
  769    $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
 
  772    if (is_array($extralabelsline)) {
 
  774      foreach ($extralabelsline as $key => $value) {
 
  775         unset($_POST[
"options_".$key]);
 
  780    $special_code = 
GETPOST(
'special_code', 
'int');
 
  781    if ($special_code == 3) {
 
  798    if (empty($remise_percent)) {
 
  803    $productid = 
GETPOST(
'productid', 
'int');
 
  804    if (!empty($productid)) {
 
  806      $product->fetch($productid);
 
  808      $type = $product->type;
 
  810      $price_min = $product->price_min;
 
  811      if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
 
  812        $price_min = $product->multiprices_min[$object->thirdparty->price_level];
 
  820      if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($typeinvoice == 
Facture::TYPE_STANDARD || $typeinvoice == 
Facture::TYPE_REPLACEMENT) && $price_min && ((float) 
price2num($pu_ht) * (1 - (float) $remise_percent / 100) < (float) 
price2num($price_min)))) {
 
  821        setEventMessages($langs->trans(
"CantBeLessThanMinPrice", 
price(
price2num($price_min, 
'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 
null, 
'errors');
 
  825      $type = 
GETPOST(
'type', 
'int');
 
  826      $label = (
GETPOST(
'product_label') ? 
GETPOST(
'product_label') : 
'');
 
  829      if (
GETPOST(
'type', 
'int') < 0) {
 
  830        setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), 
null, 
'errors');
 
  835      $langs->load(
"errors");
 
  836      setEventMessages($langs->trans(
'ErrorQtyForCustomerInvoiceCantBeNegative'), 
null, 
'errors');
 
  840    $date_start_fill = 
GETPOST(
'date_start_fill', 
'int');
 
  841    $date_end_fill = 
GETPOST(
'date_end_fill', 
'int');
 
  845      $result = $object->updateline(
 
  890        $object->fetch($object->id); 
 
  892        unset($_POST[
'qty']);
 
  893        unset($_POST[
'type']);
 
  894        unset($_POST[
'productid']);
 
  895        unset($_POST[
'remise_percent']);
 
  896        unset($_POST[
'price_ht']);
 
  897        unset($_POST[
'multicurrency_price_ht']);
 
  898        unset($_POST[
'price_ttc']);
 
  899        unset($_POST[
'tva_tx']);
 
  900        unset($_POST[
'product_ref']);
 
  901        unset($_POST[
'product_label']);
 
  902        unset($_POST[
'product_desc']);
 
  903        unset($_POST[
'fournprice']);
 
  904        unset($_POST[
'buying_price']);
 
  905        unset($_POST[
'np_marginRate']);
 
  906        unset($_POST[
'np_markRate']);
 
  908        unset($_POST[
'dp_desc']);
 
  909        unset($_POST[
'idprod']);
 
  910        unset($_POST[
'units']);
 
  912        unset($_POST[
'date_starthour']);
 
  913        unset($_POST[
'date_startmin']);
 
  914        unset($_POST[
'date_startsec']);
 
  915        unset($_POST[
'date_startday']);
 
  916        unset($_POST[
'date_startmonth']);
 
  917        unset($_POST[
'date_startyear']);
 
  918        unset($_POST[
'date_endhour']);
 
  919        unset($_POST[
'date_endmin']);
 
  920        unset($_POST[
'date_endsec']);
 
  921        unset($_POST[
'date_endday']);
 
  922        unset($_POST[
'date_endmonth']);
 
  923        unset($_POST[
'date_endyear']);
 
  925        unset($_POST[
'situations']);
 
  926        unset($_POST[
'progress']);
 
  940llxHeader(
'', $langs->trans(
"RepeatableInvoices"), $help_url);
 
  942$form = 
new Form($db);
 
  944if (isModEnabled(
'project')) {
 
  947$companystatic = 
new Societe($db);
 
  957if ($action == 
'create') {
 
  958  print 
load_fiche_titre($langs->trans(
"CreateRepeatableInvoice"), 
'', 
'bill');
 
  961  $product_static = 
new Product($db);
 
  963  if ($object->fetch($id, $ref) > 0) {
 
  964    $result = $object->getLinesArray();
 
  966    print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
 
  967    print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  968    print 
'<input type="hidden" name="action" value="add">';
 
  969    print 
'<input type="hidden" name="facid" value="'.$object->id.
'">';
 
  974    if (isModEnabled(
'project')) {
 
  977    if ($object->fk_account > 0) {
 
  981    print 
'<table class="border centpercent">';
 
  983    $object->fetch_thirdparty();
 
  986    print 
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Title").
'</td><td>';
 
  987    print 
'<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(
GETPOST(
"title", 
'alphanohtml')).
'" autofocus>';
 
  991    print 
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Customer").
'</td><td>'.$object->thirdparty->getNomUrl(1, 
'customer').
'</td>';
 
  994    $note_public = GETPOSTISSET(
'note_public') ? 
GETPOST(
'note_public', 
'restricthtml') : $object->note_public;
 
  995    $note_private = GETPOSTISSET(
'note_private') ? 
GETPOST(
'note_private', 
'restricthtml') : $object->note_private;
 
 1000    $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($object->date, -1, 
'm'), 
'%m').
')';
 
 1001    $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($object->date, 
'%m').
')';
 
 1002    $substitutionarray[
'__INVOICE_NEXT_MONTH__'] = $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($object->date, 1, 
'm'), 
'%m').
')';
 
 1003    $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($object->date, -1, 
'm'), 
'%B').
')';
 
 1004    $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($object->date, 
'%B').
')';
 
 1005    $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($object->date, 1, 
'm'), 
'%B').
')';
 
 1006    $substitutionarray[
'__INVOICE_PREVIOUS_YEAR__'] = $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($object->date, -1, 
'y'), 
'%Y').
')';
 
 1007    $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($object->date, 
'%Y').
')';
 
 1008    $substitutionarray[
'__INVOICE_NEXT_YEAR__'] = $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($object->date, 1, 
'y'), 
'%Y').
')';
 
 1010    $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans(
"DateNextInvoiceBeforeGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($object->date, 1, 
'm'), 
'dayhour').
')';
 
 1011    $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans(
"DateNextInvoiceAfterGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($object->date, 2, 
'm'), 
'dayhour').
')';
 
 1012    $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] = $langs->trans(
"Count");
 
 1013    $substitutionarray[
'__INVOICE_COUNTER_MAX__'] = $langs->trans(
"MaxPeriodNumber");
 
 1015    $htmltext = 
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
 
 1016    foreach ($substitutionarray as $key => $val) {
 
 1017      $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
 
 1019    $htmltext .= 
'</i>';
 
 1023    print 
'<td class="tdtop">';
 
 1024    print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1, 
'help', 
'', 0, 2, 
'notepublic');
 
 1027    $doleditor = 
new DolEditor(
'note_public', $note_public, 
'', 80, 
'dolibarr_notes', 
'In', 0, 
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, 
'90%');
 
 1028    print $doleditor->Create(1);
 
 1031    if (empty($user->socid)) {
 
 1033      print 
'<td class="tdtop">';
 
 1034      print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext, 1, 
'help', 
'', 0, 2, 
'noteprivate');
 
 1037      $doleditor = 
new DolEditor(
'note_private', $note_private, 
'', 80, 
'dolibarr_notes', 
'In', 0, 
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, 
'90%');
 
 1038      print $doleditor->Create(1);
 
 1044    print 
"<tr><td>".$langs->trans(
"Author").
"</td><td>".$user->getFullName($langs).
"</td></tr>";
 
 1047    print 
"<tr><td>".$langs->trans(
"PaymentConditions").
"</td><td>";
 
 1048    print $form->getSelectConditionsPaiements(GETPOSTISSET(
'cond_reglement_id') ? 
GETPOST(
'cond_reglement_id', 
'int') : $object->cond_reglement_id, 
'cond_reglement_id', -1, 0, 0, 
'');
 
 1053    print 
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>";
 
 1054    print 
img_picto(
'', 
'payment', 
'class="pictofixedwidth"');
 
 1055    print $form->select_types_paiements(GETPOSTISSET(
'mode_reglement_id') ? 
GETPOST(
'mode_reglement_id', 
'int') : $object->mode_reglement_id, 
'mode_reglement_id', 
'', 0, 1, 0, 0, 1, 
'', 1);
 
 1060    if ($object->fk_account > 0) {
 
 1061      print 
"<tr><td>".$langs->trans(
'BankAccount').
"</td><td>";
 
 1062      $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account, 
'none');
 
 1067    if (isModEnabled(
'project') && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
 
 1068      $projectid = 
GETPOST(
'projectid') ?
GETPOST(
'projectid') : $object->fk_project;
 
 1069      $langs->load(
'projects');
 
 1070      print 
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
 
 1071      print 
img_picto(
'', 
'project', 
'class="pictofixedwidth"');
 
 1072      $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 
'projectid', 0, 0, 1, 0, 0, 0, 0, 
'', 0, 0, 
'');
 
 1073      print 
'   <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$object->thirdparty->id.
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? 
'&id='.$id : 
'')).
'">'.
img_object($langs->trans(
"AddProject"), 
'add').
'</a>';
 
 1078    print 
"<tr><td>".$langs->trans(
'Model').
"</td><td>";
 
 1079    include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
 
 1081    print 
img_picto(
'', 
'generic', 
'class="pictofixedwidth"');
 
 1082    print $form->selectarray(
'modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
 
 1091    $title = $langs->trans(
"Recurrence");
 
 1096    print 
'<table class="border centpercent">';
 
 1099    print 
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency')).
"</td><td>";
 
 1100    print 
"<input type='text' name='frequency' value='".GETPOST(
'frequency', 
'int').
"' size='4' /> ";
 
 1101    print $form->selectarray(
'unit_frequency', array(
'd'=>$langs->trans(
'Day'), 
'm'=>$langs->trans(
'Month'), 
'y'=>$langs->trans(
'Year')), (
GETPOST(
'unit_frequency') ?
GETPOST(
'unit_frequency') : 
'm'));
 
 1105    print 
"<tr><td>".$langs->trans(
'NextDateToExecution').
"</td><td>";
 
 1107    print $form->selectDate($date_next_execution, 
'', 1, 1, 
'', 
"add", 1, 1);
 
 1111    print 
"<tr><td>".$langs->trans(
"MaxPeriodNumber").
"</td><td>";
 
 1112    print 
'<input type="text" name="nb_gen_max" value="'.GETPOST(
'nb_gen_max').
'" size="5" />';
 
 1116    print 
"<tr><td>".$langs->trans(
"StatusOfGeneratedInvoices").
"</td><td>";
 
 1117    $select = array(
'0'=>$langs->trans(
'BillStatusDraft'), 
'1'=>$langs->trans(
'BillStatusValidated'));
 
 1118    print $form->selectarray(
'auto_validate', $select, 
GETPOST(
'auto_validate'));
 
 1122    if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) {
 
 1123      print 
"<tr><td>".$langs->trans(
"StatusOfGeneratedDocuments").
"</td><td>";
 
 1124      $select = array(
'0'=>$langs->trans(
'DoNotGenerateDoc'), 
'1'=>$langs->trans(
'AutoGenerateDoc'));
 
 1125      print $form->selectarray(
'generate_pdf', $select, 
GETPOST(
'generate_pdf'));
 
 1128      print 
'<input type="hidden" name="generate_pdf" value="1">';
 
 1136    $title = $langs->trans(
"ProductsAndServices");
 
 1137    if (!isModEnabled(
'service')) {
 
 1138      $title = $langs->trans(
"Products");
 
 1139    } elseif (!isModEnabled(
'product')) {
 
 1140      $title = $langs->trans(
"Services");
 
 1148    print 
'<div class="div-table-responsive-no-min">';
 
 1149    print 
'<table id="tablelines" class="noborder noshadow" width="100%">';
 
 1151    if (!empty($object->lines)) {
 
 1155      $object->printObjectLines(
'', $mysoc, $object->thirdparty, $lineid, 0); 
 
 1163    if ($flag_price_may_change) {
 
 1164      print 
'<tr><td colspan="3" class="left">';
 
 1165      print 
'<select name="usenewprice" class="flat">';
 
 1166      print 
'<option value="0">'.$langs->trans(
"AlwaysUseFixedPrice").
'</option>';
 
 1167      print 
'<option value="1" disabled>'.$langs->trans(
"AlwaysUseNewPrice").
'</option>';
 
 1173    print $form->buttonsSaveCancel(
"Create");
 
 1183  if ($object->id > 0) {
 
 1184    $object->fetch_thirdparty();
 
 1188    if ($action == 
'ask_deleteline') {
 
 1189      $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'), 
'confirm_deleteline', 
'', 
'no', 1);
 
 1192    if ($action == 
'delete') {
 
 1193      $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteRepeatableInvoice'), $langs->trans(
'ConfirmDeleteRepeatableInvoice'), 
'confirm_delete', 
'', 
'no', 1);
 
 1197    $parameters = array(
'formConfirm' => $formconfirm);
 
 1198    $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action); 
 
 1199    if (empty($reshook)) {
 
 1200      $formconfirm .= $hookmanager->resPrint;
 
 1201    } elseif ($reshook > 0) {
 
 1202      $formconfirm = $hookmanager->resPrint;
 
 1207    $author = 
new User($db);
 
 1208    $author->fetch($object->user_author);
 
 1212    print 
dol_get_fiche_head($head, 
'card', $langs->trans(
"RepeatableInvoice"), -1, 
'bill'); 
 
 1216    $linkback = 
'<a href="'.DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php?restore_lastsearch_values=1'.(!empty($socid) ? 
'&socid='.$socid : 
'').
'">'.$langs->trans(
"BackToList").
'</a>';
 
 1219    if ($action != 
'editref') {
 
 1220      $morehtmlref .= $form->editfieldkey($object->ref, 
'ref', $object->ref, $object, $user->hasRight(
'facture', 
'creer'), 
'', 
'', 0, 2);
 
 1222      $morehtmlref .= $form->editfieldval(
'', 
'ref', $object->ref, $object, $user->hasRight(
'facture', 
'creer'), 
'string');
 
 1225    $morehtmlref .= 
'<div class="refidno">';
 
 1230    $morehtmlref .= $langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
 
 1232    if (isModEnabled(
'project')) {
 
 1233      $langs->load(
"projects");
 
 1234      $morehtmlref .= 
'<br>'.$langs->trans(
'Project').
' ';
 
 1235      if ($user->hasRight(
'facture', 
'creer')) {
 
 1236        if ($action != 
'classify') {
 
 1237          $morehtmlref .= 
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
 
 1239        if ($action == 
'classify') {
 
 1241          $morehtmlref .= 
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
 
 1242          $morehtmlref .= 
'<input type="hidden" name="action" value="classin">';
 
 1243          $morehtmlref .= 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
 1244          $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 
'projectid', $maxlength, 0, 1, 0, 1, 0, 0, 
'', 1);
 
 1245          $morehtmlref .= 
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
 
 1246          $morehtmlref .= 
'</form>';
 
 1248          $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, 
'none', 0, 0, 0, 1, 
'', 
'maxwidth300');
 
 1251        if (!empty($object->fk_project)) {
 
 1253          $proj->fetch($object->fk_project);
 
 1254          $morehtmlref .= 
' : '.$proj->getNomUrl(1);
 
 1256            $morehtmlref .= 
' - '.$proj->title;
 
 1263    $morehtmlref .= 
'</div>';
 
 1265    $morehtmlright = 
'';
 
 1267    dol_banner_tab($object, 
'ref', $linkback, 1, 
'title', 
'none', $morehtmlref, 
'', 0, 
'', $morehtmlright);
 
 1269    print 
'<div class="fichecenter">';
 
 1270    print 
'<div class="fichehalfleft">';
 
 1271    print 
'<div class="underbanner clearboth"></div>';
 
 1273    print 
'<table class="border centpercent tableforfield">';
 
 1275    print 
'<tr><td class="titlefield">'.$langs->trans(
"Author").
'</td><td>';
 
 1276    print $author->getNomUrl(-1);
 
 1279    print 
'<tr><td>'.$langs->trans(
"AmountHT").
'</td>';
 
 1280    print 
'<td>'.price($object->total_ht, 
'', $langs, 1, -1, -1, $conf->currency).
'</td>';
 
 1283    print 
'<tr><td>'.$langs->trans(
"AmountVAT").
'</td><td>'.
price($object->total_tva, 
'', $langs, 1, -1, -1, $conf->currency).
'</td>';
 
 1287    if (($mysoc->localtax1_assuj == 
"1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) {  
 
 1288      print 
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
 
 1289      print 
'<td class="nowrap">'.price($object->total_localtax1, 1, 
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
 
 1291    if (($mysoc->localtax2_assuj == 
"1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) {  
 
 1292      print 
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
 
 1293      print 
'<td class=nowrap">'.price($object->total_localtax2, 1, 
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
 
 1296    print 
'<tr><td>'.$langs->trans(
"AmountTTC").
'</td><td colspan="3">'.
price($object->total_ttc, 
'', $langs, 1, -1, -1, $conf->currency).
'</td>';
 
 1302    print 
'<table class="nobordernopadding centpercent"><tr><td>';
 
 1303    print $langs->trans(
'PaymentConditionsShort');
 
 1305    if ($action != 
'editconditions' && $user->hasRight(
'facture', 
'creer')) {
 
 1306      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.newToken().
'&facid='.$object->id.
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
 
 1308    print 
'</tr></table>';
 
 1310    if ($action == 
'editconditions') {
 
 1311      $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?facid='.$object->id, $object->cond_reglement_id, 
'cond_reglement_id');
 
 1313      $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?facid='.$object->id, $object->cond_reglement_id, 
'none');
 
 1319    print 
'<table class="nobordernopadding" width="100%"><tr><td>';
 
 1320    print $langs->trans(
'PaymentMode');
 
 1322    if ($action != 
'editmode' && $user->hasRight(
'facture', 
'creer')) {
 
 1323      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.newToken().
'&facid='.$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
 
 1325    print 
'</tr></table>';
 
 1327    if ($action == 
'editmode') {
 
 1328      $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?facid='.$object->id, $object->mode_reglement_id, 
'mode_reglement_id', 
'CRDT', 1, 1);
 
 1330      $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?facid='.$object->id, $object->mode_reglement_id, 
'none');
 
 1335    if (isModEnabled(
'multicurrency')) {
 
 1339      print 
'<table class="nobordernopadding" width="100%"><tr><td>';
 
 1340      print $form->editfieldkey(
'Currency', 
'multicurrency_code', 
'', $object, 0);
 
 1342      if ($usercancreate && $action != 
'editmulticurrencycode' && !empty($object->brouillon)) {
 
 1343        print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencycode&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
 
 1345      print 
'</tr></table>';
 
 1347      $htmlname = (($usercancreate && $action == 
'editmulticurrencycode') ? 
'multicurrency_code' : 
'none');
 
 1348      $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code, $htmlname);
 
 1352      if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
 
 1355        print 
'<table class="nobordernopadding" width="100%"><tr><td>';
 
 1356        print $form->editfieldkey(
'CurrencyRate', 
'multicurrency_tx', 
'', $object, 0);
 
 1358        if ($usercancreate && $action != 
'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
 
 1359          print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencyrate&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
 
 1361        print 
'</tr></table>';
 
 1363        if ($action == 
'editmulticurrencyrate' || $action == 
'actualizemulticurrencyrate') {
 
 1364          if ($action == 
'actualizemulticurrencyrate') {
 
 1367          $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx, ($usercancreate ? 
'multicurrency_tx' : 
'none'), $object->multicurrency_code);
 
 1369          $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx, 
'none', $object->multicurrency_code);
 
 1370          if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
 
 1371            print 
'<div class="inline-block">         ';
 
 1372            print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
 
 1382    if (!empty($object->frequency) && !empty($object->date_when)) {
 
 1383      $dateexample = $object->date_when;
 
 1389    $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1, 
'm'), 
'%m').
')';
 
 1390    $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample, 
'%m').
')';
 
 1391    $substitutionarray[
'__INVOICE_NEXT_MONTH__'] = $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1, 
'm'), 
'%m').
')';
 
 1392    $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1, 
'm'), 
'%B').
')';
 
 1393    $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample, 
'%B').
')';
 
 1394    $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1, 
'm'), 
'%B').
')';
 
 1395    $substitutionarray[
'__INVOICE_PREVIOUS_YEAR__'] = $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1, 
'y'), 
'%Y').
')';
 
 1396    $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample, 
'%Y').
')';
 
 1397    $substitutionarray[
'__INVOICE_NEXT_YEAR__'] = $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1, 
'y'), 
'%Y').
')';
 
 1399    $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans(
"DateNextInvoiceBeforeGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(($object->date_when ? $object->date_when : 
dol_now()), 
'dayhour').
')';
 
 1400    $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans(
"DateNextInvoiceAfterGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(($object->date_when ? $object->date_when : 
dol_now()), $object->frequency, $object->unit_frequency), 
'dayhour').
')';
 
 1401    $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] = $object->nb_gen_done;
 
 1402    $substitutionarray[
'__INVOICE_COUNTER_MAX__'] = $object->nb_gen_max;
 
 1404    $htmltext = 
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
 
 1405    foreach ($substitutionarray as $key => $val) {
 
 1406      $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
 
 1408    $htmltext .= 
'</i>';
 
 1412    print $form->editfieldkey($form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1, 
'help', 
'', 0, 2, 
'notepublic'), 
'note_public', $object->note_public, $object, $user->hasRight(
'facture', 
'creer'));
 
 1413    print 
'</td><td class="wordbreak">';
 
 1414    print $form->editfieldval($langs->trans(
"NotePublic"), 
'note_public', $object->note_public, $object, $user->hasRight(
'facture', 
'creer'), 
'textarea:'.ROWS_4.
':90%', 
'', 
null, 
null, 
'', 1);
 
 1420    print $form->editfieldkey($form->textwithpicto($langs->trans(
"NotePrivate"), $htmltext, 1, 
'help', 
'', 0, 2, 
'noteprivate'), 
'note_private', $object->note_private, $object, $user->hasRight(
'facture', 
'creer'));
 
 1421    print 
'</td><td class="wordbreak">';
 
 1422    print $form->editfieldval($langs->trans(
"NotePrivate"), 
'note_private', $object->note_private, $object, $user->hasRight(
'facture', 
'creer'), 
'textarea:'.ROWS_4.
':90%', 
'', 
null, 
null, 
'', 1);
 
 1427    print 
'<tr><td class="nowrap">';
 
 1428    print 
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
 
 1429    print $langs->trans(
'BankAccount');
 
 1431    if (($action != 
'editbankaccount') && $user->hasRight(
'facture', 
'creer') && $object->statut == 
FactureRec::STATUS_DRAFT) {
 
 1432      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
 
 1434    print 
'</tr></table>';
 
 1436    if ($action == 
'editbankaccount') {
 
 1437      $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account, 
'fk_account', 1);
 
 1439      $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account, 
'none');
 
 1445    print 
'<tr><td class="nowrap">';
 
 1446    print 
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
 
 1447    print $langs->trans(
'Model');
 
 1449    if (($action != 
'editmodelpdf') && $user->hasRight(
'facture', 
'creer') && $object->statut == 
FactureRec::STATUS_DRAFT) {
 
 1450      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmodelpdf&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetModel'), 1).
'</a></td>';
 
 1452    print 
'</tr></table>';
 
 1454    if ($action == 
'editmodelpdf') {
 
 1455      include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
 
 1458      foreach ($models as $k => $model) {
 
 1459        $list[] = str_replace(
':', 
'|', $k).
':'.$model;
 
 1461      $select = 
'select;'.implode(
',', $list);
 
 1462      print $form->editfieldval($langs->trans(
"Model"), 
'modelpdf', $object->model_pdf, $object, $user->hasRight(
'facture', 
'creer'), $select);
 
 1464      print $object->model_pdf;
 
 1471    include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
 
 1476    print 
'<div class="fichehalfright">';
 
 1477    print 
'<div class="underbanner clearboth"></div>';
 
 1483    $title = $langs->trans(
"Recurrence");
 
 1486    print 
'<table class="border centpercent tableforfield">';
 
 1488    print 
'<tr><td colspan="2">'.img_picto(
'', 
'recurring', 
'class="pictofixedwidth"').$title.
'</td></tr>';
 
 1491    print 
'<tr><td style="width: 50%">';
 
 1492    print 
'<table class="nobordernopadding" width="100%"><tr><td>';
 
 1493    print $langs->trans(
'Frequency');
 
 1495    if ($action != 
'editfrequency' && $user->hasRight(
'facture', 
'creer')) {
 
 1496      print 
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editfrequency&token='.newToken().
'&facid='.$object->id.
'">'.
img_edit($langs->trans(
'Edit'), 1).
'</a></td>';
 
 1498    print 
'</tr></table>';
 
 1500    if ($action == 
'editfrequency') {
 
 1501      print 
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?facid='.$object->id.
'">';
 
 1502      print 
'<input type="hidden" name="action" value="setfrequency">';
 
 1503      print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
 1504      print 
'<table class="nobordernopadding">';
 
 1506      print 
"<input type='text' name='frequency' value='".$object->frequency.
"' size='5' /> ";
 
 1507      print $form->selectarray(
'unit_frequency', array(
'd'=>$langs->trans(
'Day'), 
'm'=>$langs->trans(
'Month'), 
'y'=>$langs->trans(
'Year')), ($object->unit_frequency ? $object->unit_frequency : 
'm'));
 
 1509      print 
'<td class="left"><input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
 
 1510      print 
'</tr></table></form>';
 
 1512      if ($object->frequency > 0) {
 
 1513        print $langs->trans(
'FrequencyPer_'.$object->unit_frequency, $object->frequency);
 
 1515        print 
'<span class="opacitymedium">'.$langs->trans(
"NotARecurringInvoiceTemplate").
'</span>';
 
 1522    if ($action == 
'date_when' || $object->frequency > 0) {
 
 1523      print $form->editfieldkey($langs->trans(
"NextDateToExecution"), 
'date_when', $object->date_when, $object, $user->hasRight(
'facture', 
'creer'), 
'day');
 
 1525      print $langs->trans(
"NextDateToExecution");
 
 1528    if ($action == 
'date_when' || $object->frequency > 0) {
 
 1529      print $form->editfieldval($langs->trans(
"NextDateToExecution"), 
'date_when', $object->date_when, $object, $user->hasRight(
'facture', 
'creer'), 
'day', $object->date_when, 
null, 
'', 
'', 0, 
'strikeIfMaxNbGenReached');
 
 1532    if (!$object->isMaxNbGenReached()) {
 
 1533      if (!$object->suspended && $action != 
'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) {
 
 1537      print 
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
 
 1544    if ($action == 
'nb_gen_max' || $object->frequency > 0) {
 
 1545      print $form->editfieldkey($langs->trans(
"MaxPeriodNumber"), 
'nb_gen_max', $object->nb_gen_max, $object, $user->hasRight(
'facture', 
'creer'));
 
 1547      print $langs->trans(
"MaxPeriodNumber");
 
 1550    if ($action == 
'nb_gen_max' || $object->frequency > 0) {
 
 1551        print $form->editfieldval($langs->trans(
"MaxPeriodNumber"), 
'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : 
'', $object, $user->hasRight(
'facture', 
'creer'));
 
 1560    if ($action == 
'auto_validate' || $object->frequency > 0) {
 
 1561      print $form->editfieldkey($langs->trans(
"StatusOfGeneratedInvoices"), 
'auto_validate', $object->auto_validate, $object, $user->hasRight(
'facture', 
'creer'));
 
 1563      print $langs->trans(
"StatusOfGeneratedInvoices");
 
 1566    $select = 
'select;0:'.$langs->trans(
'BillStatusDraft').
',1:'.$langs->trans(
'BillStatusValidated');
 
 1567    if ($action == 
'auto_validate' || $object->frequency > 0) {
 
 1568      print $form->editfieldval($langs->trans(
"StatusOfGeneratedInvoices"), 
'auto_validate', $object->auto_validate, $object, $user->hasRight(
'facture', 
'creer'), $select);
 
 1572    if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) {
 
 1575      if ($action == 
'generate_pdf' || $object->frequency > 0) {
 
 1576        print $form->editfieldkey($langs->trans(
"StatusOfGeneratedDocuments"), 
'generate_pdf', $object->generate_pdf, $object, $user->hasRight(
'facture', 
'creer'));
 
 1578        print $langs->trans(
"StatusOfGeneratedDocuments");
 
 1582      $select = 
'select;0:'.$langs->trans(
'DoNotGenerateDoc').
',1:'.$langs->trans(
'AutogenerateDoc');
 
 1583      if ($action == 
'generate_pdf' || $object->frequency > 0) {
 
 1584        print $form->editfieldval($langs->trans(
"StatusOfGeneratedDocuments"), 
'generate_pdf', $object->generate_pdf, $object, $user->hasRight(
'facture', 
'creer'), $select);
 
 1589      print 
'<input type="hidden" name="generate_pdf" value="1">';
 
 1595    if ($object->frequency > 0) {
 
 1598      if (!isModEnabled(
'cron')) {
 
 1599        print 
info_admin($langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name")));
 
 1602      print 
'<div class="underbanner clearboth"></div>';
 
 1603      print 
'<table class="border centpercent tableforfield">';
 
 1606      print 
'<tr><td style="width: 50%">'.$langs->trans(
"NbOfGenerationDone").
'</td>';
 
 1608      print $object->nb_gen_done ? $object->nb_gen_done : 
'0';
 
 1614      print $langs->trans(
"DateLastGeneration");
 
 1628    print 
'<div class="clearboth"></div><br>';
 
 1632    print 
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action != 
'editline') ? 
'#add' : 
'#line_'.
GETPOST(
'lineid', 
'int')).
'" method="POST">';
 
 1633    print 
'<input type="hidden" name="token" value="' . newToken().
'">';
 
 1634    print 
'<input type="hidden" name="action" value="' . (($action != 
'editline') ? 
'addline' : 
'updateline').
'">';
 
 1635    print 
'<input type="hidden" name="mode" value="">';
 
 1636    print 
'<input type="hidden" name="id" value="' . $object->id.
'">';
 
 1637    print 
'<input type="hidden" name="page_y" value="">';
 
 1639    if (!empty($conf->use_javascript_ajax) && $object->statut == 0) {
 
 1640      include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
 
 1643    print 
'<div class="div-table-responsive-no-min">';
 
 1644    print 
'<table id="tablelines" class="noborder noshadow centpercent">';
 
 1646    if (!empty($object->lines)) {
 
 1647      $canchangeproduct = 1;
 
 1648      $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); 
 
 1652    if ($object->statut == $object::STATUS_DRAFT && $user->hasRight(
'facture', 
'creer') && $action != 
'valid' && $action != 
'editline') {
 
 1653      if ($action != 
'editline') {
 
 1656        $parameters = array();
 
 1657        $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action); 
 
 1658        if ($reshook < 0) 
setEventMessages($hookmanager->error, $hookmanager->errors, 
'errors');
 
 1659        if (empty($reshook))
 
 1660          $object->formAddObjectLine(0, $mysoc, $object->thirdparty); 
 
 1675    print 
'<div class="tabsAction">';
 
 1677    $parameters = array();
 
 1678    $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action); 
 
 1679    if (empty($reshook)) {
 
 1682          'class' => 
'classfortooltip',
 
 1685      if (empty($object->suspended)) {
 
 1686        if ($user->hasRight(
'facture', 
'creer')) {
 
 1687          if (!empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) {
 
 1688            print 
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . 
dol_escape_htmltag($langs->trans(
"MaxGenerationReached")) . 
'">' . $langs->trans(
"CreateBill") . 
'</a></div>';
 
 1690            if (empty($object->frequency) || $object->date_when <= $nowlasthour) {
 
 1691              print 
'<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . 
'/compta/facture/card.php?action=create&socid=' . $object->thirdparty->id . 
'&fac_rec=' . $object->id . 
'">' . $langs->trans(
"CreateBill") . 
'</a></div>';
 
 1693              print 
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . 
dol_escape_htmltag($langs->trans(
"DateIsNotEnough")) . 
'">' . $langs->trans(
"CreateBill") . 
'</a></div>';
 
 1697          print 
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans(
"CreateBill") . 
'</a></div>';
 
 1701      if ($user->hasRight(
'facture', 
'creer')) {
 
 1702        if (empty($object->suspended)) {
 
 1703          print 
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?action=disable&id='.$object->id.
'&token='.newToken().
'">'.$langs->trans(
"Disable").
'</a></div>';
 
 1705          print 
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=enable&id='.$object->id.
'&token='.newToken().
'">'.$langs->trans(
"Enable").
'</a></div>';
 
 1710      print 
dolGetButtonAction($langs->trans(
"Delete"), 
'', 
'delete', $_SERVER[
"PHP_SELF"] . 
'?id=' . $object->id . 
'&action=delete&token=' . newToken(), 
'delete', $user->hasRight(
'facture', 
'supprimer'));
 
 1716    print 
'<div class="fichecenter"><div class="fichehalfleft">';
 
 1717    print 
'<a name="builddoc"></a>'; 
 
 1721    $linktoelem = $form->showLinkToObjectBlock($object, 
null, array(
'invoice'));
 
 1723    $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
 
 1727    print 
'<div class="fichehalfright">';
 
 1732    $morehtmlcenter = 
'';
 
 1735    include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
 
 1737    $morehtmlcenter = 
'';
 
 1738    $somethingshown = 
$formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, 
'', $MAXEVENT, 
'', $morehtmlcenter);
 
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
const STATUS_DRAFT
Draft status.
Class to manage a WYSIWYG editor.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard invoice.
Class to manage invoice lines of templates.
Class to manage invoice templates.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending   and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_info($titlealt='default')
Show info logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object informations.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.