diff --git a/.travis.yml b/.travis.yml index 718356e8075..1a6cae1e792 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ php: - '5.5' - '5.6' - '7.0' +- '7.1' - nightly addons: @@ -96,7 +97,7 @@ install: if [ "$TRAVIS_PHP_VERSION" = '5.3' ] || [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then composer -n require phpunit/phpunit ^4 fi - if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then composer -n require phpunit/phpunit ^5 fi echo @@ -136,7 +137,7 @@ before_script: echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini echo echo "Enabling Memcached for PHP <= 5.4" - # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0 and nightly! + # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1 and nightly! echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini fi phpenv rehash @@ -208,7 +209,7 @@ before_script: echo "Setting up Apache + FPM" # enable php-fpm cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then # Copy the included pool cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf fi diff --git a/htdocs/cashdesk/css/ticket.css b/htdocs/cashdesk/css/ticket.css new file mode 100644 index 00000000000..248e0f7b9b6 --- /dev/null +++ b/htdocs/cashdesk/css/ticket.css @@ -0,0 +1,61 @@ +/* + * TPV ticket.css + */ +body { + font-size: 1.5em; + position: relative; +} + +.entete { /* position: relative; */ + +} + +.address { /* float: left; */ + font-size: 12px; +} + +.date_heure { + position: absolute; + top: 0; + right: 0; + font-size: 16px; +} + +.infos { + position: relative; +} + +.liste_articles { + width: 100%; + border-bottom: 1px solid #000; + text-align: center; +} + +.liste_articles tr.titres th { + border-bottom: 1px solid #000; +} + +.liste_articles td.total { + text-align: right; +} + +.totaux { + margin-top: 20px; + width: 30%; + float: right; + text-align: right; +} + +.lien { + position: absolute; + top: 0; + left: 0; + display: none; +} + +@media print { + .lien { + display: none; + } +} + diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index 9ea8cb70943..78ce86f45f7 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -28,130 +28,84 @@ $object->fetch($facid); ?> - -<?php echo $langs->trans('PrintTicket') ?> - - - + + <?php echo $langs->trans('PrintTicket') ?> +
- -
-

name; ?>
-
-

+ +
+

name; ?>
+
+

-

'; -print $object->ref; -?>

-
+

'; + print $object->ref; + ?>

+

+ - - - - - + + + + + + + + '."\n"); + ?> + + + + + + + + + ?> +
trans("Code"); ?>trans("Label"); ?>trans("Qty"); ?>trans("Discount").' (%)'; ?>trans("TotalHT"); ?>trans("Code"); ?>trans("Label"); ?>trans("Qty"); ?>trans("Discount").' (%)'; ?>trans("TotalHT"); ?>
'.$tab[$i]['ref'].''.$tab[$i]['label'].''.$tab[$i]['qte'].''.$tab[$i]['remise_percent'].''.price(price2num($tab[$i]['total_ht'],'MT'),0,$langs,0,0,-1,$conf->currency).'
currency);?>
-\n"; -echo '\n"; -echo '\n"; -?> + + + + + + + + + +
'.$langs->trans("TotalHT").''.price(price2num($obj_facturation->prixTotalHt(),'MT'),'',$langs,0,-1,-1,$conf->currency)."
'.$langs->trans("TotalVAT").''.price(price2num($obj_facturation->montantTva(),'MT'),'',$langs,0,-1,-1,$conf->currency)."
'.$langs->trans("TotalTTC").''.price(price2num($obj_facturation->prixTotalTtc(),'MT'),'',$langs,0,-1,-1,$conf->currency)."
trans("TotalHT");?>prixTotalHt(),'MT'),'',$langs,0,-1,-1,$conf->currency)."\n";?>
trans("TotalVAT").''.price(price2num($obj_facturation->montantTva(),'MT'),'',$langs,0,-1,-1,$conf->currency)."\n";?>
trans("TotalTTC").''.price(price2num($obj_facturation->prixTotalTtc(),'MT'),'',$langs,0,-1,-1,$conf->currency)."\n";?>
-trans("Close"); ?> - +trans("Close"); ?> diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index f263763f7ab..3128a7612f5 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -919,7 +919,19 @@ if (empty($reshook)) else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); } } - + + /* + * Send mail + */ + + // Actions to send emails + $actiontypecode='AC_CONT'; + $trigger_name='CONTRACT_SENTBYMAIL'; + $paramname='id'; + $mode='emailfromcontract'; + $trackid='cont'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { if ($action == 'addcontact') @@ -2026,37 +2038,164 @@ else print ""; } + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } - print '
'; + if ($action != 'presend') + { + print '
'; - /* - * Documents generes - */ - $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->contrat->creer; - $delallowed = $user->rights->contrat->supprimer; + /* + * Documents generes + */ + $filename = dol_sanitizeFileName($object->ref); + $filedir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->contrat->creer; + $delallowed = $user->rights->contrat->supprimer; - $var = true; + $var = true; - print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - - - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - print '
'; + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'contract', $socid); + + + print '
'; + } + + /* + * Action presend + */ + if ($action == 'presend') + { + $object->fetch_projet(); + + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->contrat->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->thirdparty->default_lang; + + if (!empty($newlang)) + { + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->load('commercial'); + } + + // Build document if it not exists + if (! $file || ! is_readable($file)) { + $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { + dol_print_error($db, $object->error, $object->errors); + exit(); + } + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; + } + + print '
'; + print '
'; + print load_fiche_titre($langs->trans('SendOrderByMail')); + + dol_fiche_head(''); + + // Cree l'objet formulaire mail + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); + $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); + + if($formmail->fromtype === 'user'){ + $formmail->fromid = $user->id; + + } + $formmail->trackid='ord'.$object->id; + if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set + { + include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id); + } + $formmail->withfrom = 1; + $liste = array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) + $liste [$key] = $value; + $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; + $formmail->withtocc = $liste; + $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; + if (empty($object->ref_client)) { + $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); + } else if (! empty($object->ref_client)) { + $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); + } + $formmail->withfile = 2; + $formmail->withbody = 1; + $formmail->withdeliveryreceipt = 1; + $formmail->withcancel = 1; + // Tableau des substitutions + $formmail->setSubstitFromObject($object); + $formmail->substit ['__ORDERREF__'] = $object->ref; + + $custcontact = ''; + $contactarr = array(); + $contactarr = $object->liste_contact(- 1, 'external'); + + if (is_array($contactarr) && count($contactarr) > 0) + { + foreach ($contactarr as $contact) + { + if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { // TODO Use code and not label + $contactstatic = new Contact($db); + $contactstatic->fetch($contact ['id']); + $custcontact = $contactstatic->getFullName($langs, 1); + } + } + + if (! empty($custcontact)) { + $formmail->substit['__CONTACTCIVNAME__'] = $custcontact; + } + } + + // Tableau des parametres complementaires + $formmail->param['action'] = 'send'; + $formmail->param['models'] = 'order_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); + $formmail->param['orderid'] = $object->id; + $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; + + // Init list of files + if (GETPOST("mode") == 'init') { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file, basename($file), dol_mimetype($file)); + } + + // Show form + print $formmail->get_form(); + + dol_fiche_end(); + } - // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'contract', $socid); - - - print '
'; } } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 082089b429f..107111a8986 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1248,11 +1248,15 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl { if ($issupplierline) { - //$ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref - if (! empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) $ref_prodserv =$ref_supplier; - else $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref + if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) + $ref_prodserv = $ref_supplier; + elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) + $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; + else + $ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')'; } - else $ref_prodserv = $prodser->ref; // Show local ref only + else + $ref_prodserv = $prodser->ref; // Show local ref only if (! empty($libelleproduitservice)) $ref_prodserv .= " - "; } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b217d452a86..af4da616ce9 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -281,7 +281,14 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + if(!$user->rights->societe->client->voir) { + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; + if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : ''; + } + $this->export_sql_end[$r] .=')'; + } // Export list of contacts and attributes $r++; @@ -311,7 +318,14 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + if(!$user->rights->societe->client->voir) { + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; + if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) { + $subordinatesids = $user->getAllChildIds(); + $this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : ''; + } + $this->export_sql_end[$r] .=')'; + } // Imports diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index ea75f7eeab6..afc00b60225 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -342,11 +342,11 @@ if (empty($reshook)) $filename=array(); $filedir=array(); $mimetype=array(); // SUBJECT - $subject = $langs->trans("ExpenseReportWaitingForApproval"); + $subject = $langs->transnoentities("ExpenseReportWaitingForApproval"); // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); + $message = $langs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); // Rebuild pdf /* @@ -436,74 +436,83 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition - { - // Send mail + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_validator); + $emailTo = $destinataire->email; - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_validator); - $emailTo = $destinataire->email; + if ($emailTo) + { + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_author); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportWaitingForReApproval"); - if ($emailTo) + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $dateRefusEx = explode(" ",$object->date_refuse); + $message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link); + + // Rebuild pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF) + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) { - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais à re-approuver"; - - // CONTENT - $dateRefusEx = explode(" ",$object->date_refuse); - - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n"; - $message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n"; - $message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Génération du pdf avant attachement - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF) + // SEND + $result=$mailfile->sendfile(); + if ($result) { - // ATTACHMENT - $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf"); - array_push($mimetype,"application/pdf"); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if (! $mailfile->error) + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $mesg=$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - // END - Send mail + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); } else { - dol_print_error($db,$resultPDF); - exit; + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); } } } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } + } + else + { + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } else @@ -542,80 +551,89 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition - { - // Send mail + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // CC + $emailCC = $conf->global->NDF_CC_EMAILS; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_valid); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportApproved"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); + + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // CC - $emailCC = $conf->global->NDF_CC_EMAILS; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_valid); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais validée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être approuvé!\n"; - $message.= "- Approbateur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Génération du pdf avant attachement - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF): - // ATTACHMENT - $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir, $conf->expensereport->dir_output. - "/". - dol_sanitizeFileName($object->ref) . - "/". - dol_sanitizeFileName($object->ref). - ".pdf" - ); - array_push($mimetype,"application/pdf"); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename,$emailCC); - - if(!$mailfile->error): - - // SEND - $result=$mailfile->sendfile(); - if ($result): - setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs'); - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - else: - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - endif; - - else: - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - endif; - // END - Send mail - else : // if ($resultPDF) - dol_print_error($db,$resultPDF); - exit; - endif; - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + if($resultPDF + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } + } + else + { + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->approve) { @@ -646,57 +664,86 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_refuse); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportRefused"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link); + + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_refuse); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais refusée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être refusée.\n"; - $message.= "- Refuseur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Motif de refus : {$_POST['detail_refuse']}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error) + // SEND + $result=$mailfile->sendfile(); + if ($result) { - // SEND - $result=$mailfile->sendfile(); - if ($result) + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) { - setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs'); - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); } else { - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); } - // END - Send mail } } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } //var_dump($user->id == $object->fk_user_validator);exit; if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_cancel') && $id > 0 && $user->rights->expensereport->creer) @@ -730,64 +777,85 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_cancel); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportCanceled"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_cancel'], $link); + + // Rebuilt pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref)."/".dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); + } + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_cancel); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais annulée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être annulée.\n"; - $message.= "- Annuleur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Motif d'annulation : {$_POST['detail_cancel']}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error) + // SEND + $result=$mailfile->sendfile(); + if ($result) { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $mesg="Impossible d'envoyer l'email."; - setEventMessages($mesg, null, 'errors'); - } - // END - Send mail + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; } else { - setEventMessages($mail->error, $mail->errors, 'errors'); + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } } } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } else { - setEventMessages($langs->transnoentitiesnoconv("OnlyOwnerCanCancel"), '', 'errors'); // Should not happened + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -864,68 +932,83 @@ if (empty($reshook)) if ($result > 0) { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($user->id); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = $langs->transnoentities("ExpenseReportPaid"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; + $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // Generate pdf before attachment + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($user->id); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "'ERP - Note de frais payée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; - $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Generate pdf before attachment - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error): - // SEND - $result=$mailfile->sendfile(); - if ($result): - - // Retour - if($result): - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; - else: - dol_print_error($db); - endif; - - else: - dol_print_error($db,$acct->error); - endif; - - else: - $mesg="Impossible d'envoyer l'email."; - setEventMessages($mesg, null, 'errors'); - endif; - // END - Send mail + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
'.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; } } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; } } - + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + if ($action == "addline" && $user->rights->expensereport->creer) { $error = 0; diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 9cb992f6af3..ac650ab98c7 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -21,7 +21,17 @@ ListToApprove=Waiting for approval ExpensesArea=Expense reports area ClassifyRefunded=Classify 'Refunded' ExpenseReportWaitingForApproval=A new expense report has been submitted for approval -ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n- User: %s\n- Period: %s\nClick here to validate: %s +ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n - User: %s\n - Period: %s\nClick here to validate: %s +ExpenseReportWaitingForReApproval=An expense report has been submitted for re-approval +ExpenseReportWaitingForReApprovalMessage=An expense report has been submitted and is waiting for re-approval.\nThe %s, you refused to approve the expense report for this reason: %s.\nA new version has been proposed and waiting for your approval.\n - User: %s\n - Period: %s\nClick here to validate: %s +ExpenseReportApproved=An expense report was approved +ExpenseReportApprovedMessage=The expense report %s was approved.\n - User: %s\n - Approved by: %s\nClick here to show the expense report: %s +ExpenseReportRefused=An expense report was refused +ExpenseReportRefusedMessage=The expense report %s was refused.\n - User: %s\n - Refused by: %s\n - Motive for refusal: %s\nClick here to show the expense report: %s +ExpenseReportCanceled=An expense report was canceled +ExpenseReportCanceledMessage=The expense report %s was canceled.\n - User: %s\n - Canceled by: %s\n - Motive for cancellation: %s\nClick here to show the expense report: %s +ExpenseReportPaid=An expense report was paid +ExpenseReportPaidMessage=The expense report %s was paid.\n - User: %s\n - Paid by: %s\nClick here to show the expense report: %s TripId=Id expense report AnyOtherInThisListCanValidate=Person to inform for validation. TripSociete=Information company diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index d6b7a40ae30..84fbca27f3c 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -99,17 +99,7 @@ if (empty($reshook)) $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); $capital = price2num(GETPOST('capital')); - if (! $datestart) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors'); - $action = 'create'; - } - elseif (! $dateend) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); - $action = 'create'; - } - elseif (! $capital) + if (! $capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); $action = 'create'; @@ -155,13 +145,31 @@ if (empty($reshook)) if (! $cancel) { $result = $object->fetch($id); - if ($result > 0) + + $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); + $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); + $capital = price2num(GETPOST('capital')); + + if (! $capital) { - $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); - $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); - $object->capital = price2num(GETPOST("capital")); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); + $action = 'edit'; + } + else + { + $object->datestart = $datestart; + $object->dateend = $dateend; + $object->capital = $capital; $object->nbterm = GETPOST("nbterm"); $object->rate = GETPOST("rate"); + + $accountancy_account_capital = GETPOST('accountancy_account_capital'); + $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); + $accountancy_account_interest = GETPOST('accountancy_account_interest'); + + if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } + if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } + if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } } $result = $object->update($user); @@ -255,21 +263,21 @@ if ($action == 'create') // Date Start print ""; - print ''.$langs->trans("DateStart").''; + print ''.$langs->trans("DateStart").''; print $form->select_date($datestart?$datestart:-1,'start','','','','add',1,1,1); print ''; // Date End print ""; - print ''.$langs->trans("DateEnd").''; + print ''.$langs->trans("DateEnd").''; print $form->select_date($dateend?$dateend:-1,'end','','','','add',1,1,1); print ''; // Number of terms - print ''.$langs->trans("Nbterms").''; + print ''.$langs->trans("Nbterms").''; // Rate - print ''.$langs->trans("Rate").' %'; + print ''.$langs->trans("Rate").' %'; // Project if (! empty($conf->projet->enabled)) @@ -308,19 +316,19 @@ if ($action == 'create') if (! empty($conf->accounting->enabled)) { // Accountancy_account_capital - print ''.$langs->trans("LoanAccountancyCapitalCode").''; + print ''.$langs->trans("LoanAccountancyCapitalCode").''; print ''; print $formaccountancy->select_account($object->accountancy_account_capital, 'accountancy_account_capital', 1, '', 0, 1); print ''; // Accountancy_account_insurance - print ''.$langs->trans("LoanAccountancyInsuranceCode").''; + print ''.$langs->trans("LoanAccountancyInsuranceCode").''; print ''; print $formaccountancy->select_account($object->accountancy_account_insurance, 'accountancy_account_insurance', 1, '', 0, 1); print ''; // Accountancy_account_interest - print ''.$langs->trans("LoanAccountancyInterestCode").''; + print ''.$langs->trans("LoanAccountancyInterestCode").''; print ''; print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1); print ''; @@ -328,17 +336,17 @@ if ($action == 'create') else // For external software { // Accountancy_account_capital - print ''.$langs->trans("LoanAccountancyCapitalCode").''; + print ''.$langs->trans("LoanAccountancyCapitalCode").''; print ''; print ''; // Accountancy_account_insurance - print ''.$langs->trans("LoanAccountancyInsuranceCode").''; + print ''.$langs->trans("LoanAccountancyInsuranceCode").''; print ''; print ''; // Accountancy_account_interest - print ''.$langs->trans("LoanAccountancyInterestCode").''; + print ''.$langs->trans("LoanAccountancyInterestCode").''; print ''; print ''; } @@ -398,7 +406,7 @@ if ($id > 0) // Ref loan $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); - // Project + // Project if (! empty($conf->projet->enabled)) { $langs->load("projects"); @@ -442,29 +450,10 @@ if ($id > 0) print ''; - /* - // Ref - print '"; - - // Label - if ($action == 'edit') - { - print ''; - } - else - { - print ''; - } - */ - // Capital if ($action == 'edit') { - print ''; print ''; } @@ -500,19 +489,53 @@ if ($id > 0) print ""; // Nbterms - print ''; + print ''.$langs->trans("Nbterms").''; + print ''; // Rate - print ''; + print ''.$langs->trans("Rate").''; + print ''; // Accountancy account capital print ''; @@ -520,10 +543,24 @@ if ($id > 0) print ''; @@ -531,17 +568,27 @@ if ($id > 0) print ''; - - // Status - // print ''; - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'id'); - print "
'.$langs->trans("Label").''; - print ''; - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("LoanCapital").''; + print '
'.$langs->trans("LoanCapital").''; print '
'.$langs->trans("Nbterms").''.$object->nbterm.'
'; + if ($action == 'edit') + { + print ''; + } + else + { + print $object->nbterm; + } + print '
'.$langs->trans("Rate").''.$object->rate.' %
'; + if ($action == 'edit') + { + print '%'; + } + else + { + print $object->rate . '%'; + } + print '
'; print $langs->trans("LoanAccountancyCapitalCode"); print ''; - if (! empty($conf->accounting->enabled)) { - print length_accountg($object->account_capital); - } else { - print $object->account_capital; + if ($action == 'edit') + { + if (! empty($conf->accounting->enabled)) + { + print $formaccountancy->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 0, 1); + } + else + { + print ''; + } + } + else + { + if (! empty($conf->accounting->enabled)) { + print length_accountg($object->account_capital); + } else { + print $object->account_capital; + } } print '
'; print $langs->trans("LoanAccountancyInsuranceCode"); print ''; - if (! empty($conf->accounting->enabled)) { - print length_accountg($object->account_insurance); - } else { - print $object->account_insurance; + if ($action == 'edit') + { + if (! empty($conf->accounting->enabled)) + { + print $formaccountancy->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 0, 1); + } + else + { + print ''; + } + } + else + { + if (! empty($conf->accounting->enabled)) { + print length_accountg($object->account_insurance); + } else { + print $object->account_insurance; + } } print '
'; print $langs->trans("LoanAccountancyInterestCode"); print ''; - if (! empty($conf->accounting->enabled)) { - print length_accountg($object->account_interest); - } else { - print $object->account_interest; + if ($action == 'edit') + { + if (! empty($conf->accounting->enabled)) + { + print $formaccountancy->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 0, 1); + } + else + { + print ''; + } + } + else + { + if (! empty($conf->accounting->enabled)) { + print length_accountg($object->account_interest); + } else { + print $object->account_interest; + } } print '
'.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).'
'; print '';