gestion des contacts sur les commandes - Merci MESSIN Enguerrand
This commit is contained in:
parent
b62a214a96
commit
4a850d7b27
@ -114,6 +114,10 @@ if ($_GET["id"] > 0) {
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans('Info');
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans('OrderContact');
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans('Order').': '.$commande->ref);
|
||||
|
||||
|
||||
@ -1328,6 +1328,212 @@ class Commande
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Liste les valeurs possibles de type de contacts pour les factures
|
||||
* \param source 'internal' ou 'external'
|
||||
* \return array Tableau des types de contacts
|
||||
*/
|
||||
function liste_type_contact($source)
|
||||
{
|
||||
global $langs;
|
||||
$element='commande';
|
||||
$tab = array();
|
||||
|
||||
$sql = "SELECT distinct tc.rowid, tc.code, tc.libelle";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||
$sql.= " WHERE element='".$element."'";
|
||||
$sql.= " AND source='".$source."'";
|
||||
$sql.= " ORDER by tc.code";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num=$this->db->num_rows($resql);
|
||||
$i=0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$transkey="TypeContact_".$element."_".$source."_".$obj->code;
|
||||
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
|
||||
$tab[$obj->rowid]=$libelle_type;
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Récupère les lignes de contact de l'objet
|
||||
* \param statut Statut des lignes detail à récupérer
|
||||
* \param source Source du contact external (llx_socpeople) ou internal (llx_user)
|
||||
* \return array Tableau des rowid des contacts
|
||||
*/
|
||||
function liste_contact($statut=-1,$source='external')
|
||||
{
|
||||
global $langs;
|
||||
$element='commande';
|
||||
$tab=array();
|
||||
|
||||
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,";
|
||||
if ($source == 'internal') $sql.=" '-1' as socid,";
|
||||
if ($source == 'external') $sql.=" t.fk_soc as socid,";
|
||||
if ($source == 'internal') $sql.=" t.name as nom,";
|
||||
if ($source == 'external') $sql.=" t.name as nom,";
|
||||
$sql.= "tc.source, tc.element, tc.code, tc.libelle";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
|
||||
if ($source == 'internal') $sql.=" ".MAIN_DB_PREFIX."user t,";
|
||||
if ($source == 'external') $sql.=" ".MAIN_DB_PREFIX."socpeople t,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."c_type_contact tc";
|
||||
$sql.= " WHERE element_id =".$this->id;
|
||||
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
|
||||
$sql.= " AND tc.element='".$element."'";
|
||||
if ($source == 'internal') $sql.= " AND tc.source = 'internal'";
|
||||
if ($source == 'external') $sql.= " AND tc.source = 'external'";
|
||||
$sql.= " AND tc.active=1";
|
||||
if ($source == 'internal') $sql.= " AND ec.fk_socpeople = t.rowid";
|
||||
if ($source == 'external') $sql.= " AND ec.fk_socpeople = t.idp";
|
||||
if ($statut >= 0) $sql.= " AND statut = '$statut'";
|
||||
$sql.=" ORDER BY t.name ASC";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num=$this->db->num_rows($resql);
|
||||
$i=0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
|
||||
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
|
||||
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut);
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Ajoute un contact associé une commande
|
||||
* \param fk_socpeople Id du contact a ajouter.
|
||||
* \param type_contact Type de contact
|
||||
* \param source extern=Contact externe (llx_socpeople), intern=Contact interne (llx_user)
|
||||
* \return int <0 si erreur, >0 si ok
|
||||
*/
|
||||
function add_contact($fk_socpeople, $type_contact, $source='extern')
|
||||
{
|
||||
dolibarr_syslog("Commande::add_contact $fk_socpeople, $type_contact, $source");
|
||||
|
||||
if ($fk_socpeople <= 0) return -1;
|
||||
|
||||
// Verifie type_contact
|
||||
if (! $type_contact || ! is_numeric($type_contact))
|
||||
{
|
||||
$this->error="Valeur pour type_contact incorrect";
|
||||
return -3;
|
||||
}
|
||||
|
||||
$datecreate = time();
|
||||
|
||||
// Insertion dans la base
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
|
||||
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
|
||||
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
|
||||
$sql.= $this->db->idate($datecreate);
|
||||
$sql.= ", 4, '". $type_contact . "' ";
|
||||
$sql.= ")";
|
||||
|
||||
// Retour
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." - $sql";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Supprime une ligne de contact
|
||||
* \param rowid La reference du contact
|
||||
* \return statur >0 si ok, <0 si ko
|
||||
*/
|
||||
function delete_contact($rowid)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
|
||||
$sql.= " WHERE rowid =".$rowid;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function getIdContact($source,$code)
|
||||
{
|
||||
$element='commande'; // Contact sur la facture
|
||||
$result=array();
|
||||
$i=0;
|
||||
|
||||
$sql = "SELECT ec.fk_socpeople";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||
$sql.= " WHERE ec.element_id = ".$this->id;
|
||||
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
|
||||
$sql.= " AND tc.element = '".$element."'";
|
||||
$sql.= " AND tc.source = '".$source."'";
|
||||
$sql.= " AND tc.code = '".$code."'";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
$result[$i]=$obj->fk_socpeople;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Supprime la commande
|
||||
|
||||
476
htdocs/commande/contact.php
Normal file
476
htdocs/commande/contact.php
Normal file
@ -0,0 +1,476 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
|
||||
* Copyright (C) 2005 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/contact.php
|
||||
\ingroup facture
|
||||
\brief Onglet de gestion des contacts des factures
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require ("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php');
|
||||
|
||||
$langs->load("facture");
|
||||
$langs->load("orders");
|
||||
$langs->load("sendings");
|
||||
$langs->load("companies");
|
||||
|
||||
$user->getrights('commande');
|
||||
if (!$user->rights->commande->lire)
|
||||
accessforbidden();
|
||||
|
||||
// les methodes locales
|
||||
/**
|
||||
* \brief Retourne la liste déroulante des sociétés
|
||||
* \param selected Societe présélectionnée
|
||||
* \param htmlname Nom champ formulaire
|
||||
*/
|
||||
function select_societes_for_newconcat($commande, $selected = '', $htmlname = 'newcompany'){
|
||||
// On recherche les societes
|
||||
$sql = "SELECT s.idp, s.nom FROM";
|
||||
$sql .= " ".MAIN_DB_PREFIX."societe as s";
|
||||
// if ($filter) $sql .= " WHERE $filter";
|
||||
$sql .= " ORDER BY nom ASC";
|
||||
|
||||
$resql = $commande->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$javaScript = "window.location='./contact.php?id=".$commande->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
|
||||
print '<select class="flat" name="'.$htmlname.'" onChange="'.$javaScript.'">';
|
||||
$num = $commande->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $commande->db->fetch_object($resql);
|
||||
if ($i == 0)
|
||||
$firstCompany = $obj->idp;
|
||||
if ($selected > 0 && $selected == $obj->idp)
|
||||
{
|
||||
print '<option value="'.$obj->idp.'" selected="true">'.dolibarr_trunc($obj->nom,24).'</option>';
|
||||
$firstCompany = $obj->idp;
|
||||
} else
|
||||
{
|
||||
print '<option value="'.$obj->idp.'">'.dolibarr_trunc($obj->nom,24).'</option>';
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
print "</select>\n";
|
||||
return $firstCompany;
|
||||
} else
|
||||
{
|
||||
dolibarr_print_error($commande->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function select_type_contact($commande, $defValue, $htmlname = 'type', $source)
|
||||
{
|
||||
$lesTypes = $commande->liste_type_contact($source);
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
foreach($lesTypes as $key=>$value)
|
||||
{
|
||||
print '<option value="'.$key.'">'.$value.'</option>';
|
||||
}
|
||||
print "</select>\n";
|
||||
}
|
||||
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajout d'un nouveau contact
|
||||
*/
|
||||
|
||||
if ($_POST["action"] == 'addcontact' && $user->rights->commande->creer)
|
||||
{
|
||||
|
||||
$result = 0;
|
||||
$commande = new Commande($db);
|
||||
$result = $commande->fetch($_GET["id"]);
|
||||
|
||||
if ($result > 0 && $_GET["id"] > 0)
|
||||
{
|
||||
$result = $commande->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
|
||||
}
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
Header("Location: contact.php?id=".$commande->id);
|
||||
exit;
|
||||
} else
|
||||
{
|
||||
$mesg = '<div class="error">'.$commande->error.'</div>';
|
||||
}
|
||||
}
|
||||
// modification d'un contact. On enregistre le type
|
||||
if ($_POST["action"] == 'updateligne' && $user->rights->commande->creer)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
if ($commande->fetch($_GET["id"]))
|
||||
{
|
||||
$contact = $commande->detail_contact($_POST["elrowid"]);
|
||||
$type = $_POST["type"];
|
||||
$statut = $contact->statut;
|
||||
|
||||
$result = $commande->update_contact($_POST["elrowid"], $statut, $type);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$db->commit();
|
||||
} else
|
||||
{
|
||||
dolibarr_print_error($db, "result=$result");
|
||||
$db->rollback();
|
||||
}
|
||||
} else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// bascule du statut d'un contact
|
||||
if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
if ($commande->fetch($_GET["id"]))
|
||||
{
|
||||
$contact = $commande->detail_contact($_GET["ligne"]);
|
||||
$id_type_contact = $contact->fk_c_type_contact;
|
||||
$statut = ($contact->statut == 4) ? 5 : 4;
|
||||
|
||||
$result = $commande->update_contact($_GET["ligne"], $statut, $id_type_contact);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$db->commit();
|
||||
} else
|
||||
{
|
||||
dolibarr_print_error($db, "result=$result");
|
||||
$db->rollback();
|
||||
}
|
||||
} else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Efface un contact
|
||||
if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET["id"]);
|
||||
$result = $commande->delete_contact($_GET["lineid"]);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
Header("Location: contact.php?id=".$commande->id);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
llxHeader('', $langs->trans("Order"), "Commande");
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
/* *************************************************************************** */
|
||||
/* */
|
||||
/* Mode vue et edition */
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
if ( isset($mesg))
|
||||
print $mesg;
|
||||
$id = $_GET["id"];
|
||||
if ($id > 0)
|
||||
{
|
||||
$langs->trans("OrderCard");
|
||||
$commande = New Commande($db);
|
||||
if ( $commande->fetch($_GET['id'], $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $commande->socidp);
|
||||
$soc->fetch($commande->socidp);
|
||||
|
||||
$h=0;
|
||||
|
||||
if ($conf->commande->enabled && $user->rights->commande->lire)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderCard");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->expedition->enabled && $user->rights->expedition->lire)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("SendingCard");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("ComptaCard");
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->use_preview_tabs)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Preview");
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$h++;
|
||||
|
||||
//Ajout de longlet contacts
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans('OrderContact');
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
|
||||
|
||||
/*
|
||||
* Facture synthese pour rappel
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Reference de la commande
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $commande->ref;
|
||||
print "</td></tr>";
|
||||
|
||||
// Customer
|
||||
if ( is_null($commande->ref_client) )
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->soc_id);
|
||||
|
||||
print "<tr><td>".$langs->trans("Customer")."</td>";
|
||||
print '<td colspan="3">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td></tr>';
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Lignes de contacts
|
||||
*/
|
||||
echo '<br><table class="noborder" width="100%">';
|
||||
|
||||
/*
|
||||
* Ajouter une ligne de contact
|
||||
* Non affiché en mode modification de ligne
|
||||
*/
|
||||
if ($_GET["action"] != 'editline' && $user->rights->facture->creer)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Source").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Contacts").'</td>';
|
||||
print '<td>'.$langs->trans("ContactType").'</td>';
|
||||
print '<td colspan="3"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$var = false;
|
||||
|
||||
print '<form action="contact.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="addcontact">';
|
||||
print '<input type="hidden" name="source" value="internal">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
// Ligne ajout pour contact interne
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td>';
|
||||
print $langs->trans("Internal");
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
print $conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
$html->select_users($user->id,'contactid');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
select_type_contact($commande, '', 'type','internal');
|
||||
print '</td>';
|
||||
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '<form action="contact.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="addcontact">';
|
||||
print '<input type="hidden" name="source" value="external">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
// Ligne ajout pour contact externe
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td>';
|
||||
print $langs->trans("External");
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$commande->client->id;
|
||||
$selectedCompany = select_societes_for_newconcat($commande, $selectedCompany, $htmlname = 'newcompany');
|
||||
print '</td>';
|
||||
|
||||
print '<td colspan="1">';
|
||||
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
select_type_contact($commande, '', 'type','external');
|
||||
print '</td>';
|
||||
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</form>";
|
||||
|
||||
print '<tr><td colspan="6"> </td></tr>';
|
||||
}
|
||||
|
||||
// Liste des contacts liés
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Source").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Contacts").'</td>';
|
||||
print '<td>'.$langs->trans("ContactType").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$societe = new Societe($db);
|
||||
$var = true;
|
||||
|
||||
foreach(array('internal','external') as $source)
|
||||
{
|
||||
$tab = $commande->liste_contact(-1,$source);
|
||||
$num=sizeof($tab);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$var = !$var;
|
||||
|
||||
print '<tr '.$bc[$var].' valign="top">';
|
||||
|
||||
// Source
|
||||
print '<td align="left">';
|
||||
if ($tab[$i]['source']=='internal') print $langs->trans("Internal");
|
||||
if ($tab[$i]['source']=='external') print $langs->trans("External");
|
||||
print '</td>';
|
||||
|
||||
// Societe
|
||||
print '<td align="left">';
|
||||
if ($tab[$i]['socid'] > 0)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$tab[$i]['socid'].'">';
|
||||
print img_object($langs->trans("ShowCompany"),"company").' '.$societe->get_nom($tab[$i]['socid']);
|
||||
print '</a>';
|
||||
}
|
||||
if ($tab[$i]['socid'] < 0)
|
||||
{
|
||||
print $conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
}
|
||||
if (! $tab[$i]['socid'])
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Contact
|
||||
print '<td>';
|
||||
if ($tab[$i]['source']=='internal')
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$tab[$i]['id'].'">';
|
||||
print img_object($langs->trans("ShowUser"),"user").' '.$tab[$i]['nom'].'</a>';
|
||||
}
|
||||
if ($tab[$i]['source']=='external')
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$tab[$i]['id'].'">';
|
||||
print img_object($langs->trans("ShowContact"),"contact").' '.$tab[$i]['nom'].'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Type de contact
|
||||
print '<td>'.$tab[$i]['libelle'].'</td>';
|
||||
|
||||
// Statut
|
||||
print '<td align="center">';
|
||||
// Activation desativation du contact
|
||||
if ($commande->statut >= 0)
|
||||
print '<a href="contact.php?id='.$commande->id.'&action=swapstatut&ligne='.$tab[$i]['rowid'].'">';
|
||||
print img_statut($tab[$i]['status']);
|
||||
|
||||
if ($commande->statut >= 0)
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
|
||||
// Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé)
|
||||
print '<td align="center" nowrap>';
|
||||
if ($commande->statut == 0 && $user->rights->facture->creer)
|
||||
{
|
||||
print ' ';
|
||||
print '<a href="contact.php?id='.$commande->id.'&action=deleteline&lineid='.$tab[$i]['rowid'].'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i ++;
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Contrat non trouvé
|
||||
print "Contrat inexistant ou accés refusé";
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$');
|
||||
?>
|
||||
@ -766,6 +766,11 @@ else
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans('Info');
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans('OrderContact');
|
||||
$h++;
|
||||
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans('Order').': '.$commande->ref);
|
||||
|
||||
|
||||
@ -82,6 +82,10 @@ $h = 0;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans('OrderContact');
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
|
||||
|
||||
|
||||
@ -121,6 +121,10 @@ if ($_GET["id"] > 0)
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans('OrderContact');
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
|
||||
|
||||
|
||||
@ -121,6 +121,10 @@ if ($_GET["id"] > 0)
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans('OrderContact');
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
|
||||
|
||||
|
||||
@ -470,15 +470,17 @@ class Expedition
|
||||
|
||||
$pdf = new $mod($this->db);
|
||||
|
||||
$dir = $conf->expedition->dir_output . "/" .get_exdir($this->id);
|
||||
//$dir = $conf->expedition->dir_output . "/" .get_exdir($this->id); //test
|
||||
$dir = $conf->expedition->dir_output . "/" .$this->ref;
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
create_exdir($dir);
|
||||
}
|
||||
|
||||
$file = $dir . $this->id . ".pdf";
|
||||
|
||||
//$file = $dir . $this->id . ".pdf"; //test
|
||||
$file = $dir . $this->ref . ".pdf";
|
||||
|
||||
if (file_exists($dir))
|
||||
{
|
||||
$pdf->generate($this, $file);
|
||||
|
||||
@ -500,9 +500,16 @@ else
|
||||
/*
|
||||
* Documents générés
|
||||
*/
|
||||
$filename=sanitize_string($expedition->id);
|
||||
$filedir=$conf->expedition->dir_output . "/" .get_exdir($expedition->id);
|
||||
|
||||
//mis en commentaire pour test du patch
|
||||
//$filename=sanitize_string($expedition->id);
|
||||
//$filedir=$conf->expedition->dir_output . "/" .get_exdir($expedition->id);
|
||||
|
||||
$filename=sanitize_string($expedition->ref);
|
||||
$filedir=$conf->expedition->dir_output . "/" .$expedition->ref;
|
||||
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$expedition->id;
|
||||
|
||||
//$genallowed=$user->rights->expedition->creer;
|
||||
//$delallowed=$user->rights->expedition->supprimer;
|
||||
$genallowed=0;
|
||||
@ -594,6 +601,7 @@ else
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
print '<br>';
|
||||
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
|
||||
print_titre("Documents");
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
@ -10,11 +10,11 @@ Pris
|
||||
|
||||
- rouget
|
||||
- dorade
|
||||
- mérou
|
||||
|
||||
|
||||
Disponibles
|
||||
|
||||
- mérou
|
||||
- ombrine
|
||||
- mulet
|
||||
- maquereau
|
||||
391
htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php
Normal file
391
htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php
Normal file
@ -0,0 +1,391 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/ModelePdfExpedition.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/contact.class.php";
|
||||
|
||||
Class pdf_expedition_merou extends ModelePdfExpedition{
|
||||
|
||||
function pdf_expedition_merou($db=0){
|
||||
$this->db = $db;
|
||||
$this->name = "Merou";
|
||||
$this->description = "Modele Merou 2xA5 \n
|
||||
Attention !! Il est nécessaire de creer 4 nouveaux types de contact : \n
|
||||
|element->commande,source->internal,code->LIVREUR \n
|
||||
|element->commande,source->external,code->LIVREUR \n
|
||||
|element->commande,source->external,code->EXPEDITEUR \n
|
||||
|element->commande,source->external,code->DESTINATAIRE \n
|
||||
";
|
||||
}
|
||||
|
||||
//*****************************
|
||||
//Creation du Document
|
||||
//Initialisation des données
|
||||
//*****************************
|
||||
function generate(&$objExpe){
|
||||
global $user,$langs,$conf;
|
||||
//Initialisation des langues
|
||||
$langs->load("main");
|
||||
$langs->load("bills");
|
||||
$langs->load("products");
|
||||
//Generation de la fiche
|
||||
$this->expe = $objExpe;
|
||||
$this->expe->fetch_commande();
|
||||
//Creation du Client
|
||||
$this->soc = new Societe($this->db);
|
||||
$this->soc->fetch($this->expe->commande->soc_id);
|
||||
//Creation de l expediteur
|
||||
$this->expediteur = $this->soc;
|
||||
//Creation du destinataire
|
||||
$this->destinataire = new Contact($this->db);
|
||||
// $this->expe->commande->fetch($this->commande->id);
|
||||
//print_r($this->expe);
|
||||
$idcontact = $this->expe->commande->getIdContact('external','DESTINATAIRE');
|
||||
$this->destinataire->fetch($idcontact[0]);
|
||||
//Creation du livreur
|
||||
$idcontact = $this->expe->commande->getIdContact('internal','LIVREUR');
|
||||
$this->livreur = new User($this->db,$idcontact[0]);
|
||||
$this->livreur->fetch();
|
||||
|
||||
//Verificatio nde la configuration
|
||||
if ($conf->expedition->dir_output){
|
||||
$forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
|
||||
$expref = str_replace($forbidden_chars,"_",$this->expe->ref);
|
||||
$dir = $conf->expedition->dir_output . "/" . $this->expe->ref . "/" ;
|
||||
$file = $dir .$this->expe->ref . ".pdf";
|
||||
//Si le dossier n existe pas
|
||||
if (! file_exists($dir)){
|
||||
umask(0);
|
||||
//On tente de le creer
|
||||
if (! mkdir($dir, 0755)){
|
||||
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//Si le dossier existe
|
||||
if (file_exists($dir)){
|
||||
// Initialisation Bon vierge
|
||||
$this->FPDF('l','mm','A5');
|
||||
$this->Open();
|
||||
$this->AddPage();
|
||||
//Generation de l entete du fichier
|
||||
$this->SetTitle($this->expe->ref);
|
||||
$this->SetSubject($langs->trans("Sending"));
|
||||
$this->SetCreator("EXPRESSIV Dolibarr ".DOL_VERSION);
|
||||
$this->SetAuthor($user->fullname);
|
||||
$this->SetMargins(10, 10, 10);
|
||||
$this->SetAutoPageBreak(1,0);
|
||||
//Insertion de l entete
|
||||
$this->_pagehead($this->expe);
|
||||
//Initiailisation des coordonnées
|
||||
$tab_top = 53;
|
||||
$tab_height = 70;
|
||||
$this->SetFillColor(240,240,240);
|
||||
$this->SetTextColor(0,0,0);
|
||||
$this->SetFont('Arial','', 7);
|
||||
$this->SetXY (10, $tab_top + 5 );
|
||||
$iniY = $this->GetY();
|
||||
$curY = $this->GetY();
|
||||
$nexY = $this->GetY();
|
||||
//Generation du tableau
|
||||
$this->_tableau($tab_top, $tab_height, $nexY);
|
||||
//Recuperation des produits de la commande.
|
||||
$this->expe->commande->fetch_lignes();
|
||||
$Produits = $this->expe->commande->lignes;
|
||||
$nblignes = sizeof($Produits);
|
||||
for ($i = 0 ; $i < $nblignes ; $i++){
|
||||
//Generation du produit
|
||||
$Prod = new Product($this->db);
|
||||
$Prod->fetch($Produits[$i]->product_id);
|
||||
//Creation des cases à cocher
|
||||
$this->rect(10+3, $curY+1, 3, 3);
|
||||
$this->rect(20+3, $curY+1, 3, 3);
|
||||
//Insertion de la reference du produit
|
||||
$this->SetXY (30, $curY );
|
||||
$this->SetFont('Arial','B', 7);
|
||||
$this->MultiCell(20, 5, $Prod->ref, 0, 'L', 0);
|
||||
//Insertion du libelle
|
||||
$this->SetFont('Arial','', 7);
|
||||
$this->SetXY (50, $curY );
|
||||
$this->MultiCell(130, 5, stripslashes($Prod->libelle), 0, 'L', 0);
|
||||
//Insertion de la quantite
|
||||
$this->SetFont('Arial','', 7);
|
||||
$this->SetXY (180, $curY );
|
||||
$this->MultiCell(20, 5, $Produits[$i]->qty, 0, 'L', 0);
|
||||
//Generation de la page 2
|
||||
$curY += 4;
|
||||
$nexY = $curY;
|
||||
if ($nexY > ($tab_top+$tab_height-10) && $i < $nblignes - 1){
|
||||
$this->_tableau($tab_top, $tab_height, $nexY);
|
||||
$this->_pagefoot();
|
||||
$this->AliasNbPages();
|
||||
$this->AddPage();
|
||||
$nexY = $iniY;
|
||||
$this->_pagehead($this->expe);
|
||||
$this->SetTextColor(0,0,0);
|
||||
$this->SetFont('Arial','', 7);
|
||||
}
|
||||
}
|
||||
//Insertio ndu pied de page
|
||||
$this->_pagefoot($propale);
|
||||
$this->AliasNbPages();
|
||||
//Cloture du pdf
|
||||
$this->Close();
|
||||
//Ecriture du pdf
|
||||
$this->Output($file);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//********************************
|
||||
// Generation du tableau
|
||||
//********************************
|
||||
function _tableau($tab_top, $tab_height, $nexY){
|
||||
global $langs;
|
||||
$langs->load("main");
|
||||
$langs->load("bills");
|
||||
$this->SetFont('Arial','B',8);
|
||||
$this->SetXY(10,$tab_top);
|
||||
$this->MultiCell(10,5,"LS",0,'C',1);
|
||||
$this->line(20, $tab_top, 20, $tab_top + $tab_height);
|
||||
$this->SetXY(20,$tab_top);
|
||||
$this->MultiCell(10,5,"LR",0,'C',1);
|
||||
$this->line(30, $tab_top, 30, $tab_top + $tab_height);
|
||||
$this->SetXY(30,$tab_top);
|
||||
$this->MultiCell(20,5,$langs->trans("Ref"),0,'C',1);
|
||||
$this->SetXY(50,$tab_top);
|
||||
$this->MultiCell(130,5,$langs->trans("Description"),0,'L',1);
|
||||
$this->SetXY(180,$tab_top);
|
||||
$this->MultiCell(20,5,$langs->trans("Quantity"),0,'L',1);
|
||||
$this->Rect(10, $tab_top, 190, $tab_height);
|
||||
}
|
||||
|
||||
//********************************
|
||||
// Generation du Pied de page
|
||||
//********************************
|
||||
function _pagefoot(){
|
||||
$this->SetFont('Arial','',8);
|
||||
$this->SetY(-23);
|
||||
$this->MultiCell(100, 3, "Déclare avoir reçu les marchandises ci-dessus en bon état,", 0, 'L');
|
||||
$this->SetY(-13);
|
||||
$this->MultiCell(100, 3, "A___________________________________ le ____/_____/__________" , 0, 'C');
|
||||
$this->SetXY(120,-23);
|
||||
$this->MultiCell(100, 3, "Nom et Signature : " , 0, 'C');
|
||||
$this->SetXY(-10,-10);
|
||||
$this->MultiCell(10, 3, $this->PageNo().'/{nb}', 0, 'R');
|
||||
}
|
||||
|
||||
|
||||
//********************************
|
||||
// Generation de l entete
|
||||
//********************************
|
||||
function _pagehead($exp){
|
||||
GLOBAL $langs;
|
||||
$tab4_top = 60;
|
||||
$tab4_hl = 6;
|
||||
$tab4_sl = 4;
|
||||
$ligne = 2;
|
||||
//*********************LOGO****************************
|
||||
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO){
|
||||
$this->SetXY(10,5);
|
||||
if (file_exists(FAC_PDF_LOGO)) {
|
||||
$this->Image(FAC_PDF_LOGO, 10, 5,85.0, 17.0, 'PNG');
|
||||
}else {
|
||||
//Cas Erreur Fichier introuvable
|
||||
$this->SetTextColor(200,0,0);
|
||||
$this->SetFont('Arial','B',8);
|
||||
$this->MultiCell(80, 3, $langs->trans("ErrorLogoFileNotFound",FAC_PDF_LOGO), 0, 'L');
|
||||
$this->MultiCell(80, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L');
|
||||
}
|
||||
}else if (defined("FAC_PDF_INTITULE")){
|
||||
$this->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L');
|
||||
}
|
||||
//*********************Entete****************************
|
||||
//Nom du Document
|
||||
$Yoff = 0;
|
||||
$this->SetXY(60,7);
|
||||
$this->SetFont('Arial','B',14);
|
||||
$this->SetTextColor(0,0,0);
|
||||
$this->MultiCell(0, 8, "BON DE LIVRAISON", '' , 'L');
|
||||
//Num Expedition
|
||||
$Yoff = $Yoff+7;
|
||||
$Xoff = 115;
|
||||
// $this->rect($Xoff, $Yoff, 85, 8);
|
||||
$this->SetXY($Xoff,$Yoff);
|
||||
$this->SetFont('Arial','',8);
|
||||
$this->SetTextColor(0,0,0);
|
||||
$this->MultiCell(0, 8, "Num Bon de Livraison : ".$exp->ref, '' , 'L');
|
||||
$this->Code39($Xoff+43, $Yoff+1, $this->expe->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
|
||||
//Num Commande
|
||||
$Yoff = $Yoff+10;
|
||||
// $this->rect($Xoff, $Yoff, 85, 8);
|
||||
$this->SetXY($Xoff,$Yoff);
|
||||
$this->SetFont('Arial','',8);
|
||||
$this->SetTextColor(0,0,0);
|
||||
$this->MultiCell(0, 8, "Num Commande : ".$exp->commande->ref, '' , 'L');
|
||||
$this->Code39($Xoff+43, $Yoff+1, $exp->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
|
||||
//Definition Emplacement du bloc Societe
|
||||
$blSocX=11;
|
||||
$blSocY=25;
|
||||
$blSocW=50;
|
||||
$blSocX2=$blSocW+$blSocXs;
|
||||
$this->SetTextColor(0,0,0);
|
||||
//Adresse Internet
|
||||
if (defined("FAC_PDF_WWW")){
|
||||
$this->SetXY($blSocX,$blSocY);
|
||||
$this->SetFont('Arial','B',8);
|
||||
$this->MultiCell($blSocW, 3, FAC_PDF_WWW, '' , 'L');
|
||||
}
|
||||
if (defined("FAC_PDF_ADRESSE")){
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->SetXY($blSocX,$blSocY+3);
|
||||
$this->MultiCell($blSocW, 3, FAC_PDF_ADRESSE, '' , 'L');
|
||||
}
|
||||
|
||||
if (defined("FAC_PDF_ADRESSE2")){
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->SetXY($blSocX,$blSocY+6);
|
||||
$this->MultiCell($blSocW, 3, FAC_PDF_ADRESSE2, '' , 'L');
|
||||
}
|
||||
|
||||
if (defined("FAC_PDF_TEL")){
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->SetXY($blSocX,$blSocY+10);
|
||||
$this->MultiCell($blSocW, 3, "Tel : " . FAC_PDF_TEL, '' , 'L');
|
||||
}
|
||||
|
||||
if (defined("FAC_PDF_MEL")){
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->SetXY($blSocX,$blSocY+13);
|
||||
$this->MultiCell(40, 3, "Email : " . FAC_PDF_MEL, '' , 'L');
|
||||
}
|
||||
|
||||
if (defined("FAC_PDF_FAX")){
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->SetXY($blSocX,$blSocY+16);
|
||||
$this->MultiCell(40, 3, "Fax : " . FAC_PDF_FAX, '' , 'L');
|
||||
}
|
||||
|
||||
if (defined("MAIN_INFO_SIRET")){
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->SetXY($blSocX2,$blSocY+10);
|
||||
$this->MultiCell($blSocW, 3, "SIRET : " . MAIN_INFO_SIRET, '' , 'L');
|
||||
}
|
||||
|
||||
if (defined("MAIN_INFO_APE")){
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->SetXY($blSocX2,$blSocY+13);
|
||||
$this->MultiCell($blSocW, 3, "APE : " . MAIN_INFO_APE, '' , 'L');
|
||||
}
|
||||
|
||||
if (defined("MAIN_INFO_TVAINTRA")){
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->SetXY($blSocX2,$blSocY+16);
|
||||
$this->MultiCell($blSocW, 3, "ICOMM : " . MAIN_INFO_TVAINTRA, '' , 'L');
|
||||
}
|
||||
|
||||
//Date Expedition
|
||||
$Yoff = $Yoff+7;
|
||||
$this->SetXY($blSocX,$blSocY+20);
|
||||
$this->SetFont('Arial','B',8);
|
||||
$this->SetTextColor(0,0,0);
|
||||
$this->MultiCell(50, 8, "Date : " . strftime("%d %b %Y", $exp->date), '' , 'L');
|
||||
//Date Expedition
|
||||
$this->SetXY($blSocX2,$blSocY+20);
|
||||
$this->SetFont('Arial','B',8);
|
||||
$this->SetTextColor(0,0,0);
|
||||
$this->MultiCell(50, 8, "Livreur(s) : ".$this->livreur->fullname, '' , 'L');
|
||||
/**********************************/
|
||||
//Emplacement Informations Expediteur (Client)
|
||||
/**********************************/
|
||||
$Ydef = $Yoff;
|
||||
$blExpX=$Xoff-20;
|
||||
$blW=50;
|
||||
$Yoff = $Yoff+5;
|
||||
$Ydef = $Yoff;
|
||||
$blSocY = 1;
|
||||
//Titre
|
||||
$this->SetXY($blExpX,$Yoff-3);
|
||||
$this->SetFont('Arial','B',7);
|
||||
$this->MultiCell($blW,3, 'Expéditeur', 0, 'L');
|
||||
$this->Rect($blExpX, $Yoff, $blW, 20);
|
||||
//Nom Client
|
||||
$this->SetXY($blExpX,$Yoff+$blSocY);
|
||||
$this->SetFont('Arial','B',7);
|
||||
$this->MultiCell($blW,3, $this->expediteur->nom, 0, 'C');
|
||||
$this->SetFont('Arial','',7);
|
||||
$blSocY+=3;
|
||||
//Adresse Client
|
||||
//Gestion des Retours chariots
|
||||
$Out=split("\n",$this->expediteur->adresse);
|
||||
for ($i=0;$i<count($Out);$i++) {
|
||||
$this->SetXY($blExpX,$Yoff+$blSocY);
|
||||
$this->MultiCell($blW,5,urldecode($Out[$i]), 0, 'L');
|
||||
$blSocY+=3;
|
||||
}
|
||||
$this->SetXY($blExpX,$Yoff+$blSocY);
|
||||
$this->MultiCell($blW,5, $this->expediteur->cp . " " . $this->expediteur->ville, 0, 'L');
|
||||
$blSocY+=4;
|
||||
//Tel Client
|
||||
$this->SetXY($blExpX,$Yoff+$blSocY);
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->MultiCell($blW,3, "Tel : ".$this->expediteur->tel, 0, 'L');
|
||||
|
||||
/**********************************/
|
||||
//Emplacement Informations Destinataire (Contact livraison)
|
||||
/**********************************/
|
||||
$blDestX=$blExpX+55;
|
||||
$blW=50;
|
||||
$Yoff = $Ydef;
|
||||
$blSocY = 1;
|
||||
//Titre
|
||||
$this->SetXY($blDestX,$Yoff-3);
|
||||
$this->SetFont('Arial','B',7);
|
||||
$this->MultiCell($blW,3, 'Destinataire', 0, 'L');
|
||||
$this->Rect($blDestX, $Yoff, $blW, 20);
|
||||
//Nom Client
|
||||
$this->SetXY($blDestX,$Yoff+$blSocY);
|
||||
$this->SetFont('Arial','B',7);
|
||||
$this->MultiCell($blW,3, $this->destinataire->fullname, 0, 'C');
|
||||
$this->SetFont('Arial','',7);
|
||||
$blSocY+=3;
|
||||
//Adresse Client
|
||||
//Gestion des Retours chariots
|
||||
$Out=split("\n",$this->destinataire->address);
|
||||
for ($i=0;$i<count($Out);$i++) {
|
||||
$this->SetXY($blDestX,$Yoff+$blSocY);
|
||||
$this->MultiCell($blW,5,urldecode($Out[$i]), 0, 'L');
|
||||
$blSocY+=3;
|
||||
}
|
||||
$this->SetXY($blDestX,$Yoff+$blSocY);
|
||||
$this->MultiCell($blW,5, $this->destinataire->cp . " " . $this->destinataire->ville, 0, 'L');
|
||||
$blSocY+=4;
|
||||
//Tel Client
|
||||
$this->SetXY($blDestX,$Yoff+$blSocY);
|
||||
$this->SetFont('Arial','',7);
|
||||
$this->MultiCell($blW,3, "Tel : ".$this->destinataire->phone_pro, 0, 'L');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -453,19 +453,19 @@ class Livraison
|
||||
{
|
||||
global $conf;
|
||||
|
||||
//EXPEDITION_ADDON_PDF
|
||||
if (defined("EXPEDITION_ADDON_PDF") && strlen(EXPEDITION_ADDON_PDF) > 0)
|
||||
//LIVRAISON_ADDON_PDF
|
||||
if (defined("LIVRAISON_ADDON_PDF") && strlen(LIVRAISON_ADDON_PDF) > 0)
|
||||
{
|
||||
$module_file_name = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/pdf_expedition_".EXPEDITION_ADDON_PDF.".modules.php";
|
||||
$module_file_name = DOL_DOCUMENT_ROOT."/livraison/mods/pdf/pdf_".LIVRAISON_ADDON_PDF.".modules.php";
|
||||
|
||||
$mod = "pdf_expedition_".EXPEDITION_ADDON_PDF;
|
||||
$mod = "pdf_".LIVRAISON_ADDON_PDF;
|
||||
$this->fetch_commande();
|
||||
|
||||
require_once($module_file_name);
|
||||
|
||||
$pdf = new $mod($this->db);
|
||||
|
||||
$dir = $conf->expedition->dir_output . "/" .get_exdir($this->id);
|
||||
$dir = $conf->livraison->dir_output . "/" .get_exdir($this->id);
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
@ -496,13 +496,15 @@ class Livraison
|
||||
{
|
||||
$this->lignes = array();
|
||||
|
||||
$sql = "SELECT c.description, c.qty as qtycom, e.qty as qtyexp";
|
||||
$sql .= ", c.fk_product";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as e";
|
||||
$sql = "SELECT c.label, c.description, c.qty as qtycom, l.qty as qtyliv";
|
||||
$sql .= ", c.fk_product, c.price, p.ref";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."livraisondet as l";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."commandedet as c";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."product as p";
|
||||
|
||||
$sql .= " WHERE e.fk_expedition = ".$this->id;
|
||||
$sql .= " AND e.fk_commande_ligne = c.rowid";
|
||||
$sql .= " WHERE l.fk_livraison = ".$this->id;
|
||||
$sql .= " AND l.fk_commande_ligne = c.rowid";
|
||||
$sql .= " AND c.fk_product = p.rowid";
|
||||
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
@ -512,14 +514,17 @@ class Livraison
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$ligne = new ExpeditionLigne();
|
||||
$ligne = new LivraisonLigne();
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$ligne->product_id = $obj->fk_product;
|
||||
$ligne->qty_commande = $obj->qtycom;
|
||||
$ligne->qty_expedition = $obj->qtyexp;
|
||||
$ligne->description = stripslashes($obj->description);
|
||||
$ligne->qty_livre = $obj->qtyliv;
|
||||
$ligne->ref = $obj->ref;
|
||||
$ligne->label = stripslashes($obj->label);
|
||||
$ligne->description = stripslashes($obj->description);
|
||||
$ligne->price = $obj->price;
|
||||
|
||||
$this->lignes[$i] = $ligne;
|
||||
$i++;
|
||||
@ -533,7 +538,7 @@ class Livraison
|
||||
}
|
||||
|
||||
|
||||
class ExpeditionLigne
|
||||
class LivraisonLigne
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -860,3 +860,8 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'SHIPPING', 'Contact client livraison', 1);
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (62, 'facture', 'external', 'SERVICE', 'Contact client prestation', 1);
|
||||
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (90, 'commande', 'internal', 'SALESREPSIGN', 'Commercial signataire de la commande', 1);
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (91, 'commande', 'internal', 'SALESREPFOLL', 'Commercial suivi de la commande', 1);
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (100, 'commande', 'external', 'BILLING', 'Contact client facturation commande', 1);
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (101, 'commande', 'external', 'CUSTOMER', 'Contact client suivi commande', 1);
|
||||
|
||||
|
||||
@ -222,4 +222,9 @@ create table llx_livraisondet
|
||||
)type=innodb;
|
||||
|
||||
ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_soc (fk_soc);
|
||||
ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp);
|
||||
ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp);
|
||||
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (90, 'commande', 'internal', 'SALESREPSIGN', 'Commercial signataire de la commande', 1);
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (91, 'commande', 'internal', 'SALESREPFOLL', 'Commercial suivi de la commande', 1);
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (100, 'commande', 'external', 'BILLING', 'Contact client facturation commande', 1);
|
||||
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (101, 'commande', 'external', 'CUSTOMER', 'Contact client suivi commande', 1);
|
||||
Loading…
Reference in New Issue
Block a user