diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 68dc1b2aa0bd3b4720c745f00a3b7fd2205be870..de8b31f900c445efbe2370ee6b9f28ae50ca7649 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -51,7 +51,7 @@ $langs->load('propal'); $langs->load('deliveries'); $langs->load('products'); -$id =(GETPOST("id")?GETPOST("id"):GETPOST("orderid")); +$id = (GETPOST("id")?GETPOST("id"):GETPOST("orderid")); $ref = GETPOST('ref'); $socid = GETPOST('socid'); $action = GETPOST('action'); @@ -928,8 +928,7 @@ if ($_POST['addfile']) $mesg=dol_add_file_process($upload_dir,0,0); - $action ='presend'; - $_POST["action"]='presend'; + $action ='presend'; } /* @@ -945,8 +944,7 @@ if (! empty($_POST['removedfile'])) $mesg=dol_remove_file_process($_POST['removedfile'],0); - $action ='presend'; - $_POST["action"]='presend'; + $action ='presend'; } /* @@ -1098,8 +1096,8 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P else { $langs->load("other"); - $mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>'; - dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.'); + $mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Order")).'</div>'; + dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order"))); } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 2c2f4fd07923b70482a5fd2add342f98b36b22ce..6cf50f2390a2f3351686d8eb871528f9927661a2 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -141,7 +141,7 @@ class Expedition extends CommonObject */ function create($user) { - global $conf; + global $conf, $langs; require_once DOL_DOCUMENT_ROOT ."/product/stock/class/mouvementstock.class.php"; $error = 0; @@ -234,6 +234,13 @@ class Expedition extends CommonObject if (! $error) { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('SHIPPING_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + $this->db->commit(); return $this->id; } @@ -745,6 +752,8 @@ class Expedition extends CommonObject */ function delete() { + global $conf, $langs, $user; + require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); $this->db->begin(); @@ -789,6 +798,14 @@ class Expedition extends CommonObject } } } + + // Call triggers + include_once(DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('SHIPPING_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // End call triggers + // TODO il faut incrementer le stock si on supprime une expedition validee return 1; } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 8ac7b0fb2ff4ff3551b531b097a80d830978e870..a4d2ce767e3264342e0f6d12627f141bc7fa4c09 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -49,12 +49,8 @@ $langs->load('stocks'); $langs->load('other'); $langs->load('propal'); - -$action = GETPOST("action"); -$confirm = GETPOST("confirm"); - -$origin = GETPOST("origin")?GETPOST("origin"):'expedition'; // Example: commande, propal -$origin_id = GETPOST("id")?GETPOST("id"):''; +$origin = GETPOST("origin")?GETPOST("origin"):'expedition'; // Example: commande, propal +$origin_id = GETPOST("id")?GETPOST("id"):''; if (empty($origin_id)) $origin_id = GETPOST("origin_id"); // Id of order or propal if (empty($origin_id)) $origin_id = GETPOST("object_id"); // Id of order or propal $id = $origin_id; @@ -63,6 +59,9 @@ $id = $origin_id; if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,$origin,$origin_id); +$action = GETPOST("action"); +$confirm = GETPOST("confirm"); + $object = new Expedition($db); /* @@ -188,7 +187,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expeditio } } -if ($action == 'open' && $user->rights->expedition->valider) +if ($action == 'reopen' && $user->rights->expedition->valider) { $object->fetch($id); $result = $object->setStatut(0); @@ -284,6 +283,191 @@ if ($action == 'builddoc') // En get ou en post } } +/* + * Add file in email form + */ +if ($_POST['addfile']) +{ + require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir = $vardir.'/temp/'; + + $mesg=dol_add_file_process($upload_dir,0,0); + + $action ='presend'; +} + +/* + * Remove file in email form + */ +if (! empty($_POST['removedfile'])) +{ + require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); + + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir = $vardir.'/temp/'; + + $mesg=dol_remove_file_process($_POST['removedfile'],0); + + $action ='presend'; +} + +/* + * Send mail + */ +if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) +{ + $langs->load('mails'); + + $result=$object->fetch($id); + $result=$object->fetch_thirdparty(); + + if ($result > 0) + { + $ref = dol_sanitizeFileName($object->ref); + $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; + + if (is_readable($file)) + { + if ($_POST['sendto']) + { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST['sendto']; + $sendtoid = 0; + } + elseif ($_POST['receiver']) + { + // Le destinataire a ete fourni via la liste deroulante + if ($_POST['receiver'] < 0) // Id du tiers + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); + $sendtoid = $_POST['receiver']; + } + } + + if (dol_strlen($sendto)) + { + $langs->load("commercial"); + + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; + $deliveryreceipt = $_POST['deliveryreceipt']; + + if ($_POST['action'] == 'send') + { + if (dol_strlen($_POST['subject'])) $subject=$_POST['subject']; + else $subject = $langs->transnoentities('Shipping').' '.$object->ref; + $actiontypecode='AC_SHIP'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + if ($message) + { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; + $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; + $actionmsg.=$message; + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + + // Create form object + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); + $formmail = new FormMail($db); + + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Send mail + require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); + if ($mailfile->error) + { + $mesg='<div class="error">'.$mailfile->error.'</div>'; + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + $_SESSION['mesg']=$langs->trans('MailSuccessfulySent',$from,$sendto); + + $error=0; + + // Initialisation donnees + $object->sendtoid=$sendtoid; + $object->actiontypecode=$actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2= $actionmsg2; + $object->shippingrowid=$object->id; + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('SHIPPING_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + + if ($error) + { + dol_print_error($db); + } + else + { + // Redirect here + // This avoid sending mail twice if going out and then back to page + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + else + { + $langs->load("other"); + $mesg='<div class="error">'; + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='<br>'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg.='</div>'; + } + } + } + else + { + $langs->load("other"); + $mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>'; + $action='presend'; + dol_syslog('Recipient email is empty'); + } + } + else + { + $langs->load("other"); + $mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>'; + dol_syslog('Failed to read file: '.$file); + } + } + else + { + $langs->load("other"); + $mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Shipping")).'</div>'; + dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Shipping"))); + } +} /* * View @@ -655,6 +839,8 @@ else { print '<div class="error">'.$mesg.'</div>'; } + + dol_htmloutput_mesg(); if (!empty($object->origin)) { @@ -1039,44 +1225,60 @@ else { print '<div class="tabsAction">'; - /*if ($object->statut > 0 && $user->rights->expedition->valider) - { - print '<a class="butAction" href="fiche.php?id='.$object->id.'&action=open">'.$langs->trans("Modify").'</a>'; - }*/ - if ($object->statut == 0 && $num_prod > 0) { if ($user->rights->expedition->valider) { - print '<a class="butAction" href="fiche.php?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a>'; } else { print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Validate").'</a>'; } } + + // TODO add alternative status + /* if ($object->statut == 1 && $user->rights->expedition->valider) + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>'; + }*/ + + // Send + if ($object->statut == 1) + { + $ref = dol_sanitizeFileName($object->ref); + $file = $conf->expedition->dir_output . '/sending/'.$ref.'/'.$ref.'.pdf'; + if (file_exists($file)) + { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) + { + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>'; + } + else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>'; + } + } if ($conf->livraison_bon->enabled && $object->statut == 1 && $user->rights->expedition->livraison->creer && empty($object->linkedObjectsIds)) { - print '<a class="butAction" href="fiche.php?id='.$object->id.'&action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>'; + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>'; } if ($user->rights->expedition->supprimer) { - print '<a class="butActionDelete" href="fiche.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>'; + print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>'; } print '</div>'; } print "\n"; - print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">"; + print '<table width="100%" cellspacing=2><tr><td width="50%" valign="top">'; /* * Documents generated */ - if ($conf->expedition_bon->enabled) + if ($action != 'presend') { $objectref = dol_sanitizeFileName($object->ref); $filedir = $conf->expedition->dir_output . "/sending/" .$objectref; @@ -1090,21 +1292,77 @@ else $somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); if ($genallowed && ! $somethingshown) $somethingshown=1; + + print '</td><td valign="top" width="50%">'; + + // List of actions on element + /* + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'shipping',$socid); + */ + + print '</td></tr></table>'; + } + + /* + * Action presend + * + */ + if ($action == 'presend') + { + $ref = dol_sanitizeFileName($object->ref); + $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; + + print '<br>'; + print_titre($langs->trans('SendShippingByMail')); + + // Cree l'objet formulaire mail + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; + $formmail->withtosocid=$soc->id; + $formmail->withtocc=1; + $formmail->withtoccsocid=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtocccsocid=0; + $formmail->withtopic=$langs->trans('SendShippingRef','__SHIPPINGREF__'); + $formmail->withfile=2; + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + // Tableau des substitutions + $formmail->substit['__SHIPPINGREF__']=$object->ref; + // Tableau des parametres complementaires + $formmail->param['action']='send'; + $formmail->param['models']='shipping_send'; + $formmail->param['shippingid']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf'); + } + + // Show form + $formmail->show_form(); + + print '<br>'; } - print '</td><td valign="top" width="50%">'; - - // Rien a droite - - print '</td></tr></table>'; - - if (!empty($origin) && $object->$origin->id) + if ($action != 'presend' && ! empty($origin) && $object->$origin->id) { print '<br>'; //show_list_sending_receive($object->origin,$object->origin_id," AND e.rowid <> ".$object->id); show_list_sending_receive($object->origin,$object->origin_id); } - } else { diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php index 376f2d5640f33072603a4c9b7fd002a264634703..d5eeecc6873a9aa85dd676fda156b6659aea90fd 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,149 +68,6 @@ Class pdf_expedition_rouget extends ModelePdfExpedition if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // By default if not defined } - /** - * \param pdf Objet PDF - * \param exp Objet expedition - * \param showadress 0=non, 1=oui - * \param outputlang Objet lang cible - */ - function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) - { - global $conf,$langs,$mysoc; - $default_font_size = pdf_getPDFFontSize($outputlangs); - $langs->load("orders"); - - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); - - //Affiche le filigrane brouillon - Print Draft Watermark - if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) ) - { - pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK); - } - - //Prepare la suite - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('','B', $default_font_size + 3); - - $posy=$this->marge_haute; - - $pdf->SetXY($this->marge_gauche,$posy); - - // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) - { - if (is_readable($logo)) - { - $pdf->Image($logo, $this->marge_gauche, $posy, 0, 24); - } - else - { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } - else - { - $text=$this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } - - // Show barcode - if ($conf->barcode->enabled) - { - $posx=105; - } - else - { - $posx=$this->marge_gauche+3; - } - //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if ($conf->barcode->enabled) - { - // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); - //$pdf->Image($logo,10, 5, 0, 24); - } - - $pdf->SetDrawColor(128,128,128); - if ($conf->barcode->enabled) - { - // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); - //$pdf->Image($logo,10, 5, 0, 24); - } - - - $posx=100; - $posy=$this->marge_haute; - - $pdf->SetFont('','B', $default_font_size + 3); - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $title=$outputlangs->transnoentities("SendingSheet"); - $pdf->MultiCell(100, 4, $title, '' , 'R'); - $posy+=1; - - $pdf->SetFont('','', $default_font_size + 2); - - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); - - //Date Expedition - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_delivery,"%d %b %Y",false,$outputlangs,true), '', 'R'); - - if (! empty($object->client->code_client)) - { - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); - } - - - $pdf->SetFont('','', $default_font_size + 4); - $Yoff=40; - - // Add list of linked orders - // TODO possibility to use with other document (business module,...) - //$object->load_object_linked(); - - $origin = $object->origin; - $origin_id = $object->origin_id; - - // TODO move to external function - if ($conf->$origin->enabled) - { - $outputlangs->load('orders'); - - $classname = ucfirst($origin); - $linkedobject = new $classname($this->db); - $result=$linkedobject->fetch($origin_id); - if ($result >= 0) - { - $pdf->SetFont('','', $default_font_size - 2); - $text=$linkedobject->ref; - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; - $Yoff = $Yoff+8; - $pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff); - $pdf->MultiCell(60, 4, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); - $Yoff = $Yoff+4; - $pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff); - $pdf->MultiCell(60, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true), 0, 'R'); - } - } - - } - - /** * \brief Fonction generant le document sur le disque * \param object Objet expedition a generer (ou id si ancienne methode) @@ -295,7 +153,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); - $tab_top = 90; + $tab_top = 95; $height_note = 180; $pdf->Rect($this->marge_gauche, $tab_top-10, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+10); $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note); @@ -307,7 +165,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition { $this->posxdesc=$this->marge_gauche+1; } - $this->tableau_top = 80; + $this->tableau_top = 85; $pdf->SetFont('','', $default_font_size); $curY = $this->tableau_top + 4; @@ -375,6 +233,255 @@ Class pdf_expedition_rouget extends ModelePdfExpedition return 0; // Erreur par defaut } + /** + * Show header of document + * @param pdf Object PDF + * @param object Object commercial proposal + * @param showaddress 0=no, 1=yes + * @param outputlangs Object lang for output + */ + function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs) + { + global $conf,$langs,$mysoc; + $default_font_size = pdf_getPDFFontSize($outputlangs); + $langs->load("orders"); + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + //Affiche le filigrane brouillon - Print Draft Watermark + if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) ) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK); + } + + //Prepare la suite + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posy=$this->marge_haute; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $pdf->Image($logo, $this->marge_gauche, $posy, 0, 24); + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } + else + { + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + } + + // Show barcode + if ($conf->barcode->enabled) + { + $posx=105; + } + else + { + $posx=$this->marge_gauche+3; + } + //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); + if ($conf->barcode->enabled) + { + // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref + //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); + //$pdf->Image($logo,10, 5, 0, 24); + } + + $pdf->SetDrawColor(128,128,128); + if ($conf->barcode->enabled) + { + // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref + //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); + //$pdf->Image($logo,10, 5, 0, 24); + } + + + $posx=100; + $posy=$this->marge_haute; + + $pdf->SetFont('','B', $default_font_size + 3); + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $title=$outputlangs->transnoentities("SendingSheet"); + $pdf->MultiCell(100, 4, $title, '' , 'R'); + $posy+=1; + + $pdf->SetFont('','', $default_font_size + 2); + + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); + + //Date Expedition + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_delivery,"%d %b %Y",false,$outputlangs,true), '', 'R'); + + if (! empty($object->client->code_client)) + { + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); + } + + + $pdf->SetFont('','', $default_font_size + 4); + $Yoff=40; + + // Add list of linked orders + // TODO possibility to use with other document (business module,...) + //$object->load_object_linked(); + + $origin = $object->origin; + $origin_id = $object->origin_id; + + // TODO move to external function + if ($conf->$origin->enabled) + { + $outputlangs->load('orders'); + + $classname = ucfirst($origin); + $linkedobject = new $classname($this->db); + $result=$linkedobject->fetch($origin_id); + if ($result >= 0) + { + $pdf->SetFont('','', $default_font_size - 2); + $text=$linkedobject->ref; + if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; + $Yoff = $Yoff+8; + $pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff); + $pdf->MultiCell(60, 4, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); + $Yoff = $Yoff+4; + $pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff); + $pdf->MultiCell(60, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true), 0, 'R'); + } + } + + // Tracking number + if (! empty($object->tracking_number)) + { + $object->GetUrlTrackingStatus($object->tracking_number); + if (! empty($object->tracking_url)) + { + if ($object->expedition_method_id > 0) + { + // Get code using getLabelFromKey + $code=$outputlangs->getLabelFromKey($this->db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); + $label=$outputlangs->trans("SendingMethod".strtoupper($code))." :"; + $pdf->SetFont('','', $default_font_size - 2); + $posy=$pdf->GetY()+2; + $pdf->writeHTMLCell(60, 4, 140, $posy, $label." ".$object->tracking_url, 0, 1, false, true, 'R'); + } + } + } + + if ($showaddress) + { + // Sender properties + $carac_emetteur=''; + // Add internal contact of proposal if defined + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (sizeof($arrayidcontact) > 0) + { + $object->fetch_user($arrayidcontact[0]); + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur); + + // Show sender + $posx=$this->marge_gauche; + $posy=42; + $hautcadre=40; + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; + + // Show sender frame + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posx,$posy-5); + $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L'); + $pdf->SetXY($posx,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + + // Show sender name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B',$default_font_size); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + + // Show sender information + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetXY($posx+2,$posy+8); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); + + + // If CUSTOMER contact defined, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); + if (sizeof($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname; + else $socname = $object->client->nom; + $carac_client_name=$outputlangs->convToOutputCharset($socname); + } + else + { + $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); + } + + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target'); + + // Show recipient + $posy=42; + $posx=100; + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + + // Show recipient frame + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posx,$posy-5); + $pdf->MultiCell(80, 4, $outputlangs->transnoentities("Recipient").":", 0, 'L'); + $pdf->rect($posx, $posy, 100, $hautcadre); + $pdf->SetTextColor(0,0,0); + + // Show recipient name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell(96,4, $carac_client_name, 0, 'L'); + + // Show recipient information + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetXY($posx+2,$posy+8); + $pdf->MultiCell(86,4, $carac_client, 0, 'L'); + } + + } /** * \brief Show footer of page diff --git a/htdocs/includes/modules/modExpedition.class.php b/htdocs/includes/modules/modExpedition.class.php index 4a6b18133909f0b26712e67c26dc27f60180fe75..546cd800cd57a0f9e7fa0a06ed3d4d27762237ec 100644 --- a/htdocs/includes/modules/modExpedition.class.php +++ b/htdocs/includes/modules/modExpedition.class.php @@ -143,6 +143,14 @@ class modExpedition extends DolibarrModules $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'valider'; + + $r++; + $this->rights[$r][0] = 105; // id de la permission + $this->rights[$r][1] = 'Envoyer les expeditions aux clients'; // libelle de la permission + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'shipping_advance'; + $this->rights[$r][5] = 'send'; $r++; $this->rights[$r][0] = 109; diff --git a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN index b2b1668dc7a826cdf88fd7b455c2bf0ff219bcb3..f6a533a4aed2b0dbd7ce4fc850113bea5a677d62 100644 --- a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN +++ b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN @@ -456,6 +456,28 @@ class InterfaceDemo dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } elseif ($action == 'TASK_TIMESPENT_DELETE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + + // Shipping + elseif ($action == 'SHIPPING_CREATE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'SHIPPING_MODIFY') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'SHIPPING_VALIDATE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'SHIPPING_SENTBYMAIL') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'SHIPPINGL_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } diff --git a/htdocs/install/mysql/data/llx_c_actioncomm.sql b/htdocs/install/mysql/data/llx_c_actioncomm.sql index 0f5342cdfb8ebb3a38345e344f88f02c4a17f818..dcbaf2faaf48b55bd718c79d0acfa64787cdd4b2 100644 --- a/htdocs/install/mysql/data/llx_c_actioncomm.sql +++ b/htdocs/install/mysql/data/llx_c_actioncomm.sql @@ -3,7 +3,7 @@ -- Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> -- Copyright (C) 2004 Guillaume Delecourt <guillaume.delecourt@opensides.be> --- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> +-- Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> -- Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> -- -- This program is free software; you can redistribute it and/or modify @@ -32,14 +32,15 @@ -- Types action comm -- -delete from llx_c_actioncomm where id in (1,2,3,4,5,8,9,50); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 1, 'AC_TEL', 'system', 'Phone call' ,NULL, 2); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 2, 'AC_FAX', 'system', 'Send Fax' ,NULL, 3); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 3, 'AC_PROP', 'system', 'Send commercial proposal by email','propal', 10); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 4, 'AC_EMAIL', 'system', 'Send Email' ,NULL, 4); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 5, 'AC_RDV', 'system', 'Rendez-vous' ,NULL, 1); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 8, 'AC_COM', 'system', 'Send customer order by email' ,'order', 8); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 9, 'AC_FAC', 'system', 'Send customer invoice by email' ,'invoice', 6); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values (30, 'AC_SUP_ORD', 'system', 'Send supplier order by email' ,'order_supplier', 9); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values (31, 'AC_SUP_INV', 'system', 'Send supplier invoice by email' ,'invoice_supplier', 7); -insert into llx_c_actioncomm (id, code, type, libelle, module, position) values (50, 'AC_OTH', 'system', 'Other' ,NULL, 5); +delete from llx_c_actioncomm where id in (1,2,3,4,5,8,9,10,30,31,50); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 1, 'AC_TEL', 'system', 'Phone call' ,NULL, 2); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 2, 'AC_FAX', 'system', 'Send Fax' ,NULL, 3); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 3, 'AC_PROP', 'system', 'Send commercial proposal by email' ,'propal', 10); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 4, 'AC_EMAIL', 'system', 'Send Email' ,NULL, 4); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 5, 'AC_RDV', 'system', 'Rendez-vous' ,NULL, 1); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 8, 'AC_COM', 'system', 'Send customer order by email' ,'order', 8); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 9, 'AC_FAC', 'system', 'Send customer invoice by email' ,'invoice', 6); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 10, 'AC_SHIP', 'system', 'Send shipping by email' ,'shipping', 11); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 30, 'AC_SUP_ORD', 'system', 'Send supplier order by email' ,'order_supplier', 9); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values (31, 'AC_SUP_INV', 'system', 'Send supplier invoice by email' ,'invoice_supplier', 7); +insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 50, 'AC_OTH', 'system', 'Other' ,NULL, 5); diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index 4a4e781fd600e344355b95e3fcdf007d76e9c2af..d7f7b95a71e51e9f06954d1355c51ac766247812 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -133,6 +133,7 @@ ALTER TABLE llx_livraison ADD COLUMN ref_ext varchar(30) AFTER fk_soc; ALTER TABLE llx_livraison ADD COLUMN ref_int varchar(30) AFTER ref_ext; INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (4,'LETTREMAX','Lettre Max','Courrier Suivi et Lettre Max',0); +INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, position) VALUES ( 10, 'AC_SHIP', 'system', 'Send shipping by email' ,'shipping', 11); --Add Chile data (id pays=67) -- Regions Chile diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 3764cf62077284843d0c8c23dcede294819f2240..1c42417573ce6142919f223d606a534dec0e40ca 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -3674,6 +3674,18 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb $ret=''; $out=''; $divstart=$divend=''; + + if (isset($_SESSION['mesg'])) + { + $mesgstring=$_SESSION['mesg']; + unset($_SESSION['mesg']); + } + + if (isset($_SESSION['mesgarray'])) + { + $mesgarray=$_SESSION['mesgarray']; + unset($_SESSION['mesgarray']); + } if (! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! preg_match('/<div class=".*">/i',$out)) {