From 507d96ec2504c40deb927686c4bd15ee938da131 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 Jul 2008 12:45:29 +0000 Subject: [PATCH] Fix: Error on generating PDF --- htdocs/comm/propal.php | 1008 +++++++++-------- htdocs/commande/fiche.php | 867 +++++++------- htdocs/compta/facture.php | 7 + htdocs/fichinter/fiche.php | 326 +++--- htdocs/fichinter/fichinter.class.php | 22 +- .../modules/fichinter/modules_fichinter.php | 4 +- .../modules/fichinter/pdf_soleil.modules.php | 11 +- 7 files changed, 1151 insertions(+), 1094 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 80b8656623c..5b2f8d34d5f 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -22,11 +22,11 @@ */ /** - \file htdocs/comm/propal.php - \ingroup propale - \brief Page liste des propales (vision commercial) - \version $Id$ -*/ + \file htdocs/comm/propal.php + \ingroup propale + \brief Page liste des propales (vision commercial) + \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); @@ -79,57 +79,57 @@ $NBLINES=4; // Suppression de la propale if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') { - if ($user->rights->propale->supprimer) - { - $propal = new Propal($db, 0, $_GET['propalid']); - $propal->fetch($_GET['propalid']); - $propal->delete($user); - $propalid = 0; - $brouillon = 1; - } - Header('Location: '.$_SERVER["PHP_SELF"]); - exit; + if ($user->rights->propale->supprimer) + { + $propal = new Propal($db, 0, $_GET['propalid']); + $propal->fetch($_GET['propalid']); + $propal->delete($user); + $propalid = 0; + $brouillon = 1; + } + Header('Location: '.$_SERVER["PHP_SELF"]); + exit; } /* * Supprime une ligne produit AVEC OU SANS confirmation */ if (($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) - || ($_GET['action'] == 'deleteline' && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE)) +|| ($_GET['action'] == 'deleteline' && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE)) { if ($user->rights->propale->creer) - { - $propal = new Propal($db); - $propal->fetch($_GET['propalid']); - $result = $propal->delete_product($_GET['lineid']); - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); + { + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + $result = $propal->delete_product($_GET['lineid']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); } Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$_GET['propalid']); - exit; + exit; } // Validation de la propale if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' && $user->rights->propale->valider) { - $propal = new Propal($db); - $propal->fetch($_GET['propalid']); + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); $propal->fetch_client(); - - $result=$propal->valid($user); + + $result=$propal->valid($user); if ($result >= 0) { - if ($_REQUEST['lang_id']) + if ($_REQUEST['lang_id']) { $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); - } + propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); + } else { $mesg='
'.$fac->error.'
'; @@ -139,14 +139,14 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' & if ($_POST['action'] == 'setecheance') { $propal = new Propal($db); - $propal->fetch($_GET['propalid']); + $propal->fetch($_GET['propalid']); $result=$propal->set_echeance($user,dolibarr_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); if ($result < 0) dolibarr_print_error($db,$propal->error); } if ($_POST['action'] == 'setdate_livraison') { $propal = new Propal($db); - $propal->fetch($_GET['propalid']); + $propal->fetch($_GET['propalid']); $result=$propal->set_date_livraison($user,dolibarr_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); if ($result < 0) dolibarr_print_error($db,$propal->error); } @@ -175,9 +175,9 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) $propal = new Propal($db); $propal->socid=$_POST['socid']; $propal->fetch_client(); - + $db->begin(); - + // Si on a selectionne une propal a copier, on realise la copie if($_POST['createmode']=='copy' && $_POST['copie_propal']) { @@ -199,7 +199,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) $propal->note = $_POST['note']; $propal->ref = $_POST['ref']; $propal->statut = 0; - + $id = $propal->create_from($user); } else @@ -215,7 +215,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) $propal->duree_validite = $_POST['duree_validite']; $propal->cond_reglement_id = $_POST['cond_reglement_id']; $propal->mode_reglement_id = $_POST['mode_reglement_id']; - + $propal->contactid = $_POST['contactidp']; $propal->projetidp = $_POST['projetidp']; $propal->modelpdf = $_POST['model']; @@ -223,7 +223,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) $propal->note = $_POST['note']; $propal->ref_client = $_POST['ref_client']; $propal->ref = $_POST['ref']; - + for ($i = 1 ; $i <= $conf->global->PROPALE_NEW_FORM_NB_PRODUCT ; $i++) { if ($_POST['idprod'.$i]) @@ -234,10 +234,10 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) $propal->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); } } - + $id = $propal->create(); } - + if ($id > 0) { $error=0; @@ -291,15 +291,15 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer) */ if ($_REQUEST['action'] == 'setstatut' && $user->rights->propale->cloturer) { - if (! $_POST['cancel']) - { - $propal = new Propal($db); - $propal->fetch($_GET['propalid']); + if (! $_POST['cancel']) + { + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); // prevent browser refresh from closing proposal several times - if ($propal->statut==1) + if ($propal->statut==1) { - $propal->cloture($user, $_REQUEST['statut'], $_REQUEST['note']); - } + $propal->cloture($user, $_REQUEST['statut'], $_REQUEST['note']); + } } } @@ -312,30 +312,30 @@ if ($_POST['addfile']) // Set tmp user directory $conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id; $upload_dir = $conf->users->dir_tmp.'/temp/'; - + if (! empty($_FILES['addedfile']['tmp_name'])) { - if (! is_dir($upload_dir)) create_exdir($upload_dir); - - if (is_dir($upload_dir)) - { - if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0) - { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; - //print_r($_FILES); + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); $formmail = new FormMail($db); // Add file in list of files in session $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); - } - else - { - // Echec transfert (fichier dépassant la limite ?) - $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; - // print_r($_FILES); - } - } + } + else + { + // Echec transfert (fichier dépassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } } $_GET["action"]='presend'; } @@ -345,18 +345,18 @@ if ($_POST['addfile']) */ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) { - $langs->load('mails'); + $langs->load('mails'); + + $propal= new Propal($db); + if ( $propal->fetch($_POST['propalid']) ) + { + $propalref = sanitize_string($propal->ref); + $file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf'; + + if (is_readable($file)) + { + $propal->fetch_client(); - $propal= new Propal($db); - if ( $propal->fetch($_POST['propalid']) ) - { - $propalref = sanitize_string($propal->ref); - $file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf'; - - if (is_readable($file)) - { - $propal->fetch_client(); - if ($_POST['sendto']) { // Le destinataire a ete fourni via le champ libre @@ -378,22 +378,22 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) } } - if (strlen($sendto)) - { + if (strlen($sendto)) + { $langs->load("commercial"); - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; - $message = $_POST['message']; - $sendtocc = $_POST['sendtocc']; - $deliveryreceipt = $_POST['deliveryreceipt']; + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; + $deliveryreceipt = $_POST['deliveryreceipt']; - if ($_POST['action'] == 'send') - { - if (strlen($_POST['subject'])) $subject = $_POST['subject']; - else $subject = $langs->transnoentities('Propal').' '.$propal->ref; + if ($_POST['action'] == 'send') + { + if (strlen($_POST['subject'])) $subject = $_POST['subject']; + else $subject = $langs->transnoentities('Propal').' '.$propal->ref; $actiontypecode='AC_PROP'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; if ($message) { $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; @@ -401,20 +401,20 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) $actionmsg.=$message; } $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } + } // Create form object include_once('../html.formmail.class.php'); $formmail = new FormMail($db); $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - // Envoi de la propal + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Envoi de la propal require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); if ($mailfile->error) { $mesg='
'.$mailfile->error.'
'; @@ -424,17 +424,17 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) $result=$mailfile->sendfile(); if ($result) { - $mesg='
'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.
'; - + $mesg='
'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.
'; + $error=0; - - // Initialisation donnees + + // Initialisation donnees $propal->sendtoid=$sendtoid; $propal->actiontypecode=$actiontypecode; $propal->actionmsg = $actionmsg; $propal->actionmsg2= $actionmsg2; $propal->propalrowid=$propal->id; - + // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); $interface=new Interfaces($db); @@ -442,23 +442,23 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - if ($error) - { - dolibarr_print_error($db); - } - else - { + if ($error) + { + dolibarr_print_error($db); + } + else + { // Redirect here // This avoid sending mail twice if going out and then back to page - Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($mesg)); - exit; - } + Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($mesg)); + exit; + } } - else - { + else + { $langs->load("other"); $mesg='
'; - if ($mailfile->error) + if ($mailfile->error) { $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); $mesg.='
'.$mailfile->error; @@ -469,57 +469,65 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) } $mesg.='
'; } - } - } - else - { + } + } + else + { $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; dolibarr_syslog('Recipient email is empty'); - } - } - else - { + } + } + else + { $langs->load("other"); $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; dolibarr_syslog('Failed to read file: '.$file); - } - } - else - { + } + } + else + { $langs->load("other"); $mesg='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")).'
'; dolibarr_syslog('Impossible de lire les donnees de la facture. Le fichier propal n\'a peut-etre pas ete genere.'); - } + } } if ($_GET['action'] == 'commande') { - /* - * Cloture de la propale - */ - $propal = new Propal($db); - $propal->fetch($propalid); - $propal->create_commande($user); + /* + * Cloture de la propale + */ + $propal = new Propal($db); + $propal->fetch($propalid); + $propal->create_commande($user); } if ($_GET['action'] == 'modif' && $user->rights->propale->creer) { - /* - * Repasse la propale en mode brouillon - */ - $propal = new Propal($db); - $propal->fetch($_GET['propalid']); - $propal->set_draft($user); + /* + * Repasse la propale en mode brouillon + */ + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + $propal->set_draft($user); + + //regénération pdf + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); } if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer) { if ($_POST["remise_id"]) { - $prop = new Propal($db); - $prop->id=$_GET['propalid']; - $ret=$prop->fetch($_GET['propalid']); + $prop = new Propal($db); + $prop->id=$_GET['propalid']; + $ret=$prop->fetch($_GET['propalid']); if ($ret > 0) { $result=$prop->insert_discount($_POST["remise_id"]); @@ -550,7 +558,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer) exit; } $ret=$propal->fetch_client(); - + $price_base_type = 'HT'; // Ecrase $pu par celui du produit @@ -560,10 +568,10 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer) { $prod = new Product($db, $_POST['idprod']); $prod->fetch($_POST['idprod']); - + $tva_tx = get_default_tva($mysoc,$propal->client,$prod->tva_tx); $tva_npr = get_default_npr($mysoc,$propal->client,$prod->tva_tx); - + // On defini prix unitaire if ($conf->global->PRODUIT_MULTIPRICES == 1) { @@ -591,7 +599,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer) $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } } - + $desc = $prod->description; $desc.= ($prod->description && $_POST['np_desc']) ? "\n" : ""; $desc.= $_POST['np_desc']; @@ -599,26 +607,26 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer) else { $pu_ht=$_POST['np_price']; - $tva_tx=eregi_replace('\*','',$_POST['np_tva_tx']); + $tva_tx=eregi_replace('\*','',$_POST['np_tva_tx']); $tva_npr=eregi('\*',$_POST['np_tva_tx'])?1:0; $desc=$_POST['dp_desc']; } $info_bits=0; if ($tva_npr) $info_bits |= 0x01; - + // Insert line $result=$propal->addline( - $_POST['propalid'], - $desc, - $pu_ht, - $_POST['qty'], - $tva_tx, - $_POST['idprod'], - $_POST['remise_percent'], - $price_base_type, - $pu_ttc, - $info_bits + $_POST['propalid'], + $desc, + $pu_ht, + $_POST['qty'], + $tva_tx, + $_POST['idprod'], + $_POST['remise_percent'], + $price_base_type, + $pu_ttc, + $info_bits ); if ($result > 0) @@ -632,9 +640,9 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer) } else { - $mesg='
'.$propal->error.'
'; + $mesg='
'.$propal->error.'
'; } - + } } @@ -643,7 +651,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer) */ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) { - $propal = new Propal($db); + $propal = new Propal($db); if (! $propal->fetch($_POST['propalid']) > 0) dolibarr_print_error($db); // Define info_bits @@ -653,22 +661,22 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST // Define vat_rate $vat_rate=$_POST['tva_tx']; $vat_rate=eregi_replace('\*','',$vat_rate); - + $result = $propal->updateline($_POST['lineid'], - $_POST['subprice'], - $_POST['qty'], - $_POST['remise_percent'], - $vat_rate, - $_POST['desc'], + $_POST['subprice'], + $_POST['qty'], + $_POST['remise_percent'], + $vat_rate, + $_POST['desc'], 'HT', - $info_bits); + $info_bits); if ($_REQUEST['lang_id']) { $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); + propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); } /* @@ -676,13 +684,13 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST */ if ($_REQUEST['action'] == 'builddoc' && $user->rights->propale->creer) { - $propal = new Propal($db); - $propal->fetch($_GET['propalid']); - if ($_REQUEST['model']) - { - $propal->setDocModel($user, $_REQUEST['model']); - } - + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + if ($_REQUEST['model']) + { + $propal->setDocModel($user, $_REQUEST['model']); + } + if ($_REQUEST['lang_id']) { $outputlangs = new Translate("",$conf); @@ -698,7 +706,7 @@ if ($_REQUEST['action'] == 'builddoc' && $user->rights->propale->creer) { Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'#builddoc'); exit; - } + } } if ($_POST['action'] == 'classin') @@ -756,7 +764,7 @@ if ($_GET['action'] == 'up' && $user->rights->propale->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); + propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$_GET["propalid"].'#'.$_GET['rowid']); } @@ -770,15 +778,15 @@ if ($_GET['action'] == 'down' && $user->rights->propale->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); + propale_pdf_create($db, $propal->id, $propal->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$_GET["propalid"].'#'.$_GET['rowid']); exit; } /* -* Affichage page -*/ + * Affichage page + */ llxHeader('',$langs->trans('Proposal'),'Proposition'); @@ -791,86 +799,86 @@ if ($_GET['propalid'] > 0) * Affichage fiche propal en mode visu * */ - - if ($mesg) print "$mesg
"; - - $propal = new Propal($db); - $propal->fetch($_GET['propalid']); - $societe = new Societe($db); - $societe->fetch($propal->socid); - - $head = propal_prepare_head($propal); - dolibarr_fiche_head($head, 'comm', $langs->trans('Proposal')); - - /* - * Confirmation de la suppression de la propale - */ - if ($_GET['action'] == 'delete') - { - $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete'); - print '
'; - } - - /* - * Confirmation de la suppression d'une ligne produit/service - */ - if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) - { - $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline'); - print '
'; - } - - /* - * Confirmation de la validation de la propale - */ - if ($_GET['action'] == 'validate') - { - $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate'); - print '
'; - } - - - /* - * Fiche propal - * - */ - - print ''; - - // Ref - print ''; - - // Ref client - print ''; - print ''; - - $rowspan=8; - - // Societe - print ''; - print ''; - - // Ligne info remises tiers + if ($mesg) print "$mesg
"; + + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); + + $societe = new Societe($db); + $societe->fetch($propal->socid); + + $head = propal_prepare_head($propal); + dolibarr_fiche_head($head, 'comm', $langs->trans('Proposal')); + + /* + * Confirmation de la suppression de la propale + */ + if ($_GET['action'] == 'delete') + { + $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete'); + print '
'; + } + + /* + * Confirmation de la suppression d'une ligne produit/service + */ + if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) + { + $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline'); + print '
'; + } + + /* + * Confirmation de la validation de la propale + */ + if ($_GET['action'] == 'validate') + { + $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate'); + print '
'; + } + + + /* + * Fiche propal + * + */ + + print '
'.$langs->trans('Ref').''.$propal->ref.'
'; - print ''; - if ($_GET['action'] != 'refclient' && $propal->brouillon) print ''; - print '
'; - print $langs->trans('RefCustomer').''; - print ''.img_edit($langs->trans('Modify')).'
'; - print '
'; - if ($user->rights->propale->creer && $_GET['action'] == 'refclient') - { - print '
'; - print ''; - print ''; - print ' '; - print '
'; - } - else - { - print $propal->ref_client; - } - print '
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'; + + // Ref + print ''; + + // Ref client + print ''; + print ''; + + $rowspan=8; + + // Societe + print ''; + print ''; + + // Ligne info remises tiers print ''; print ''; @@ -1102,7 +1110,7 @@ if ($_GET['propalid'] > 0) print ''; print ''; print ''; - + // Amount TTC print ''; print ''; @@ -1158,7 +1166,7 @@ if ($_GET['propalid'] > 0) if ($_GET['action'] != 'editline' || $_GET['lineid'] != $objp->rowid) { print ''; - + // Produit if ($objp->fk_product > 0) { @@ -1178,7 +1186,7 @@ if ($_GET['propalid'] > 0) { print ($objp->description && $objp->description!=$objp->product)?'
'.dol_htmlentitiesbr($objp->description):''; } - + print ''; } else @@ -1237,14 +1245,14 @@ if ($_GET['propalid'] > 0) //$formMarkup.= '   '."\n"; $formMarkup.= '
'.$langs->trans('Ref').''.$propal->ref.'
'; + print ''; + if ($_GET['action'] != 'refclient' && $propal->brouillon) print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print ''.img_edit($langs->trans('Modify')).'
'; + print '
'; + if ($user->rights->propale->creer && $_GET['action'] == 'refclient') + { + print '
'; + print ''; + print ''; + print ' '; + print '
'; + } + else + { + print $propal->ref_client; + } + print '
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$langs->trans('Discounts').''; if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); @@ -909,7 +917,7 @@ if ($_GET['propalid'] > 0) if ($conf->global->PROPALE_ADD_SHIPPING_DATE || !$conf->commande->enabled) $rowspan++; if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS || !$conf->commande->enabled) $rowspan++; } - + // Notes print ''.$langs->trans('NotePublic').' :
'. nl2br($propal->note_public).'
'.$langs->trans('AmountVAT').''.price($propal->total_tva).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($propal->total_ttc).'
'."\n"; $formMarkup.= ajax_updaterWithID("rate".$i,"markup","sellingprice_ht".$i,"/product/ajaxproducts.php","&count=".$i,"working")."\n"; - + print ''."\n"; - + print ''."\n"; - + print ''; print ''; - print ''; + print ''; print '
'; @@ -1260,14 +1268,14 @@ if ($_GET['propalid'] > 0) print $html->textwithtooltip($picto,$langs->trans("ToCalculateMarkup"),3,'','',$i); } print ''.vatrate($objp->marge_tx).'% '.vatrate($objp->marge_tx).'%
'; print ''; } - + // VAT Rate print ''.vatrate($objp->tva_tx,'%',$objp->info_bits).''; - + // U.P HT print ''.price($objp->subprice)."\n"; @@ -1279,7 +1287,7 @@ if ($_GET['propalid'] > 0) } else print ' '; print ''; - + // Remise % if ($objp->remise_percent > 0 && $objp->special_code != 3) { @@ -1289,7 +1297,7 @@ if ($_GET['propalid'] > 0) { print ' '; } - + // Montant total HT if ($objp->special_code == 3) { @@ -1395,7 +1403,7 @@ if ($_GET['propalid'] > 0) } } print ''; - if ($conf->global->PRODUIT_USE_MARKUP) + if ($conf->global->PRODUIT_USE_MARKUP) { print ''.vatrate($objp->marge_tx).'%'; } @@ -1421,17 +1429,17 @@ if ($_GET['propalid'] > 0) print '
'; print '' . "\n"; /* - if ($conf->service->enabled) - { - print ""; - print 'Si produit de type service a duree limitee: Du '; - print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1); - print ' au '; - print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1); - print ''; - print '' . "\n"; - } - */ + if ($conf->service->enabled) + { + print ""; + print 'Si produit de type service a duree limitee: Du '; + print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1); + print ' au '; + print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1); + print ''; + print '' . "\n"; + } + */ print "\n"; } @@ -1446,8 +1454,8 @@ if ($_GET['propalid'] > 0) } /* - * Ajouter une ligne - */ + * Ajouter une ligne + */ if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') { if ($conf->global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"'; @@ -1513,20 +1521,20 @@ if ($_GET['propalid'] > 0) $colspan = 'colspan="3"'; } print ''; - print ''; - if ($conf->service->enabled) - { - print $langs->trans('RecordedProductsAndServices'); - } - else - { - print $langs->trans('RecordedProducts'); - } - print ''; - print ''.$langs->trans('Qty').''; - print ''.$langs->trans('ReductionShort').''; - print ' '; - print ''; + print ''; + if ($conf->service->enabled) + { + print $langs->trans('RecordedProductsAndServices'); + } + else + { + print $langs->trans('RecordedProducts'); + } + print ''; + print ''.$langs->trans('Qty').''; + print ''.$langs->trans('ReductionShort').''; + print ' '; + print ''; print '
'; print ''; print ''; @@ -1545,7 +1553,7 @@ if ($_GET['propalid'] > 0) $html->select_produits('','idprod','',$conf->produit->limit_size); } if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; - + // editeur wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { @@ -1575,8 +1583,8 @@ if ($_GET['propalid'] > 0) print "\n"; /* - * Formulaire cloture (signe ou non) - */ + * Formulaire cloture (signe ou non) + */ $form_close = ''; $form_close.= ''; $form_close.= ''; - + // Note privée if (! $user->societe_id) { @@ -928,7 +939,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) print ''; } - + if ($propalid > 0) { $amount = ($obj->price); @@ -938,7 +949,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) print ''."\n"; print ''."\n"; print ''; - + print ''; print ''; print ''; @@ -949,12 +960,12 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) { /* - * Services/produits predefinis - */ + * Services/produits predefinis + */ $NBLINES=8; - + print '
'.$langs->trans('Note').'
'.$langs->trans('Ref').''.$obj->ref.'
'.$langs->trans('TotalTTC').''.price($amount).'
'.$langs->trans('VAT').''.price($obj->tva).'
'; - + print ''; print ''; print ''; @@ -979,8 +990,8 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) } /* - * - */ + * + */ print ''; print '
'.$langs->trans('ProductsAndServices').''.$langs->trans('Qty').'
'; @@ -989,8 +1000,8 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) if ($propalid) { /* - * Produits - */ + * Produits + */ print_titre($langs->trans('Products')); print ''; print ''; @@ -1057,99 +1068,99 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) } else { - /* *************************************************************************** */ - /* */ - /* Mode vue et edition */ - /* */ - /* *************************************************************************** */ - $id = $_GET['id']; - if ($id > 0) - { - if ($mesg) print $mesg.'
'; - - $commande = new Commande($db); - if ( $commande->fetch($_GET['id']) > 0) + /* *************************************************************************** */ + /* */ + /* Mode vue et edition */ + /* */ + /* *************************************************************************** */ + $id = $_GET['id']; + if ($id > 0) { + if ($mesg) print $mesg.'
'; + + $commande = new Commande($db); + if ( $commande->fetch($_GET['id']) > 0) + { $soc = new Societe($db); $soc->fetch($commande->socid); - + $author = new User($db); $author->id = $commande->user_author_id; $author->fetch(); - + $head = commande_prepare_head($commande); dolibarr_fiche_head($head, 'order', $langs->trans("CustomerOrder")); - + /* * Confirmation de la suppression de la commande */ if ($_GET['action'] == 'delete') - { - $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete'); - print '
'; - } - + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete'); + print '
'; + } + /* * Confirmation de la validation */ if ($_GET['action'] == 'validate') { // on verifie si la facture est en numerotation provisoire - $ref = substr($commande->ref, 1, 4); - if ($ref == 'PROV') - { - $num = $commande->getNextNumRef($soc); - } - else - { - $num = $commande->ref; - } - - $text=$langs->trans('ConfirmValidateOrder',$num); - $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_validate'); - print '
'; + $ref = substr($commande->ref, 1, 4); + if ($ref == 'PROV') + { + $num = $commande->getNextNumRef($soc); + } + else + { + $num = $commande->ref; + } + + $text=$langs->trans('ConfirmValidateOrder',$num); + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_validate'); + print '
'; } - + /* * Confirmation de la cloture */ if ($_GET['action'] == 'close') - { - $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close'); - print '
'; - } - + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close'); + print '
'; + } + /* * Confirmation de l'annulation */ if ($_GET['action'] == 'cancel') - { - $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel'); - print '
'; - } - + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel'); + print '
'; + } + /* * Confirmation de la suppression d'une ligne produit */ if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) - { - $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline'); - print '
'; - } - + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline'); + print '
'; + } + /* * Commande */ $nbrow=8; if ($conf->projet->enabled) $nbrow++; - + print '
'.$langs->trans('Ref').''.$langs->trans('Product').'
'; - + // Ref print ''; print ''; print ''; - + // Ref commande client print ''; print ''; - + // Societe print ''; @@ -1290,7 +1301,7 @@ else $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'none'); } print ''; - + //Note public lorsque le module expedition n'est pas active if (!$conf->projet->enabled) $nbrow--; if (!$conf->expedition->enabled) @@ -1301,7 +1312,7 @@ else print nl2br($commande->note_public); print ''; } - + print ''; print ''; + } + + // Model + print ''; + print ''; + print '"; + + print ''; + print "'; - } - // Model - print ''; - print ''; - print '"; + print ''; - print ''; - print "'; - - print ''; - - print '
'.$langs->trans('Ref').''.$commande->ref.'
'; print '
'; @@ -1159,20 +1170,20 @@ else print '
'; print '
'; if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder') - { - print ''; - print ''; - print ''; - print ' '; - print ''; - } + { + print '
'; + print ''; + print ''; + print ' '; + print '
'; + } else - { - print $commande->ref_client; - } + { + print $commande->ref_client; + } print '
'.$langs->trans('Company').'
'; print ''; @@ -1676,60 +1687,60 @@ else print ''; print ''; print ''; - + print ''; print ''; print ''; - $var=!$var; - print ''; - print ''; + print ''; - print ''; - print ''; - print ''; - print ''; + if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; - print ''; - } + // editeur wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('np_desc','',100,'dolibarr_details'); + $doleditor->Create(); + } + else + { + print ''; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + } } print '
'; @@ -1366,8 +1377,8 @@ else print "\n"; /* - * Lignes de commandes - */ + * Lignes de commandes + */ $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, '; $sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,'; $sql.= ' l.total_ht, l.total_tva, l.total_ttc,'; @@ -1600,7 +1611,7 @@ else $i++; } $db->free($resql); - + $numlines=$num; } else @@ -1609,8 +1620,8 @@ else } /* - * Ajouter une ligne - */ + * Ajouter une ligne + */ if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] <> 'editline') { print '
'.$langs->trans('ReductionShort').' 
'; - // multiprix - if($conf->global->PRODUIT_MULTIPRICES == 1) - { - $html->select_produits('','idprod','',$conf->produit->limit_size,$soc->price_level); - } - else - { - $html->select_produits('','idprod','',$conf->produit->limit_size); - } - - if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; + $var=!$var; + print '
'; + // multiprix + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + $html->select_produits('','idprod','',$conf->produit->limit_size,$soc->price_level); + } + else + { + $html->select_produits('','idprod','',$conf->produit->limit_size); + } - // editeur wysiwyg - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('np_desc','',100,'dolibarr_details'); - $doleditor->Create(); - } - else - { - print ''; - } - - print '%
%
'; print ''; - + /* - * Boutons actions - */ + * Boutons actions + */ if ($_GET['action'] != 'presend') { if ($user->societe_id == 0 && $_GET['action'] <> 'editline') { print '
'; - + // Valid if ($commande->statut == 0 && $commande->total_ttc >= 0 && $numlines > 0 && $user->rights->commande->valider) { @@ -1755,7 +1766,7 @@ else } print '>'.$langs->trans('Validate').''; } - + // Edit if ($commande->statut == 1) { @@ -1764,7 +1775,7 @@ else print ''.$langs->trans('Modify').''; } } - + // Send if ($commande->statut > 0) { @@ -1778,26 +1789,26 @@ else } } } - + // Ship if ($commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer && $commande->getNbOfProductsLines() > 0) { - + // Chargement des permissions $error = $user->load_entrepots(); if (sizeof($user->entrepots) === 1) { print ''; print $langs->trans('ShipProduct').''; - + } else { print ''.$langs->trans('ShipProduct').''; } } - + // Cloturer if ($commande->statut == 1 || $commande->statut == 2) { @@ -1816,7 +1827,7 @@ else print '>'.$langs->trans('Close').''; } } - + // Annuler commande if ($commande->statut == 1) { @@ -1836,7 +1847,7 @@ else print '>'.$langs->trans('CancelOrder').''; } } - + // Supprimer commande if ($commande->statut == 0 && $user->rights->commande->supprimer) { @@ -1852,22 +1863,22 @@ else } print '>'.$langs->trans('Delete').''; } - + print '
'; } print '
'; } - + if ($_GET['action'] != 'presend') { print ''; print ''; print ''; - + $var=True; while ($i < $num) { @@ -1919,20 +1930,20 @@ else dolibarr_print_error($db); } print '
'; print ''; // ancre - + /* - * Documents generes - * - */ + * Documents generes + * + */ $comref = sanitize_string($commande->ref); $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; $relativepath = $comref.'/'.$comref.'.pdf'; @@ -1875,16 +1886,16 @@ else $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; $genallowed=$user->rights->commande->creer; $delallowed=$user->rights->commande->supprimer; - + $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); - + /* - * Liste des factures - */ + * Liste des factures + */ $sql = 'SELECT f.rowid,f.facnumber, f.total_ttc, '.$db->pdate('f.datef').' as df'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'co_fa as cf'; $sql .= ' WHERE f.rowid = cf.fk_facture AND cf.fk_commande = '. $commande->id; - + $result = $db->query($sql); if ($result) { @@ -1899,7 +1910,7 @@ else print ''.$langs->trans('Date').''.$langs->trans('Price').'
'; - + // List of actions on element include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); $formactions=new FormActions($db); $somethingshown=$formactions->showactions($commande,'order',$socid); - + print '
'; } /* - * Action presend - * - */ + * Action presend + * + */ if ($_GET['action'] == 'presend') { $ref = sanitize_string($commande->ref); @@ -1979,10 +1990,10 @@ else $formmail->clear_attached_files(); $formmail->add_attached_files($file,$ref.'.pdf','application/pdf'); } - + // Show form $formmail->show_form(); - + print '
'; } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 47bf66330e3..e8e49fb1838 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -290,6 +290,13 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->glo if ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0) { $fac->set_draft($user); + //regénération PDF + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); } } diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 176f79b30d1..4aba5d76746 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -19,11 +19,11 @@ */ /** - \file htdocs/fichinter/fiche.php - \brief Fichier fiche intervention - \ingroup ficheinter - \version $Id$ -*/ + \file htdocs/fichinter/fiche.php + \brief Fichier fiche intervention + \ingroup ficheinter + \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); @@ -71,16 +71,31 @@ if ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add' && ! $_REQUE if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes') { - $fichinter = new Fichinter($db); - $fichinter->id = $_GET["id"]; - $result=$fichinter->valid($user, $conf->fichinter->outputdir); - if ($result < 0) $mesg='
'.$fichinter->error.'
'; + $fichinter = new Fichinter($db); + $fichinter->id = $_GET["id"]; + $fichinter->fetch($_GET["id"]); + + $result = $fichinter->valid($user, $conf->fichinter->outputdir); + if ($result >= 0) + { + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + + $result=fichinter_create($db, $fichinter, $_REQUEST['model'], $outputlangs); + } + else + { + $mesg='
'.$fichinter->error.'
'; + } } if ($_POST["action"] == 'add') { $fichinter = new Fichinter($db); - + $fichinter->date = dolibarr_mktime($_POST["phour"], $_POST["pmin"] , $_POST["psec"], $_POST["pmonth"], $_POST["pday"], $_POST["pyear"]); $fichinter->socid = $_POST["socid"]; $fichinter->duree = $_POST["duree"]; @@ -106,24 +121,24 @@ if ($_POST["action"] == 'add') } else { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("ThirdParty")).'
'; - $_GET["action"] = 'create'; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("ThirdParty")).'
'; + $_GET["action"] = 'create'; } } if ($_POST["action"] == 'update') { - $fichinter = new Fichinter($db); - - $fichinter->date = $db->idate(mktime(12, 1 , 1, $_POST["remonth"], $_POST["reday"], $_POST["reyear"])); - $fichinter->socid = $_POST["socid"]; - $fichinter->projet_id = $_POST["projetidp"]; - $fichinter->author = $user->id; - $fichinter->description = $_POST["description"]; - $fichinter->ref = $_POST["ref"]; - - $fichinter->update($_POST["id"]); - $_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre cr��e + $fichinter = new Fichinter($db); + + $fichinter->date = dolibarr_mktime($_POST["phour"], $_POST["pmin"] , $_POST["psec"], $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $fichinter->socid = $_POST["socid"]; + $fichinter->projet_id = $_POST["projetidp"]; + $fichinter->author = $user->id; + $fichinter->description = $_POST["description"]; + $fichinter->ref = $_POST["ref"]; + + $fichinter->update($_POST["id"]); + $_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre cr��e } /* @@ -131,15 +146,16 @@ if ($_POST["action"] == 'update') */ if ($_REQUEST['action'] == 'builddoc') // En get ou en post { + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $fichinter->fetch_lines(); + if ($_REQUEST['lang_id']) { $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - $fichinter = new Fichinter($db); - $fichinter->fetch($_GET['id']); - $result=fichinter_create($db, $fichinter, $_REQUEST['model'], $outputlangs); if ($result <= 0) { @@ -153,21 +169,21 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post */ if ($_POST['action'] == 'classin') { - $fichinter = new Fichinter($db); - $fichinter->fetch($_GET['id']); - $fichinter->set_project($user, $_POST['projetidp']); + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $fichinter->set_project($user, $_POST['projetidp']); } if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') { - if ($user->rights->ficheinter->supprimer) - { - $fichinter = new Fichinter($db); - $fichinter->fetch($_GET['id']); - $fichinter->delete($user); - } - Header('Location: index.php?leftmenu=ficheinter'); - exit; + if ($user->rights->ficheinter->supprimer) + { + $fichinter = new Fichinter($db); + $fichinter->fetch($_GET['id']); + $fichinter->delete($user); + } + Header('Location: index.php?leftmenu=ficheinter'); + exit; } if ($_POST['action'] == 'setdate_delivery') @@ -195,16 +211,16 @@ if ($_POST['action'] == "addligne" && $user->rights->ficheinter->creer) { $fichinter = new Fichinter($db); $ret=$fichinter->fetch($_POST['fichinterid']); - + $desc=$_POST['np_desc']; $date_intervention = $db->idate(mktime(12, 1 , 1, $_POST["dimonth"], $_POST["diday"], $_POST["diyear"])); $duration = ConvertTime2Seconds($_POST['durationhour'],$_POST['durationmin']); $fichinter->addline( - $_POST['fichinterid'], - $desc, - $date_intervention, - $duration + $_POST['fichinterid'], + $desc, + $date_intervention, + $duration ); if ($_REQUEST['lang_id']) @@ -247,8 +263,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->ficheinter->creer && $_P $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - fichinter_create($db, $fichinter, $fichinter->modelpdf, $outputlangs); - + fichinter_create($db, $fichinter, $fichinter->modelpdf, $outputlangs); + } /* @@ -282,30 +298,30 @@ if ($_GET['action'] == 'deleteline' && $user->rights->ficheinter->creer && !$con */ if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) { - if ($user->rights->ficheinter->creer) - { - $fichinterline = new FichinterLigne($db); - if ($fichinterline->fetch($_GET['ligne']) <= 0) - { - dolibarr_print_error($db); - exit; - } - $result=$fichinterline->delete_line(); - $fichinter = new Fichinter($db); - if ($fichinter->fetch($fichinterline->fk_fichinter) <= 0) - { - dolibarr_print_error($db); - exit; - } - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - fichinter_create($db, $fichinter, $fichinter->modelpdf, $outputlangs); - } - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']); - exit; + if ($user->rights->ficheinter->creer) + { + $fichinterline = new FichinterLigne($db); + if ($fichinterline->fetch($_GET['ligne']) <= 0) + { + dolibarr_print_error($db); + exit; + } + $result=$fichinterline->delete_line(); + $fichinter = new Fichinter($db); + if ($fichinter->fetch($fichinterline->fk_fichinter) <= 0) + { + dolibarr_print_error($db); + exit; + } + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + fichinter_create($db, $fichinter, $fichinter->modelpdf, $outputlangs); + } + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']); + exit; } /* @@ -337,7 +353,7 @@ if ($_GET['action'] == 'down' && $user->rights->ficheinter->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - fichinter_create($db, $fichinter, $fichinter->modelpdf, $outputlangs); + fichinter_create($db, $fichinter, $fichinter->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); exit; } @@ -360,14 +376,14 @@ if ($_GET["action"] == 'create') */ if ($_GET["socid"] > 0) { - $societe=new Societe($db); + $societe=new Societe($db); $societe->fetch($_GET["socid"]); } print_titre($langs->trans("AddIntervention")); if ($mesg) print $mesg.'
'; - + if (! $conf->global->FICHEINTER_ADDON) { dolibarr_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); @@ -386,81 +402,81 @@ if ($_GET["action"] == 'create') if ($_GET["socid"]) { - print "
"; + print ""; - print ''; + print '
'; print ''; print ""; - - print ""; - print ""; + print ""; - print ""; - print "\n"; + print ""; - if ($conf->projet->enabled) - { - // Projet associe - $langs->load("project"); + print ""; + print "\n"; - print '
".$langs->trans("Company")."".$societe->getNomUrl(1)."
".$langs->trans("Date").""; - $html->select_date(time(),"p",'','','','fichinter'); - print "
".$langs->trans("Date").""; + $html->select_date(time(),"p",'','','','fichinter'); + print "
".$langs->trans("Ref")."
".$langs->trans("Ref")."
'.$langs->trans("Project").''; - - if ($_GET["socid"]) $numprojet = $societe->has_projects(); - - if (!$numprojet) + if ($conf->projet->enabled) { - print ''; - print ''; + // Projet associe + $langs->load("project"); - if ($user->rights->projet->creer) + print ''; + print '
'.$langs->trans("NoProject").'
'.$langs->trans("Project").''; + + if ($_GET["socid"]) $numprojet = $societe->has_projects(); + + if (!$numprojet) { - print ''.$langs->trans("Add").'
'; + print ''; + + if ($user->rights->projet->creer) + { + print ''; + } + print '
'.$langs->trans("NoProject").''.$langs->trans("Add").'
'; } - print '
'; + else + { + select_projects($societe->id,'','projetidp'); + } + print '
'.$langs->trans("DefaultModel").''; + $model=new ModelePDFFicheinter(); + $liste=$model->liste_modeles($db); + $html->select_array('model',$liste,$conf->global->FICHEINTER_ADDON_PDF); + print "
'.$langs->trans("Description").'"; + + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE) + { + // Editeur wysiwyg + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('description','',280,'dolibarr_notes','In',true); + $doleditor->Create(); } else { - select_projects($societe->id,'','projetidp'); + print ''; } + print '
'.$langs->trans("DefaultModel").''; - $model=new ModelePDFFicheinter(); - $liste=$model->liste_modeles($db); - $html->select_array('model',$liste,$conf->global->FICHEINTER_ADDON_PDF); - print "
'; + print ''; + print '
'.$langs->trans("Description").'"; - - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE) - { - // Editeur wysiwyg - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('description','',280,'dolibarr_notes','In',true); - $doleditor->Create(); - } - else - { - print ''; - } - - print '
'; - print ''; - print '
'; - print ''; + print '
'; + print ''; } else { @@ -481,8 +497,8 @@ if ($_GET["action"] == 'create') elseif ($_GET["id"] > 0) { /* - * Affichage en mode visu - */ + * Affichage en mode visu + */ $fichinter = new Fichinter($db); $result=$fichinter->fetch($_GET["id"]); if (! $result > 0) @@ -499,8 +515,8 @@ elseif ($_GET["id"] > 0) dolibarr_fiche_head($head, 'card', $langs->trans("InterventionCard")); /* -* Confirmation de la suppression de la fiche d'intervention -*/ + * Confirmation de la suppression de la fiche d'intervention + */ if ($_GET['action'] == 'delete') { $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$fichinter->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete'); @@ -508,8 +524,8 @@ elseif ($_GET["id"] > 0) } /* -* Confirmation de la validation de la fiche d'intervention -*/ + * Confirmation de la validation de la fiche d'intervention + */ if ($_GET['action'] == 'validate') { $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$fichinter->id, $langs->trans('ValidateIntervention'), $langs->trans('ConfirmValidateIntervention'), 'confirm_validate'); @@ -517,8 +533,8 @@ elseif ($_GET["id"] > 0) } /* -* Confirmation de la suppression d'une ligne d'intervention -*/ + * Confirmation de la suppression d'une ligne d'intervention + */ if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) { $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$fichinter->id.'&ligne='.$_GET["ligne"], $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline'); @@ -612,10 +628,10 @@ elseif ($_GET["id"] > 0) } print ''; } - + // Duration print ''.$langs->trans("TotalDuration").''.ConvertSecondToTime($fichinter->duree).''; - + // Description print ''; print ''; print ''; - + // Statut print ''; print "
'; @@ -648,15 +664,15 @@ elseif ($_GET["id"] > 0) } print '
'.$langs->trans("Status").''.$fichinter->getLibStatut(4).'

"; - + /* - * Lignes d'intervention - */ + * Lignes d'intervention + */ print ''; $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang'; @@ -692,7 +708,7 @@ elseif ($_GET["id"] > 0) print ''; print ''; @@ -777,12 +793,12 @@ elseif ($_GET["id"] > 0) print ''; } print ''; - + // Date d'intervention print ''; - + // Duration print ''; @@ -841,12 +857,12 @@ elseif ($_GET["id"] > 0) print ''; } print ''; - + // Date d'intervention print ''; - + // Dur�e print '
'; print ''; // ancre pour retourner sur la ligne print nl2br($objp->description); - + print ''.dolibarr_print_date($objp->date_intervention,'day').''.ConvertSecondToTime($objp->duree).''; $html->select_date($objp->date_intervention,'di',0,0,0,"date_intervention"); print ''; $html->select_duree('duration',$objp->duree); @@ -806,8 +822,8 @@ elseif ($_GET["id"] > 0) } /* - * Ajouter une ligne - */ + * Ajouter une ligne + */ if ($fichinter->statut == 0 && $user->rights->ficheinter->creer && $_GET["action"] <> 'editline') { print '
'; $html->select_date(time(),'di',0,0,0,"addinter"); print ''; $html->select_duree('duration'); @@ -865,9 +881,9 @@ elseif ($_GET["id"] > 0) /** - * Barre d'actions - * - */ + * Barre d'actions + * + */ print '
'; if ($user->societe_id == 0) @@ -887,7 +903,7 @@ elseif ($_GET["id"] > 0) } print '>'.$langs->trans("Valid").''; } - + // Delete if ($fichinter->statut == 0 && $user->rights->ficheinter->supprimer) { @@ -904,13 +920,13 @@ elseif ($_GET["id"] > 0) print '>'.$langs->trans('Delete').''; } } - + print '
'; print '
'; /* - * Documents g�n�r�s - */ + * Documents g�n�r�s + */ $filename=sanitize_string($fichinter->ref); $filedir=$conf->fichinter->dir_output . "/".$fichinter->ref; $urlsource=$_SERVER["PHP_SELF"]."?id=".$fichinter->id; diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index 357fef795cd..1d50bc9b1b9 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -147,7 +147,7 @@ class Fichinter extends CommonObject * Insertion dans la base */ $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; - $sql .= " datei = ".$this->date; + $sql .= " datei = ".$this->db->idate($this->date); $sql .= ", description = '".addslashes($this->description)."'"; $sql .= ", duree = ".$this->duree; $sql .= ", fk_projet = ".$this->projet_id; @@ -219,6 +219,8 @@ class Fichinter extends CommonObject { global $langs, $conf; + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql.= " SET fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; @@ -234,12 +236,24 @@ class Fichinter extends CommonObject if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - return 1; + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + $this->error=join(',',$this->errors); + dolibarr_syslog("Fichinter::update ".$this->error,LOG_ERR); + return -1; + } } else { - $this->error=$this->db->error(); - dolibarr_syslog("Fichinter::update error ".$this->error,LOG_ERR); + $this->db->rollback(); + $this->error=$this->db->lasterror(); + dolibarr_syslog("Fichinter::update ".$this->error,LOG_ERR); return -1; } } diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php index 0cbf038e7e5..54248e3d173 100644 --- a/htdocs/includes/modules/fichinter/modules_fichinter.php +++ b/htdocs/includes/modules/fichinter/modules_fichinter.php @@ -174,7 +174,8 @@ function fichinter_create($db, $object, $modele='', $outputlangs='') } else { - print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_PDF_NotDefined"); + dolibarr_syslog("Error ".$langs->trans("Error_FICHEINTER_ADDON_PDF_NotDefined"), LOG_ERR); + print "Error ".$langs->trans("Error_FICHEINTER_ADDON_PDF_NotDefined"); return 0; } } @@ -188,6 +189,7 @@ function fichinter_create($db, $object, $modele='', $outputlangs='') $obj = new $classname($db); + dolibarr_syslog("fichinter_create build PDF", LOG_DEBUG); if ($obj->write_file($object,$outputlangs) > 0) { return 1; diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index 93329351361..511223b8946 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2008 Raphael Bertrand (Resultic) * * This program is free software; you can redistribute it and/or modify @@ -87,7 +87,7 @@ class pdf_soleil extends ModelePDFFicheinter $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("interventions"); - + $outputlangs->setPhpLang(); if ($conf->fichinter->dir_output) @@ -117,7 +117,7 @@ class pdf_soleil extends ModelePDFFicheinter return 0; } } - + if (file_exists($dir)) { // Protection et encryption du pdf @@ -259,7 +259,6 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->writeHTMLCell(190, 5, 10, $tab_top + 8, dol_htmlentitiesbr($fichinter->description), 0, 'J', 0); //dolibarr_syslog("desc=".dol_htmlentitiesbr($fichinter->description)); - $fichinter->fetch_lines(); $num = sizeof($fichinter->lignes); $i=0; if ($num) @@ -268,12 +267,12 @@ class pdf_soleil extends ModelePDFFicheinter { $fichinterligne = $fichinter->lignes[$i]; - $valide = $fichinterligne->fetch($fichinterligne->id); + $valide = $fichinterligne->id ? $fichinterligne->fetch($fichinterligne->id) : 0; if ($valide>0) { $pdf->SetXY (20, $tab_top + 16 + $i * 20); $pdf->writeHTMLCell(190, 8, 20, $tab_top + 16 + $i * 20, - dol_htmlentitiesbr("Date : ".dolibarr_print_date($fichinterligne->datei)." - Durée : ".ConvertSecondToTime($fichinterligne->duration)), 0, 'J', 0); + dol_htmlentitiesbr($langs->transnoentities("Date")." : ".dolibarr_print_date($fichinterligne->datei)." - ".$langs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration)), 0, 'J', 0); $pdf->SetXY (20, $tab_top + 22 + $i * 20); $pdf->writeHTMLCell(170, 8, 20, $tab_top + 22 + $i * 20,