From 60be0193b07d11348f01d45eb23aa0ab64494c44 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 26 Jan 2015 17:21:35 +0100 Subject: [PATCH 001/120] [CORE] Initialisation global du module askpricesupplier (#new_ask_price). --- htdocs/comm/askpricesupplier/apercu.php | 221 ++ .../class/askpricesupplier.class.php | 3211 +++++++++++++++++ htdocs/comm/askpricesupplier/class/index.html | 0 htdocs/comm/askpricesupplier/contact.php | 223 ++ htdocs/comm/askpricesupplier/document.php | 144 + htdocs/comm/askpricesupplier/index.php | 528 +++ htdocs/comm/askpricesupplier/info.php | 65 + htdocs/comm/askpricesupplier/list.php | 464 +++ htdocs/comm/askpricesupplier/note.php | 151 + htdocs/comm/askpricesupplier/tpl/index.html | 0 .../tpl/linkedobjectblock.tpl.php | 79 + .../modules/modAskPriceSupplier.class.php | 226 ++ htdocs/langs/fr_FR/askpricesupplier.lang | 6 + .../eldy/img/object_askpricesupplier.png | Bin 0 -> 1038 bytes 14 files changed, 5318 insertions(+) create mode 100644 htdocs/comm/askpricesupplier/apercu.php create mode 100644 htdocs/comm/askpricesupplier/class/askpricesupplier.class.php create mode 100644 htdocs/comm/askpricesupplier/class/index.html create mode 100644 htdocs/comm/askpricesupplier/contact.php create mode 100644 htdocs/comm/askpricesupplier/document.php create mode 100644 htdocs/comm/askpricesupplier/index.php create mode 100644 htdocs/comm/askpricesupplier/info.php create mode 100644 htdocs/comm/askpricesupplier/list.php create mode 100644 htdocs/comm/askpricesupplier/note.php create mode 100644 htdocs/comm/askpricesupplier/tpl/index.html create mode 100644 htdocs/comm/askpricesupplier/tpl/linkedobjectblock.tpl.php create mode 100644 htdocs/core/modules/modAskPriceSupplier.class.php create mode 100644 htdocs/langs/fr_FR/askpricesupplier.lang create mode 100644 htdocs/theme/eldy/img/object_askpricesupplier.png diff --git a/htdocs/comm/askpricesupplier/apercu.php b/htdocs/comm/askpricesupplier/apercu.php new file mode 100644 index 00000000000..87281e7ea63 --- /dev/null +++ b/htdocs/comm/askpricesupplier/apercu.php @@ -0,0 +1,221 @@ + + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2014 Frederic France + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/apercu.php + * \ingroup propal + * \brief Preview tab of propal + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + +$langs->load('propal'); +$langs->load("bills"); +$langs->load('compta'); + +// Security check +$socid=0; +$id = GETPOST('id','int'); +$ref = GETPOST("ref"); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'propal', $id); + + +/* + * View Mode + */ + +llxHeader(); + + +if ($id > 0 || ! empty($ref)) +{ + $object = new Propal($db); + + if ($object->fetch($id,$ref) > 0) + { + $soc = new Societe($db); + $soc->fetch($object->socid); + + $head = propal_prepare_head($object); + dol_fiche_head($head, 'preview', $langs->trans('Proposal'), 0, 'propal'); + + + /* + * Propal + */ + print ''; + + // Ref + print ''; + print ''; + print ''; + + // Ref client + print ''; + print ''; + print ''; + + + // Thirdparty + print ''; + print ''; + print ''; + + // Status + print ''; + print ''; + print ''; + + // Discount + print ''; + print ''; + + // Date + print ''; + print ''; + + // Right part with $rowspan lines + $rowspan=4; + print ''; + print ''; + + // Total HT - left part + print ''; + print ''; + print ''; + + // Total VAT - left part + print ''; + print ''; + print ''; + + // Total TTC - left part + print ''; + print ''; + print ''; + + print '
'.$langs->trans('Ref').''.$object->ref.'
'.$langs->trans('RefCustomer').''.$object->ref_client.'
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans('Discounts').''; + if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount=$soc->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.
'.$langs->trans('Date').''.dol_print_date($object->date,'daytext').''; + + /* + * Documents + */ + $objectref = dol_sanitizeFileName($object->ref); + $dir_output = $conf->propal->dir_output . "/"; + $filepath = $dir_output . $objectref . "/"; + $file = $filepath . $objectref . ".pdf"; + $filedetail = $filepath . $objectref . "-detail.pdf"; + $relativepath = $objectref.'/'.$objectref.'.pdf'; + $relativepathdetail = $objectref.'/'.$objectref.'-detail.pdf'; + + // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png") + $fileimage = $file.'_preview.png'; // If PDF has 1 page + $fileimagebis = $file.'_preview-0.pdf.png'; // If PDF has more than one page + $relativepathimage = $relativepath.'_preview.png'; + + $var=true; + + // Si fichier PDF existe + if (file_exists($file)) + { + $encfile = urlencode($file); + print ''; + print ''; + + print ''; + + print ''; + + print ''; + print ''; + print ''; + + print "
'.$langs->trans("Documents").'
'.$langs->trans("Proposal").' PDF'.$object->ref.'.pdf'.dol_print_size(dol_filesize($file)).''.dol_print_date(dol_filemtime($file),'dayhour').'
\n"; + + // Conversion du PDF en image png si fichier png non existant + if (! file_exists($fileimage) && ! file_exists($fileimagebis)) + { + if (class_exists("Imagick")) + { + $ret = dol_convert_file($file,'png',$fileimage); + if ($ret < 0) $error++; + } + else + { + $langs->load("errors"); + print ''.$langs->trans("ErrorNoImagickReadimage").''; + } + } + } + + print '
'.$langs->trans('AmountHT').'' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
'.$langs->trans('AmountVAT').'' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
'.$langs->trans('AmountTTC').'' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
'; + + dol_fiche_end(); + } + else + { + // Propal non trouvee + print $langs->trans("ErrorPropalNotFound",$_GET["id"]); + } +} + +print ''; +print ''; +print '
'; +print '
'; +// Si fichier png PDF d'1 page trouve +if (file_exists($fileimage)) +{ + print ''; +} +// Si fichier png PDF de plus d'1 page trouve +elseif (file_exists($fileimagebis)) +{ + $multiple = preg_replace('/\.png/','',$relativepath) . "-"; + + for ($i = 0; $i < 20; $i++) + { + $preview = $multiple.$i.'.png'; + + if (file_exists($dir_output.$preview)) + { + print '

'; + } + } +} +print '

'; +print '
'; + + +llxFooter(); + +$db->close(); diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php new file mode 100644 index 00000000000..f68a1f4f708 --- /dev/null +++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php @@ -0,0 +1,3211 @@ + + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley + * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2008 Raphael Bertrand + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2011 Philippe Grand + * Copyright (C) 2012-2014 Christophe Battarel + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2014 Marcos García + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/class/propal.class.php + * \brief File of class to manage proposals + */ + +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php'; + +/** + * Class to manage proposals + */ +class Propal extends CommonObject +{ + public $element='propal'; + public $table_element='propal'; + public $table_element_line='propaldet'; + public $fk_element='fk_propal'; + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + + /** + * {@inheritdoc} + */ + protected $table_ref_field = 'ref'; + + var $id; + + var $socid; // Id client + var $client; // Objet societe client (a charger par fetch_client) + + var $contactid; + var $fk_project; + var $author; + var $ref; + var $ref_client; + var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed) + var $datec; // Date of creation + var $datev; // Date of validation + var $date; // Date of proposal + var $datep; // Same than date + var $date_livraison; + var $fin_validite; + + var $user_author_id; + var $user_valid_id; + var $user_close_id; + + var $total_ht; // Total net of tax + var $total_tva; // Total VAT + var $total_localtax1; // Total Local Taxes 1 + var $total_localtax2; // Total Local Taxes 2 + var $total_ttc; // Total with tax + var $price; // deprecated (for compatibility) + var $tva; // deprecated (for compatibility) + var $total; // deprecated (for compatibility) + + var $cond_reglement_id; + var $cond_reglement_code; + var $fk_account; // Id of bank account + var $mode_reglement_id; + var $mode_reglement_code; + var $remise; + var $remise_percent; + var $remise_absolue; + var $note; // deprecated (for compatibility) + var $note_private; + var $note_public; + var $fk_delivery_address; // deprecated (for compatibility) + var $fk_address; + var $address_type; + var $address; + var $shipping_method_id; + var $availability_id; + var $availability_code; + var $demand_reason_id; + var $demand_reason_code; + + var $products=array(); + var $extraparams=array(); + + var $lines = array(); + var $line; + + var $origin; + var $origin_id; + + var $labelstatut=array(); + var $labelstatut_short=array(); + + // Pour board + var $nbtodo; + var $nbtodolate; + + var $specimen; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party + * @param int $propalid Id proposal + */ + function __construct($db, $socid="", $propalid=0) + { + global $conf,$langs; + + $this->db = $db; + $this->socid = $socid; + $this->id = $propalid; + $this->products = array(); + $this->remise = 0; + $this->remise_percent = 0; + $this->remise_absolue = 0; + + $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; + + $langs->load("propal"); + $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); + $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); + $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); + $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); + $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); + $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); + $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); + $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); + $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); + $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); + } + + + /** + * Add line into array products + * $this->client doit etre charge + * + * @param int $idproduct Product Id to add + * @param int $qty Quantity + * @param int $remise_percent Discount effected on Product + * @return int <0 if KO, >0 if OK + * + * TODO Remplacer les appels a cette fonction par generation objet Ligne + * insere dans tableau $this->products + */ + function add_product($idproduct, $qty, $remise_percent=0) + { + global $conf, $mysoc; + + if (! $qty) $qty = 1; + + dol_syslog(get_class($this)."::add_product $idproduct, $qty, $remise_percent"); + if ($idproduct > 0) + { + $prod=new Product($this->db); + $prod->fetch($idproduct); + + $productdesc = $prod->description; + + $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); + // local taxes + $localtax1_tx = get_default_localtax($mysoc,$this->client,1,$prod->tva_tx); + $localtax2_tx = get_default_localtax($mysoc,$this->client,2,$prod->tva_tx); + + // multiprix + if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) + { + $price = $prod->multiprices[$this->client->price_level]; + } + else + { + $price = $prod->price; + } + + $line = new PropaleLigne($this->db); + + $line->fk_product=$idproduct; + $line->desc=$productdesc; + $line->qty=$qty; + $line->subprice=$price; + $line->remise_percent=$remise_percent; + $line->tva_tx=$tva_tx; + + $this->lines[]=$line; + } + } + + /** + * Adding line of fixed discount in the proposal in DB + * + * @param int $idremise Id of fixed discount + * @return int >0 if OK, <0 if KO + */ + function insert_discount($idremise) + { + global $langs; + + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + + $this->db->begin(); + + $remise=new DiscountAbsolute($this->db); + $result=$remise->fetch($idremise); + + if ($result > 0) + { + if ($remise->fk_facture) // Protection against multiple submission + { + $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); + $this->db->rollback(); + return -5; + } + + $propalligne=new PropaleLigne($this->db); + $propalligne->fk_propal=$this->id; + $propalligne->fk_remise_except=$remise->id; + $propalligne->desc=$remise->description; // Description ligne + $propalligne->tva_tx=$remise->tva_tx; + $propalligne->subprice=-$remise->amount_ht; + $propalligne->fk_product=0; // Id produit predefini + $propalligne->qty=1; + $propalligne->remise=0; + $propalligne->remise_percent=0; + $propalligne->rang=-1; + $propalligne->info_bits=2; + + // TODO deprecated + $propalligne->price=-$remise->amount_ht; + + $propalligne->total_ht = -$remise->amount_ht; + $propalligne->total_tva = -$remise->amount_tva; + $propalligne->total_ttc = -$remise->amount_ttc; + + $result=$propalligne->insert(); + if ($result > 0) + { + $result=$this->update_price(1); + if ($result > 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$propalligne->error; + $this->db->rollback(); + return -2; + } + } + else + { + $this->db->rollback(); + return -2; + } + } + + /** + * Add a proposal line into database (linked to product/service or not) + * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel + * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit) + * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) + * + * @param string $desc Description de la ligne + * @param double $pu_ht Prix unitaire + * @param double $qty Quantite + * @param double $txtva Taux de tva + * @param double $txlocaltax1 Local tax 1 rate + * @param double $txlocaltax2 Local tax 2 rate + * @param int $fk_product Id du produit/service predefini + * @param double $remise_percent Pourcentage de remise de la ligne + * @param string $price_base_type HT or TTC + * @param double $pu_ttc Prix unitaire TTC + * @param int $info_bits Bits de type de lignes + * @param int $type Type of line (product, service) + * @param int $rang Position of line + * @param int $special_code Special code (also used by externals modules!) + * @param int $fk_parent_line Id of parent line + * @param int $fk_fournprice Id supplier price + * @param int $pa_ht Buying price without tax + * @param string $label ??? + * @param int $date_start Start date of the line + * @param int $date_end End date of the line + * @param array $array_option extrafields array + * @return int >0 if OK, <0 if KO + * + * @see add_product + */ + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0) + { + global $mysoc; + + dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + + // Clean parameters + if (empty($remise_percent)) $remise_percent=0; + if (empty($qty)) $qty=0; + if (empty($info_bits)) $info_bits=0; + if (empty($rang)) $rang=0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + + $remise_percent=price2num($remise_percent); + $qty=price2num($qty); + $pu_ht=price2num($pu_ht); + $pu_ttc=price2num($pu_ttc); + $txtva=price2num($txtva); + $txlocaltax1=price2num($txlocaltax1); + $txlocaltax2=price2num($txlocaltax2); + $pa_ht=price2num($pa_ht); + if ($price_base_type=='HT') + { + $pu=$pu_ht; + } + else + { + $pu=$pu_ttc; + } + + // Check parameters + if ($type < 0) return -1; + + if ($this->statut == 0) + { + $this->db->begin(); + + // Calcul du total TTC et de la TVA pour la ligne a partir de + // qty, pu, remise_percent et txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + + $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); + + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, '', $localtaxes_type); + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + + // Rang to use + $rangtouse = $rang; + if ($rangtouse == -1) + { + $rangmax = $this->line_max($fk_parent_line); + $rangtouse = $rangmax + 1; + } + + // TODO A virer + // Anciens indicateurs: $price, $remise (a ne plus utiliser) + $price = $pu; + $remise = 0; + if ($remise_percent > 0) + { + $remise = round(($pu * $remise_percent / 100), 2); + $price = $pu - $remise; + } + + // Insert line + $this->line=new PropaleLigne($this->db); + + $this->line->fk_propal=$this->id; + $this->line->label=$label; + $this->line->desc=$desc; + $this->line->qty=$qty; + $this->line->tva_tx=$txtva; + $this->line->localtax1_tx=$txlocaltax1; + $this->line->localtax2_tx=$txlocaltax2; + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->fk_product=$fk_product; + $this->line->remise_percent=$remise_percent; + $this->line->subprice=$pu_ht; + $this->line->rang=$rangtouse; + $this->line->info_bits=$info_bits; + $this->line->total_ht=$total_ht; + $this->line->total_tva=$total_tva; + $this->line->total_localtax1=$total_localtax1; + $this->line->total_localtax2=$total_localtax2; + $this->line->total_ttc=$total_ttc; + $this->line->product_type=$type; + $this->line->special_code=$special_code; + $this->line->fk_parent_line=$fk_parent_line; + + $this->line->date_start=$date_start; + $this->line->date_end=$date_end; + + + // infos marge + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } + $this->line->pa_ht = $pa_ht; + + // Mise en option de la ligne + if (empty($qty) && empty($special_code)) $this->line->special_code=3; + + // TODO deprecated + $this->line->price=$price; + $this->line->remise=$remise; + + if (is_array($array_option) && count($array_option)>0) { + $this->line->array_options=$array_option; + } + + $result=$this->line->insert(); + if ($result > 0) + { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); + + // Mise a jour informations denormalisees au niveau de la propale meme + $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + if ($result > 0) + { + $this->db->commit(); + return $this->line->rowid; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$this->line->error; + $this->db->rollback(); + return -2; + } + } + } + + + /** + * Update a proposal line + * + * @param int $rowid Id de la ligne + * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) + * @param double $qty Quantity + * @param double $remise_percent Remise effectuee sur le produit + * @param double $txtva Taux de TVA + * @param double $txlocaltax1 Local tax 1 rate + * @param double $txlocaltax2 Local tax 2 rate + * @param string $desc Description + * @param double $price_base_type HT ou TTC + * @param int $info_bits Miscellaneous informations + * @param int $special_code Special code (also used by externals modules!) + * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). + * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) + * @param int $fk_fournprice Id of origin supplier price + * @param int $pa_ht Price (without tax) of product when it was bought + * @param string $label ??? + * @param int $type 0/1=Product/service + * @param int $date_start Start date of the line + * @param int $date_end End date of the line + * @param array $array_option extrafields array + * @return int 0 if OK, <0 if KO + */ + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_option=0) + { + global $conf,$user,$langs, $mysoc; + + dol_syslog(get_class($this)."::updateLine $rowid, $pu, $qty, $remise_percent, $txtva, $desc, $price_base_type, $info_bits"); + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + + // Clean parameters + $remise_percent=price2num($remise_percent); + $qty=price2num($qty); + $pu = price2num($pu); + $txtva = price2num($txtva); + $txlocaltax1=price2num($txlocaltax1); + $txlocaltax2=price2num($txlocaltax2); + $pa_ht=price2num($pa_ht); + if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag + if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag + + if ($this->statut == 0) + { + $this->db->begin(); + + // Calcul du total TTC et de la TVA pour la ligne a partir de + // qty, pu, remise_percent et txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + + $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); + + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type,'', $localtaxes_type); + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + + // Anciens indicateurs: $price, $remise (a ne plus utiliser) + $price = $pu; + if ($remise_percent > 0) + { + $remise = round(($pu * $remise_percent / 100), 2); + $price = $pu - $remise; + } + + // Update line + $this->line=new PropaleLigne($this->db); + + // Stock previous line records + $staticline=new PropaleLigne($this->db); + $staticline->fetch($rowid); + $this->line->oldline = $staticline; + + // Reorder if fk_parent_line change + if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + { + $rangmax = $this->line_max($fk_parent_line); + $this->line->rang = $rangmax + 1; + } + + $this->line->rowid = $rowid; + $this->line->label = $label; + $this->line->desc = $desc; + $this->line->qty = $qty; + $this->line->product_type = $type; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = $txlocaltax1; + $this->line->localtax2_tx = $txlocaltax2; + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->remise_percent = $remise_percent; + $this->line->subprice = $pu; + $this->line->info_bits = $info_bits; + $this->line->total_ht = $total_ht; + $this->line->total_tva = $total_tva; + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; + $this->line->total_ttc = $total_ttc; + $this->line->special_code = $special_code; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->skip_update_total = $skip_update_total; + + // infos marge + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } + $this->line->pa_ht = $pa_ht; + + $this->line->date_start=$date_start; + $this->line->date_end=$date_end; + + // TODO deprecated + $this->line->price=$price; + $this->line->remise=$remise; + + if (is_array($array_option) && count($array_option)>0) { + $this->line->array_options=$array_option; + } + + $result=$this->line->update(); + if ($result > 0) + { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); + + $this->update_price(1); + + $this->fk_propal = $this->id; + $this->rowid = $rowid; + + $this->db->commit(); + return $result; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + else + { + dol_syslog(get_class($this)."::updateline Erreur -2 Propal en mode incompatible pour cette action"); + return -2; + } + } + + + /** + * Delete detail line + * + * @param int $lineid Id of line to delete + * @return int >0 if OK, <0 if KO + */ + function deleteline($lineid) + { + if ($this->statut == 0) + { + $line=new PropaleLigne($this->db); + + // For triggers + $line->fetch($lineid); + + if ($line->delete() > 0) + { + $this->update_price(1); + + return 1; + } + else + { + return -1; + } + } + else + { + return -2; + } + } + + + /** + * Create commercial proposal into database + * this->ref can be set or empty. If empty, we will use "(PROVid)" + * + * @param User $user User that create + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if KO, >=0 if OK + */ + function create($user, $notrigger=0) + { + global $langs,$conf,$mysoc,$hookmanager; + $error=0; + + $now=dol_now(); + + // Clean parameters + if (empty($this->date)) $this->date=$this->datep; + $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); + if (empty($this->availability_id)) $this->availability_id=0; + if (empty($this->demand_reason_id)) $this->demand_reason_id=0; + + dol_syslog(get_class($this)."::create"); + + // Check parameters + $result=$this->fetch_thirdparty(); + if ($result < 0) + { + $this->error="Failed to fetch company"; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -3; + } + + // Check parameters + if (! empty($this->ref)) // We check that ref is not already used + { + $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used + if ($result > 0) + { + $this->error='ErrorRefAlreadyExists'; + dol_syslog(get_class($this)."::create ".$this->error,LOG_WARNING); + $this->db->rollback(); + return -1; + } + } + + if (empty($this->date)) + { + $this->error="Date of proposal is required"; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -4; + } + + + $this->db->begin(); + + // Insert into database + $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal ("; + $sql.= "fk_soc"; + $sql.= ", price"; + $sql.= ", remise"; + $sql.= ", remise_percent"; + $sql.= ", remise_absolue"; + $sql.= ", tva"; + $sql.= ", total"; + $sql.= ", datep"; + $sql.= ", datec"; + $sql.= ", ref"; + $sql.= ", fk_user_author"; + $sql.= ", note_private"; + $sql.= ", note_public"; + $sql.= ", model_pdf"; + $sql.= ", fin_validite"; + $sql.= ", fk_cond_reglement"; + $sql.= ", fk_mode_reglement"; + $sql.= ", fk_account"; + $sql.= ", ref_client"; + $sql.= ", date_livraison"; + $sql.= ", fk_shipping_method"; + $sql.= ", fk_availability"; + $sql.= ", fk_input_reason"; + $sql.= ", fk_projet"; + $sql.= ", entity"; + $sql.= ") "; + $sql.= " VALUES ("; + $sql.= $this->socid; + $sql.= ", 0"; + $sql.= ", ".$this->remise; + $sql.= ", ".($this->remise_percent?$this->remise_percent:'null'); + $sql.= ", ".($this->remise_absolue?$this->remise_absolue:'null'); + $sql.= ", 0"; + $sql.= ", 0"; + $sql.= ", '".$this->db->idate($this->date)."'"; + $sql.= ", '".$this->db->idate($now)."'"; + $sql.= ", '(PROV)'"; + $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); + $sql.= ", '".$this->db->escape($this->note_private)."'"; + $sql.= ", '".$this->db->escape($this->note_public)."'"; + $sql.= ", '".$this->modelpdf."'"; + $sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"null"); + $sql.= ", ".$this->cond_reglement_id; + $sql.= ", ".$this->mode_reglement_id; + $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); + $sql.= ", '".$this->db->escape($this->ref_client)."'"; + $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null"); + $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); + $sql.= ", ".$this->availability_id; + $sql.= ", ".$this->demand_reason_id; + $sql.= ", ".($this->fk_project?$this->fk_project:"null"); + $sql.= ", ".$conf->entity; + $sql.= ")"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal"); + + if ($this->id) + { + $this->ref='(PROV'.$this->id.')'; + $sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->ref."' WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) $error++; + + /* + * Insertion du detail des produits dans la base + */ + if (! $error) + { + $fk_parent_line=0; + $num=count($this->lines); + + for ($i=0;$i<$num;$i++) + { + // Reset fk_parent_line for no child products and special product + if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } + + $result = $this->addline( + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->fk_product, + $this->lines[$i]->remise_percent, + 'HT', + 0, + 0, + $this->lines[$i]->product_type, + $this->lines[$i]->rang, + $this->lines[$i]->special_code, + $fk_parent_line, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht, + $this->lines[$i]->label, + $this->lines[$i]->date_start, + $this->lines[$i]->date_end, + $this->lines[$i]->array_options + ); + + if ($result < 0) + { + $error++; + $this->error=$this->db->error; + dol_print_error($this->db); + break; + } + // Defined the new fk_parent_line + if ($result > 0 && $this->lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + } + + // Add linked object + if (! $error && $this->origin && $this->origin_id) + { + $ret = $this->add_object_linked(); + if (! $ret) dol_print_error($this->db); + } + + // Set delivery address + if (! $error && $this->fk_delivery_address) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_delivery_address = ".$this->fk_delivery_address; + $sql.= " WHERE ref = '".$this->ref."'"; + $sql.= " AND entity = ".$conf->entity; + + $result=$this->db->query($sql); + } + + if (! $error) + { + // Mise a jour infos denormalisees + $resql=$this->update_price(1); + if ($resql) + { + $action='update'; + + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('propaldao')); + $parameters=array('socid'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('PROPAL_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + else + { + $this->error=$this->db->lasterror(); + $error++; + } + } + } + else + { + $this->error=$this->db->lasterror(); + $error++; + } + + if (! $error) + { + $this->db->commit(); + dol_syslog(get_class($this)."::create done id=".$this->id); + return $this->id; + } + else + { + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + + + /** + * Insert into DB a proposal object completely defined by its data members (ex, results from copy). + * + * @param User $user User that create + * @return int Id of the new object if ok, <0 if ko + * @see create + */ + function create_from($user) + { + $this->products=$this->lines; + + return $this->create($user); + } + + /** + * Load an object from its id and create a new one in database + * + * @param int $socid Id of thirdparty + * @return int New id of clone + */ + function createFromClone($socid=0) + { + global $user,$langs,$conf,$hookmanager; + + $error=0; + $now=dol_now(); + + $this->db->begin(); + + // get extrafields so they will be clone + foreach($this->lines as $line) + $line->fetch_optionals($line->rowid); + + // Load source object + $objFrom = dol_clone($this); + + $objsoc=new Societe($this->db); + + // Change socid if needed + if (! empty($socid) && $socid != $this->socid) + { + if ($objsoc->fetch($socid) > 0) + { + $this->socid = $objsoc->id; + $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $this->fk_project = ''; + $this->fk_delivery_address = ''; + } + + // reset ref_client + $this->ref_client = ''; + + // TODO Change product price if multi-prices + } + else + { + $objsoc->fetch($this->socid); + } + + $this->id=0; + $this->statut=0; + + if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) + { + $this->error='ErrorSetupNotComplete'; + return -1; + } + + // Clear fields + $this->user_author = $user->id; + $this->user_valid = ''; + $this->date = $now; + $this->datep = $now; // deprecated + $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); + if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = ''; + + // Set ref + require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php'; + $obj = $conf->global->PROPALE_ADDON; + $modPropale = new $obj; + $this->ref = $modPropale->getNextValue($objsoc,$this); + + // Create clone + $result=$this->create($user); + if ($result < 0) $error++; + else + { + // copy internal contacts + if ($this->copy_linked_contact($objFrom, 'internal') < 0) + $error++; + + // copy external contacts if same company + elseif ($objFrom->socid == $this->socid) + { + if ($this->copy_linked_contact($objFrom, 'external') < 0) + $error++; + } + } + + if (! $error) + { + // Hook of thirdparty module + if (is_object($hookmanager)) + { + $parameters=array('objFrom'=>$objFrom); + $action=''; + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; + } + + // Call trigger + $result=$this->call_trigger('PROPAL_CLONE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + + // End + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -1; + } + } + + /** + * Load a proposal from database and its ligne array + * + * @param int $rowid id of object to load + * @param string $ref Ref of proposal + * @return int >0 if OK, <0 if KO + */ + function fetch($rowid,$ref='') + { + global $conf; + + $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; + $sql.= ", p.datec"; + $sql.= ", p.date_valid as datev"; + $sql.= ", p.datep as dp"; + $sql.= ", p.fin_validite as dfv"; + $sql.= ", p.date_livraison as date_livraison"; + $sql.= ", p.model_pdf, p.ref_client, p.extraparams"; + $sql.= ", p.note_private, p.note_public"; + $sql.= ", p.fk_projet, p.fk_statut"; + $sql.= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; + $sql.= ", p.fk_delivery_address"; + $sql.= ", p.fk_availability"; + $sql.= ", p.fk_input_reason"; + $sql.= ", p.fk_cond_reglement"; + $sql.= ", p.fk_mode_reglement"; + $sql.= ', p.fk_account'; + $sql.= ", p.fk_shipping_method"; + $sql.= ", c.label as statut_label"; + $sql.= ", ca.code as availability_code, ca.label as availability"; + $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; + $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; + $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; + $sql.= " WHERE p.fk_statut = c.id"; + $sql.= " AND p.entity = ".$conf->entity; + if ($ref) $sql.= " AND p.ref='".$ref."'"; + else $sql.= " AND p.rowid=".$rowid; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; + $this->remise = $obj->remise; + $this->remise_percent = $obj->remise_percent; + $this->remise_absolue = $obj->remise_absolue; + $this->total = $obj->total; // TODO obsolete + $this->total_ht = $obj->total_ht; + $this->total_tva = $obj->tva; + $this->total_localtax1 = $obj->localtax1; + $this->total_localtax2 = $obj->localtax2; + $this->total_ttc = $obj->total; + $this->socid = $obj->fk_soc; + $this->fk_project = $obj->fk_projet; + $this->modelpdf = $obj->model_pdf; + $this->note = $obj->note_private; // TODO obsolete + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->statut = $obj->fk_statut; + $this->statut_libelle = $obj->statut_label; + + $this->datec = $this->db->jdate($obj->datec); // TODO obsolete + $this->datev = $this->db->jdate($obj->datev); // TODO obsolete + $this->date_creation = $this->db->jdate($obj->datec); //Creation date + $this->date_validation = $this->db->jdate($obj->datev); //Validation date + $this->date = $this->db->jdate($obj->dp); // Proposal date + $this->datep = $this->db->jdate($obj->dp); // deprecated + $this->fin_validite = $this->db->jdate($obj->dfv); + $this->date_livraison = $this->db->jdate($obj->date_livraison); + $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; + $this->availability_id = $obj->fk_availability; + $this->availability_code = $obj->availability_code; + $this->availability = $obj->availability; + $this->demand_reason_id = $obj->fk_input_reason; + $this->demand_reason_code = $obj->demand_reason_code; + $this->demand_reason = $obj->demand_reason; + $this->fk_address = $obj->fk_delivery_address; + + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement; + $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement = $obj->cond_reglement; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + + $this->extraparams = (array) json_decode($obj->extraparams, true); + + $this->user_author_id = $obj->fk_user_author; + $this->user_valid_id = $obj->fk_user_valid; + $this->user_close_id = $obj->fk_user_cloture; + + if ($obj->fk_statut == 0) + { + $this->brouillon = 1; + } + + // Retreive all extrafield for invoice + // fetch optionals attributes and labels + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + + $this->db->free($resql); + + $this->lines = array(); + + /* + * Lignes propales liees a un produit ou non + */ + $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; + $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; + $sql.= ' d.date_start, d.date_end'; + $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; + $sql.= " WHERE d.fk_propal = ".$this->id; + $sql.= " ORDER by d.rang"; + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + while ($i < $num) + { + $objp = $this->db->fetch_object($result); + + $line = new PropaleLigne($this->db); + + $line->rowid = $objp->rowid; + $line->fk_propal = $objp->fk_propal; + $line->fk_parent_line = $objp->fk_parent_line; + $line->product_type = $objp->product_type; + $line->label = $objp->custom_label; + $line->desc = $objp->description; // Description ligne + $line->qty = $objp->qty; + $line->tva_tx = $objp->tva_tx; + $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax2_tx = $objp->localtax2_tx; + $line->subprice = $objp->subprice; + $line->fk_remise_except = $objp->fk_remise_except; + $line->remise_percent = $objp->remise_percent; + $line->price = $objp->price; // TODO deprecated + + $line->info_bits = $objp->info_bits; + $line->total_ht = $objp->total_ht; + $line->total_tva = $objp->total_tva; + $line->total_localtax1 = $objp->total_localtax1; + $line->total_localtax2 = $objp->total_localtax2; + $line->total_ttc = $objp->total_ttc; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; + $line->special_code = $objp->special_code; + $line->rang = $objp->rang; + + $line->fk_product = $objp->fk_product; + + $line->ref = $objp->product_ref; // TODO deprecated + $line->product_ref = $objp->product_ref; + $line->libelle = $objp->product_label; // TODO deprecated + $line->product_label = $objp->product_label; + $line->product_desc = $objp->product_desc; // Description produit + $line->fk_product_type = $objp->fk_product_type; + + $line->date_start = $objp->date_start; + $line->date_end = $objp->date_end; + + $this->lines[$i] = $line; + //dol_syslog("1 ".$line->fk_product); + //print "xx $i ".$this->lines[$i]->fk_product; + $i++; + } + $this->db->free($result); + } + else + { + $this->error=$this->db->error(); + return -1; + } + + // Retreive all extrafield for propal + // fetch optionals attributes and labels + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + + return 1; + } + + $this->error="Record Not Found"; + return 0; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + /** + * Update value of extrafields on the proposal + * + * @param User $user Object user that modify + * @return int <0 if ko, >0 if ok + */ + function update_extrafields($user) + { + $action='update'; + + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('propaldao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + + if (!$error) + { + return 1; + } + else + { + return -1; + } + + } + + /** + * Set status to validated + * + * @param User $user Object user that validate + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if KO, >=0 if OK + */ + function valid($user, $notrigger=0) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + global $conf,$langs; + + $error=0; + $now=dol_now(); + + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate))) + { + $this->db->begin(); + + // Numbering module definition + $soc = new Societe($this->db); + $soc->fetch($this->socid); + + // Define new ref + if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) + { + $num = $this->getNextNumRef($soc); + } + else + { + $num = $this->ref; + } + $this->newref = $num; + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET ref = '".$num."',"; + $sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + dol_syslog(get_class($this)."::valid", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + $error++; + } + + // Trigger calls + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('PROPAL_VALIDATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + + if (! $error) + { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Rename of propal directory ($this->ref = old ref, $num = new ref) + // to not lose the linked files + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->propal->dir_output.'/'.$oldref; + $dirdest = $conf->propal->dir_output.'/'.$newref; + + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->propal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + + $this->ref=$num; + $this->brouillon=0; + $this->statut = 1; + $this->user_valid_id=$user->id; + $this->datev=$now; + + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + } + + + /** + * Define proposal date + * + * @param User $user Object user that modify + * @param int $date Date + * @return int <0 if KO, >0 if OK + */ + function set_date($user, $date) + { + if (empty($date)) + { + $this->error='ErrorBadParameter'; + dol_syslog(get_class($this)."::set_date ".$this->error, LOG_ERR); + return -1; + } + + if (! empty($user->rights->propal->creer)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'"; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + dol_syslog(get_class($this)."::set_date", LOG_DEBUG); + if ($this->db->query($sql) ) + { + $this->date = $date; + $this->datep = $date; // deprecated + return 1; + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } + } + + /** + * Define end validity date + * + * @param User $user Object user that modify + * @param int $date_fin_validite End of validity date + * @return int <0 if KO, >0 if OK + */ + function set_echeance($user, $date_fin_validite) + { + if (! empty($user->rights->propal->creer)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null'); + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + if ($this->db->query($sql) ) + { + $this->fin_validite = $date_fin_validite; + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + } + + /** + * Set delivery date + * + * @param User $user Object user that modify + * @param int $date_livraison Delivery date + * @return int <0 if ko, >0 if ok + */ + function set_date_livraison($user, $date_livraison) + { + if (! empty($user->rights->propal->creer)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null'); + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->date_livraison = $date_livraison; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::set_date_livraison Erreur SQL"); + return -1; + } + } + } + + /** + * Set delivery + * + * @param User $user Object user that modify + * @param int $id Availability id + * @return int <0 if KO, >0 if OK + */ + function set_availability($user, $id) + { + if (! empty($user->rights->propal->creer)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET fk_availability = '".$id."'"; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->fk_availability = $id; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::set_availability Erreur SQL"); + return -1; + } + } + } + + /** + * Set source of demand + * + * @param User $user Object user that modify + * @param int $id Input reason id + * @return int <0 if KO, >0 if OK + */ + function set_demand_reason($user, $id) + { + if (! empty($user->rights->propal->creer)) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET fk_input_reason = '".$id."'"; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->fk_input_reason = $id; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::set_demand_reason Erreur SQL"); + return -1; + } + } + } + + /** + * Set customer reference number + * + * @param User $user Object user that modify + * @param string $ref_client Customer reference + * @return int <0 if ko, >0 if ok + */ + function set_ref_client($user, $ref_client) + { + if (! empty($user->rights->propal->creer)) + { + dol_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); + $sql.= ' WHERE rowid = '.$this->id; + if ($this->db->query($sql) ) + { + $this->ref_client = $ref_client; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog('Propale::set_ref_client Erreur '.$this->error.' - '.$sql); + return -2; + } + } + else + { + return -1; + } + } + + /** + * Set an overall discount on the proposal + * + * @param User $user Object user that modify + * @param double $remise Amount discount + * @return int <0 if ko, >0 if ok + */ + function set_remise_percent($user, $remise) + { + $remise=trim($remise)?trim($remise):0; + + if (! empty($user->rights->propal->creer)) + { + $remise = price2num($remise); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql) ) + { + $this->remise_percent = $remise; + $this->update_price(1); + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + } + + + /** + * Set an absolute overall discount on the proposal + * + * @param User $user Object user that modify + * @param double $remise Amount discount + * @return int <0 if ko, >0 if ok + */ + function set_remise_absolue($user, $remise) + { + $remise=trim($remise)?trim($remise):0; + + if (! empty($user->rights->propal->creer)) + { + $remise = price2num($remise); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET remise_absolue = ".$remise; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql) ) + { + $this->remise_absolue = $remise; + $this->update_price(1); + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + } + + + + /** + * Reopen the commercial proposal + * + * @param User $user Object user that close + * @param int $statut Statut + * @param string $note Comment + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if KO, >0 if OK + */ + function reopen($user, $statut, $note='', $notrigger=0) + { + global $langs,$conf; + + $this->statut = $statut; + $error=0; + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_statut = ".$this->statut.","; + if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; + $sql.= " date_cloture=NULL, fk_user_cloture=NULL"; + $sql.= " WHERE rowid = ".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::reopen", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('PROPAL_REOPEN',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + if (!empty($this->errors)) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Close the commercial proposal + * + * @param User $user Object user that close + * @param int $statut Statut + * @param string $note Comment + * @return int <0 if KO, >0 if OK + */ + function cloture($user, $statut, $note) + { + global $langs,$conf; + + $this->statut = $statut; + $error=0; + $now=dol_now(); + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; + $sql.= " WHERE rowid = ".$this->id; + + $resql=$this->db->query($sql); + if ($resql) + { + $modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf; + $trigger_name='PROPAL_CLOSE_REFUSED'; + + if ($statut == 2) + { + $trigger_name='PROPAL_CLOSE_SIGNED'; + $modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf; + + // The connected company is classified as a client + $soc=new Societe($this->db); + $soc->id = $this->socid; + $result=$soc->set_as_client(); + + if ($result < 0) + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + } + if ($statut == 4) + { + $trigger_name='PROPAL_CLASSIFY_BILLED'; + } + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + // Call trigger + $result=$this->call_trigger($trigger_name,$user); + if ($result < 0) { $error++; } + // End call triggers + + if ( ! $error ) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** + * Class invoiced the Propal + * + * @return int <0 si ko, >0 si ok + */ + function classifyBilled() + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = 4'; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; + if ($this->db->query($sql) ) + { + $this->statut=4; + return 1; + } + else + { + dol_print_error($this->db); + } + } + + /** + * Class invoiced the Propal + * + * @return int <0 si ko, >0 si ok + * @deprecated + */ + function classer_facturee() + { + return $this->classifyBilled(); + } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @return int <0 if KO, >0 if OK + */ + function set_draft($user) + { + global $conf,$langs; + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0"; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->statut = 0; + $this->brouillon = 1; + return 1; + } + else + { + return -1; + } + } + + + /** + * Return list of proposal (eventually filtered on user) into an array + * + * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name) + * @param int $draft 0=not draft, 1=draft + * @param int $notcurrentuser 0=all user, 1=not current user + * @param int $socid Id third pary + * @param int $limit For pagination + * @param int $offset For pagination + * @param string $sortfield Sort criteria + * @param string $sortorder Sort order + * @return int -1 if KO, array with result if OK + */ + function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC') + { + global $conf,$user; + + $ga = array(); + + $sql = "SELECT s.rowid, s.nom as name, s.client,"; + $sql.= " p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; + $sql.= " p.datep as dp, p.fin_validite as datelimite"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " AND p.fk_soc = s.rowid"; + $sql.= " AND p.fk_statut = c.id"; + if (! $user->rights->societe->client->voir && ! $socid) //restriction + { + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } + if ($socid) $sql.= " AND s.rowid = ".$socid; + if ($draft) $sql.= " AND p.fk_statut = 0"; + if ($notcurrentuser > 0) $sql.= " AND p.fk_user_author <> ".$user->id; + $sql.= $this->db->order($sortfield,$sortorder); + $sql.= $this->db->plimit($limit,$offset); + + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + + if ($shortlist == 1) + { + $ga[$obj->propalid] = $obj->ref; + } + else if ($shortlist == 2) + { + $ga[$obj->propalid] = $obj->ref.' ('.$obj->name.')'; + } + else + { + $ga[$i]['id'] = $obj->propalid; + $ga[$i]['ref'] = $obj->ref; + $ga[$i]['name'] = $obj->name; + } + + $i++; + } + } + return $ga; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Returns an array with the numbers of related invoices + * + * @return array Array of invoices + */ + function getInvoiceArrayList() + { + return $this->InvoiceArrayList($this->id); + } + + /** + * Returns an array with id and ref of related invoices + * + * @param int $id Id propal + * @return array Array of invoices id + */ + function InvoiceArrayList($id) + { + $ga = array(); + $linkedInvoices = array(); + + $this->fetchObjectLinked($id,$this->element); + foreach($this->linkedObjectsIds as $objecttype => $objectid) + { + $numi=count($objectid); + for ($i=0;$i<$numi;$i++) + { + // Cas des factures liees directement + if ($objecttype == 'facture') + { + $linkedInvoices[] = $objectid[$i]; + } + // Cas des factures liees par un autre objet (ex: commande) + else + { + $this->fetchObjectLinked($objectid[$i],$objecttype); + foreach($this->linkedObjectsIds as $subobjecttype => $subobjectid) + { + $numj=count($subobjectid); + for ($j=0;$j<$numj;$j++) + { + if ($subobjecttype == 'facture') + { + $linkedInvoices[] = $subobjectid[$j]; + } + } + } + } + } + } + + if (count($linkedInvoices) > 0) + { + $sql= "SELECT rowid as facid, facnumber, total, datef as df, fk_user_author, fk_statut, paye"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture"; + $sql.= " WHERE rowid IN (".implode(',',$linkedInvoices).")"; + + dol_syslog(get_class($this)."::InvoiceArrayList", LOG_DEBUG); + $resql=$this->db->query($sql); + + if ($resql) + { + $tab_sqlobj=array(); + $nump = $this->db->num_rows($resql); + for ($i = 0;$i < $nump;$i++) + { + $sqlobj = $this->db->fetch_object($resql); + $tab_sqlobj[] = $sqlobj; + } + $this->db->free($resql); + + $nump = count($tab_sqlobj); + + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = array_shift($tab_sqlobj); + + $ga[$i] = $obj; + + $i++; + } + } + return $ga; + } + else + { + return -1; + } + } + else return $ga; + } + + /** + * Delete proposal + * + * @param User $user Object user that delete + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int 1 if ok, otherwise if error + */ + function delete($user, $notrigger=0) + { + global $conf,$langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error=0; + + $this->db->begin(); + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('PROPAL_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; + if ($this->db->query($sql)) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id; + if ($this->db->query($sql)) + { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + + // Delete linked contacts + $res = $this->delete_linked_contact(); + if ($res < 0) $error++; + + if (! $error) + { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->propal->dir_output && !empty($this->ref)) + { + $dir = $conf->propal->dir_output . "/" . $ref ; + $file = $dir . "/" . $ref . ".pdf"; + if (file_exists($file)) + { + dol_delete_preview($this); + + if (! dol_delete_file($file,0,0,0,$this)) // For triggers + { + $this->error='ErrorFailToDeleteFile'; + $this->errors=array('ErrorFailToDeleteFile'); + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) + { + $res=@dol_delete_dir_recursive($dir); + if (! $res) + { + $this->error='ErrorFailToDeleteDir'; + $this->errors=array('ErrorFailToDeleteDir'); + $this->db->rollback(); + return 0; + } + } + } + } + + // Removed extrafields + if (! $error) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + $errorflag=-4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + } + } + } + + if (! $error) + { + dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return 0; + } + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -3; + } + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } + else + { + $this->db->rollback(); + return -1; + } + } + + /** + * Change the delivery time + * + * @param int $availability_id Id of new delivery time + * @return int >0 if OK, <0 if KO + */ + function availability($availability_id) + { + dol_syslog('Propale::availability('.$availability_id.')'); + if ($this->statut >= 0) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; + $sql .= ' SET fk_availability = '.$availability_id; + $sql .= ' WHERE rowid='.$this->id; + if ( $this->db->query($sql) ) + { + $this->availability_id = $availability_id; + return 1; + } + else + { + dol_syslog('Propale::availability Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog('Propale::availability, etat propale incompatible'); + $this->error='Etat propale incompatible '.$this->statut; + return -2; + } + } + + /** + * Change source demand + * + * @param int $demand_reason_id Id of new source demand + * @return int >0 si ok, <0 si ko + */ + function demand_reason($demand_reason_id) + { + dol_syslog('Propale::demand_reason('.$demand_reason_id.')'); + if ($this->statut >= 0) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; + $sql .= ' SET fk_input_reason = '.$demand_reason_id; + $sql .= ' WHERE rowid='.$this->id; + if ( $this->db->query($sql) ) + { + $this->demand_reason_id = $demand_reason_id; + return 1; + } + else + { + dol_syslog('Propale::demand_reason Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog('Propale::demand_reason, etat propale incompatible'); + $this->error='Etat propale incompatible '.$this->statut; + return -2; + } + } + + + /** + * Object Proposal Information + * + * @param int $id Proposal id + * @return void + */ + function info($id) + { + $sql = "SELECT c.rowid, "; + $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; + $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; + $sql.= " WHERE c.rowid = ".$id; + + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->rowid; + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_validation = $this->db->jdate($obj->datev); + $this->date_cloture = $this->db->jdate($obj->dateo); + + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + + } + $this->db->free($result); + + } + else + { + dol_print_error($this->db); + } + } + + + /** + * Return label of status of proposal (draft, validated, ...) + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Label + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->statut,$mode); + } + + /** + * Return label of a status (draft, validated, ...) + * + * @param int $statut id statut + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Label + */ + function LibStatut($statut,$mode=1) + { + global $langs; + $langs->load("propal"); + + if ($statut==0) $statuttrans='statut0'; + if ($statut==1) $statuttrans='statut1'; + if ($statut==2) $statuttrans='statut3'; + if ($statut==3) $statuttrans='statut5'; + if ($statut==4) $statuttrans='statut6'; + + if ($mode == 0) return $this->labelstatut[$statut]; + if ($mode == 1) return $this->labelstatut_short[$statut]; + if ($mode == 2) return img_picto($this->labelstatut_short[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; + if ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); + if ($mode == 4) return img_picto($this->labelstatut[$statut],$statuttrans).' '.$this->labelstatut[$statut]; + if ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut_short[$statut],$statuttrans); + } + + + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Object user + * @param int $mode "opened" for proposal to close, "signed" for proposal to invoice + * @return int <0 if KO, >0 if OK + */ + function load_board($user,$mode) + { + global $conf, $user; + + $now=dol_now(); + + $this->nbtodo=$this->nbtodolate=0; + $clause = " WHERE"; + + $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = " AND"; + } + $sql.= $clause." p.entity = ".$conf->entity; + if ($mode == 'opened') $sql.= " AND p.fk_statut = 1"; + if ($mode == 'signed') $sql.= " AND p.fk_statut = 2"; + if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id; + + $resql=$this->db->query($sql); + if ($resql) + { + if ($mode == 'opened') $delay_warning=$conf->propal->cloture->warning_delay; + if ($mode == 'signed') $delay_warning=$conf->propal->facturation->warning_delay; + + // This assignment in condition is not a bug. It allows walking the results. + while ($obj=$this->db->fetch_object($resql)) + { + $this->nbtodo++; + if ($mode == 'opened') + { + $datelimit = $this->db->jdate($obj->datefin); + if ($datelimit < ($now - $delay_warning)) + { + $this->nbtodolate++; + } + } + // TODO Definir regle des propales a facturer en retard + // if ($mode == 'signed' && ! count($this->FactureListeArray($obj->rowid))) $this->nbtodolate++; + } + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + function initAsSpecimen() + { + global $user,$langs,$conf; + + // Charge tableau des produits prodids + $prodids = array(); + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $resql = $this->db->query($sql); + if ($resql) + { + $num_prods = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_prods) + { + $i++; + $row = $this->db->fetch_row($resql); + $prodids[$i] = $row[0]; + } + } + + // Initialise parametres + $this->id=0; + $this->ref = 'SPECIMEN'; + $this->ref_client='NEMICEPS'; + $this->specimen=1; + $this->socid = 1; + $this->date = time(); + $this->fin_validite = $this->date+3600*24*30; + $this->cond_reglement_id = 1; + $this->cond_reglement_code = 'RECEP'; + $this->mode_reglement_id = 7; + $this->mode_reglement_code = 'CHQ'; + $this->availability_id = 1; + $this->availability_code = 'AV_NOW'; + $this->demand_reason_id = 1; + $this->demand_reason_code = 'SRC_00'; + $this->note_public='This is a comment (public)'; + $this->note_private='This is a comment (private)'; + // Lines + $nbp = 5; + $xnbp = 0; + while ($xnbp < $nbp) + { + $line=new PropaleLigne($this->db); + $line->desc=$langs->trans("Description")." ".$xnbp; + $line->qty=1; + $line->subprice=100; + $line->price=100; + $line->tva_tx=19.6; + $line->localtax1_tx=0; + $line->localtax2_tx=0; + if ($xnbp == 2) + { + $line->total_ht=50; + $line->total_ttc=59.8; + $line->total_tva=9.8; + $line->remise_percent=50; + } + else + { + $line->total_ht=100; + $line->total_ttc=119.6; + $line->total_tva=19.6; + $line->remise_percent=00; + } + + $prodid = rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; + + $this->lines[$xnbp]=$line; + + $this->total_ht += $line->total_ht; + $this->total_tva += $line->total_tva; + $this->total_ttc += $line->total_ttc; + + $xnbp++; + } + } + + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board() + { + global $conf, $user; + + $this->nb=array(); + $clause = "WHERE"; + + $sql = "SELECT count(p.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = "AND"; + } + $sql.= " ".$clause." p.entity = ".$conf->entity; + + $resql=$this->db->query($sql); + if ($resql) + { + // This assignment in condition is not a bug. It allows walking the results. + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["proposals"]=$obj->nb; + } + $this->db->free($resql); + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } + + + /** + * Returns the reference to the following non used Proposal used depending on the active numbering module + * defined into PROPALE_ADDON + * + * @param Societe $soc Object thirdparty + * @return string Reference libre pour la propale + */ + function getNextNumRef($soc) + { + global $conf, $db, $langs; + $langs->load("propal"); + + if (! empty($conf->global->PROPALE_ADDON)) + { + $mybool=false; + + $file = $conf->global->PROPALE_ADDON.".php"; + $classname = $conf->global->PROPALE_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/propale/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } + + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this); + + if ($numref != "") + { + return $numref; + } + else + { + $this->error=$obj->error; + //dol_print_error($db,"Propale::getNextNumRef ".$obj->error); + return ""; + } + } + else + { + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; + } + } + + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param string $option Where point the link ('compta', 'expedition', 'document', ...) + * @param string $get_params Parametres added to url + * @return string String with URL + */ + function getNomUrl($withpicto=0,$option='', $get_params='') + { + global $langs; + + $result=''; + $label=$langs->trans("ShowPropal").': '.$this->ref; + if (! empty($this->ref_client)) + $label.= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; + if ($option == '') { + $lien = ''; + + $picto='propal'; + + + if ($withpicto) + $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin); + if ($withpicto && $withpicto != 2) + $result.=' '; + $result.=$lien.$this->ref.$lienfin; + return $result; + } + + /** + * Retrieve an array of propal lines + * + * @return int <0 if ko, >0 if ok + */ + function getLinesArray() + { + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; + $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; + $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; + $sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,'; + $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; + $sql.= ' p.description as product_desc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; + $sql.= ' WHERE pt.fk_propal = '.$this->id; + $sql.= ' ORDER BY pt.rang ASC, pt.rowid'; + + dol_syslog(get_class($this).'::getLinesArray', LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + $this->lines[$i] = new PropaleLigne($this->db); + $this->lines[$i]->id = $obj->rowid; // for backward compatibility + $this->lines[$i]->rowid = $obj->rowid; + $this->lines[$i]->label = $obj->custom_label; + $this->lines[$i]->description = $obj->description; + $this->lines[$i]->fk_product = $obj->fk_product; + $this->lines[$i]->ref = $obj->ref; + $this->lines[$i]->product_label = $obj->product_label; + $this->lines[$i]->product_desc = $obj->product_desc; + $this->lines[$i]->fk_product_type = $obj->fk_product_type; // deprecated + $this->lines[$i]->product_type = $obj->product_type; + $this->lines[$i]->qty = $obj->qty; + $this->lines[$i]->subprice = $obj->subprice; + $this->lines[$i]->fk_remise_except = $obj->fk_remise_except; + $this->lines[$i]->remise_percent = $obj->remise_percent; + $this->lines[$i]->tva_tx = $obj->tva_tx; + $this->lines[$i]->info_bits = $obj->info_bits; + $this->lines[$i]->total_ht = $obj->total_ht; + $this->lines[$i]->total_tva = $obj->total_tva; + $this->lines[$i]->total_ttc = $obj->total_ttc; + $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; + $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); + $this->lines[$i]->pa_ht = $marginInfos[0]; + $this->lines[$i]->marge_tx = $marginInfos[1]; + $this->lines[$i]->marque_tx = $marginInfos[2]; + $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; + $this->lines[$i]->special_code = $obj->special_code; + $this->lines[$i]->rang = $obj->rang; + $this->lines[$i]->date_start = $this->db->jdate($obj->date_start); + $this->lines[$i]->date_end = $this->db->jdate($obj->date_end); + + $i++; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + { + global $conf,$user,$langs; + + $langs->load("propale"); + + // Positionne le modele sur le nom du modele a utiliser + if (! dol_strlen($modele)) + { + if (! empty($conf->global->PROPALE_ADDON_PDF)) + { + $modele = $conf->global->PROPALE_ADDON_PDF; + } + else + { + $modele = 'azur'; + } + } + + $modelpath = "core/modules/propale/doc/"; + + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + +} + + +/** + * \class PropaleLigne + * \brief Class to manage commercial proposal lines + */ +class PropaleLigne extends CommonObject +{ + var $db; + var $error; + + public $element='propaldet'; + public $table_element='propaldet'; + + var $oldline; + + // From llx_propaldet + var $rowid; + var $fk_propal; + var $fk_parent_line; + var $desc; // Description ligne + var $fk_product; // Id produit predefini + var $product_type = 0; // Type 0 = product, 1 = Service + + var $qty; + var $tva_tx; + var $subprice; + var $remise_percent; + var $fk_remise_except; + + var $rang = 0; + + var $fk_fournprice; + var $pa_ht; + var $marge_tx; + var $marque_tx; + + var $special_code; // Tag for special lines (exlusive tags) + // 1: frais de port + // 2: ecotaxe + // 3: option line (when qty = 0) + + var $info_bits = 0; // Liste d'options cumulables: + // Bit 0: 0 si TVA normal - 1 si TVA NPR + // Bit 1: 0 ligne normale - 1 si ligne de remise fixe + + var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne + var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne + + // Ne plus utiliser + var $remise; + var $price; + + // From llx_product + var $ref; // Reference produit + var $libelle; // Label produit + var $product_desc; // Description produit + + var $localtax1_tx; // Local tax 1 + var $localtax2_tx; // Local tax 2 + var $localtax1_type; // Local tax 1 type + var $localtax2_type; // Local tax 2 type + var $total_localtax1; // Line total local tax 1 + var $total_localtax2; // Line total local tax 2 + + var $date_start; + var $date_end; + + var $skip_update_total; // Skip update price total for special lines + + /** + * Class line Contructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db= $db; + } + + /** + * Retrieve the propal line object + * + * @param int $rowid Propal line id + * @return int <0 if KO, >0 if OK + */ + function fetch($rowid) + { + $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; + $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; + $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; + $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; + $sql.= ' pd.date_start, pd.date_end, pd.product_type'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; + $sql.= ' WHERE pd.rowid = '.$rowid; + + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); + + $this->rowid = $objp->rowid; + $this->fk_propal = $objp->fk_propal; + $this->fk_parent_line = $objp->fk_parent_line; + $this->label = $objp->custom_label; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->price = $objp->price; // deprecated + $this->subprice = $objp->subprice; + $this->tva_tx = $objp->tva_tx; + $this->remise = $objp->remise; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; + + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; + + $this->fk_fournprice = $objp->fk_fournprice; + + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); + $this->pa_ht = $marginInfos[0]; + $this->marge_tx = $marginInfos[1]; + $this->marque_tx = $marginInfos[2]; + + $this->special_code = $objp->special_code; + $this->product_type = $objp->product_type; + $this->rang = $objp->rang; + + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; + $this->product_desc = $objp->product_desc; + + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); + + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } + + /** + * Insert object line propal in database + * + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if KO, >0 if OK + */ + function insert($notrigger=0) + { + global $conf,$langs,$user; + + $error=0; + + dol_syslog(get_class($this)."::insert rang=".$this->rang); + + // Clean parameters + if (empty($this->tva_tx)) $this->tva_tx=0; + if (empty($this->localtax1_tx)) $this->localtax1_tx=0; + if (empty($this->localtax2_tx)) $this->localtax2_tx=0; + if (empty($this->localtax1_type)) $this->localtax1_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->rang)) $this->rang=0; + if (empty($this->remise)) $this->remise=0; + if (empty($this->remise_percent)) $this->remise_percent=0; + if (empty($this->info_bits)) $this->info_bits=0; + if (empty($this->special_code)) $this->special_code=0; + if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + if (empty($this->fk_fournprice)) $this->fk_fournprice=0; + + if (empty($this->pa_ht)) $this->pa_ht=0; + + // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente + if ($this->pa_ht == 0) { + if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) + $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + } + + // Check parameters + if ($this->product_type < 0) return -1; + + $this->db->begin(); + + // Insert line into database + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet'; + $sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type,'; + $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql.= ' subprice, remise_percent, '; + $sql.= ' info_bits, '; + $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; + $sql.= ' date_start, date_end)'; + $sql.= " VALUES (".$this->fk_propal.","; + $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; + $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; + $sql.= " '".$this->db->escape($this->desc)."',"; + $sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").","; + $sql.= " '".$this->product_type."',"; + $sql.= " ".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").","; + $sql.= " ".price2num($this->qty).","; + $sql.= " ".price2num($this->tva_tx).","; + $sql.= " ".price2num($this->localtax1_tx).","; + $sql.= " ".price2num($this->localtax2_tx).","; + $sql.= " '".$this->localtax1_type."',"; + $sql.= " '".$this->localtax2_type."',"; + $sql.= " ".($this->subprice?price2num($this->subprice):"null").","; + $sql.= " ".price2num($this->remise_percent).","; + $sql.= " ".(isset($this->info_bits)?"'".$this->info_bits."'":"null").","; + $sql.= " ".price2num($this->total_ht).","; + $sql.= " ".price2num($this->total_tva).","; + $sql.= " ".price2num($this->total_localtax1).","; + $sql.= " ".price2num($this->total_localtax2).","; + $sql.= " ".price2num($this->total_ttc).","; + $sql.= " ".(!empty($this->fk_fournprice)?"'".$this->fk_fournprice."'":"null").","; + $sql.= " ".(isset($this->pa_ht)?"'".price2num($this->pa_ht)."'":"null").","; + $sql.= ' '.$this->special_code.','; + $sql.= ' '.$this->rang.','; + $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").','; + $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); + $sql.= ')'; + + dol_syslog(get_class($this).'::insert', LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet'); + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('LINEPROPAL_INSERT',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers + } + + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error()." sql=".$sql; + $this->db->rollback(); + return -1; + } + } + + /** + * Delete line in database + * + * @return int <0 if ko, >0 if ok + */ + function delete() + { + global $conf,$langs,$user; + + $error=0; + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid; + dol_syslog("PropaleLigne::delete", LOG_DEBUG); + if ($this->db->query($sql) ) + { + + // Remove extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } + + // Call trigger + $result=$this->call_trigger('LINEPROPAL_DELETE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers + + $this->db->commit(); + + return 1; + } + else + { + $this->error=$this->db->error()." sql=".$sql; + $this->db->rollback(); + return -1; + } + } + + /** + * Update propal line object into DB + * + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if ko, >0 if ok + */ + function update($notrigger=0) + { + global $conf,$langs,$user; + + $error=0; + + // Clean parameters + if (empty($this->tva_tx)) $this->tva_tx=0; + if (empty($this->localtax1_tx)) $this->localtax1_tx=0; + if (empty($this->localtax2_tx)) $this->localtax2_tx=0; + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->localtax1_type)) $this->localtax1_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->marque_tx)) $this->marque_tx=0; + if (empty($this->marge_tx)) $this->marge_tx=0; + if (empty($this->price)) $this->price=0; // TODO A virer + if (empty($this->remise)) $this->remise=0; // TODO A virer + if (empty($this->remise_percent)) $this->remise_percent=0; + if (empty($this->info_bits)) $this->info_bits=0; + if (empty($this->special_code)) $this->special_code=0; + if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + if (empty($this->fk_fournprice)) $this->fk_fournprice=0; + + if (empty($this->pa_ht)) $this->pa_ht=0; + + // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente + if ($this->pa_ht == 0) { + if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) + $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); + } + + $this->db->begin(); + + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; + $sql.= " description='".$this->db->escape($this->desc)."'"; + $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); + $sql.= " , product_type=".$this->product_type; + $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; + $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); + $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); + $sql.= " , localtax1_type='".$this->localtax1_type."'"; + $sql.= " , localtax2_type='".$this->localtax2_type."'"; + $sql.= " , qty='".price2num($this->qty)."'"; + $sql.= " , subprice=".price2num($this->subprice).""; + $sql.= " , remise_percent=".price2num($this->remise_percent).""; + $sql.= " , price=".price2num($this->price).""; // TODO A virer + $sql.= " , remise=".price2num($this->remise).""; // TODO A virer + $sql.= " , info_bits='".$this->info_bits."'"; + if (empty($this->skip_update_total)) + { + $sql.= " , total_ht=".price2num($this->total_ht).""; + $sql.= " , total_tva=".price2num($this->total_tva).""; + $sql.= " , total_ttc=".price2num($this->total_ttc).""; + $sql.= " , total_localtax1=".price2num($this->total_localtax1).""; + $sql.= " , total_localtax2=".price2num($this->total_localtax2).""; + } + $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->fk_fournprice."'":"null"); + $sql.= " , buy_price_ht=".price2num($this->pa_ht); + if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; + $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); + if (! empty($this->rang)) $sql.= ", rang=".$this->rang; + $sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); + $sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); + $sql.= " WHERE rowid = ".$this->rowid; + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('LINEPROPAL_UPDATE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers + } + + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + } + + /** + * Update DB line fields total_xxx + * Used by migration + * + * @return int <0 if ko, >0 if ok + */ + function update_total() + { + $this->db->begin(); + + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; + $sql.= " total_ht=".price2num($this->total_ht,'MT').""; + $sql.= ",total_tva=".price2num($this->total_tva,'MT').""; + $sql.= ",total_ttc=".price2num($this->total_ttc,'MT').""; + $sql.= " WHERE rowid = ".$this->rowid; + + dol_syslog("PropaleLigne::update_total", LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + } + +} + diff --git a/htdocs/comm/askpricesupplier/class/index.html b/htdocs/comm/askpricesupplier/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/comm/askpricesupplier/contact.php b/htdocs/comm/askpricesupplier/contact.php new file mode 100644 index 00000000000..6a0a1076e62 --- /dev/null +++ b/htdocs/comm/askpricesupplier/contact.php @@ -0,0 +1,223 @@ + + * Copyright (C) 2005-2009 Destailleur Laurent + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Philippe Grand + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/contact.php + * \ingroup propal + * \brief Onglet de gestion des contacts de propal + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + +$langs->load("facture"); +$langs->load("orders"); +$langs->load("sendings"); +$langs->load("companies"); + +$id=GETPOST('id','int'); +$ref= GETPOST('ref','alpha'); +$lineid=GETPOST('lineid','int'); +$action=GETPOST('action','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'propal', $id); + +$object = new Propal($db); + +// Load object +if ($id > 0 || ! empty($ref)) +{ + $ret=$object->fetch($id, $ref); + if ($ret == 0) + { + $langs->load("errors"); + setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors'); + $error++; + } + else if ($ret < 0) + { + setEventMessage($object->error, 'errors'); + $error++; + } +} +if (! $error) +{ + $object->fetch_thirdparty(); +} +else +{ + header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); + exit; +} + + +/* + * Ajout d'un nouveau contact + */ + +if ($action == 'addcontact' && $user->rights->propale->creer) +{ + if ($object->id > 0) + { + $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + } + else + { + setEventMessage($object->error, 'errors'); + } + } +} + +// Bascule du statut d'un contact +else if ($action == 'swapstatut' && $user->rights->propale->creer) +{ + if ($object->id > 0) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } +} + +// Efface un contact +else if ($action == 'deletecontact' && $user->rights->propale->creer) +{ + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + dol_print_error($db); + } +} + +else if ($action == 'setaddress' && $user->rights->propale->creer) +{ + $result=$object->setDeliveryAddress($_POST['fk_address']); + if ($result < 0) dol_print_error($db,$object->error); +} + + +/* + * View + */ + +llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); + +$form = new Form($db); +$formcompany= new FormCompany($db); +$formother = new FormOther($db); + +if ($object->id > 0) +{ + $head = propal_prepare_head($object); + dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal'); + + /* + * Propal synthese pour rappel + */ + print ''; + + $linkback=''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Ref client + print ''; + print ''; + + // Customer + print ""; + print ''; + + // Delivery address + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + { + print ''; + } + + print "
'.$langs->trans('Ref').''; + print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); + print '
'; + print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print '
'; + print '
'; + print $object->ref_client; + print '
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'; + print ''; + + if ($action != 'editdelivery_address' && ! empty($object->brouillon)) + print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; + print '
'; + + if ($action == 'editdelivery_address') + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id); + } + else + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id); + } + print '
"; + + print ''; + + print '
'; + + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); + foreach($dirtpls as $reldir) + { + $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; + } +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/comm/askpricesupplier/document.php b/htdocs/comm/askpricesupplier/document.php new file mode 100644 index 00000000000..d224c20bc97 --- /dev/null +++ b/htdocs/comm/askpricesupplier/document.php @@ -0,0 +1,144 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Cédric Salvador + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/document.php + * \ingroup propal + * \brief Management page of documents attached to a business proposal + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +$langs->load('compta'); +$langs->load('other'); + +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); +$id = GETPOST('id','int'); +$ref = GETPOST('ref','alpha'); + +// Security check +$socid=''; +if (! empty($user->societe_id)) +{ + $action=''; + $socid = $user->societe_id; +} +$result = restrictedArea($user, 'propal', $id); + +// Get parameters +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + +$object = new Propal($db); +$object->fetch($id,$ref); +if ($object->id > 0) +{ + $object->fetch_thirdparty(); + $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; +} + +/* + * Actions + */ + + + +/* + * View + */ + +llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); + +$form = new Form($db); + +if ($object->id > 0) +{ + $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + + $head = propal_prepare_head($object); + dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal'); + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + $linkback=''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Ref client + print ''; + print ''; + + // Customer + print ""; + print ''; + + print ''; + print ''; + + print '
'.$langs->trans('Ref').''; + print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); + print '
'; + print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print '
'; + print '
'; + print $object->ref_client; + print '
".$langs->trans("Company")."'.$object->thirdparty->getNomUrl(1).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + $modulepart = 'propal'; + $permission = $user->rights->propal->creer; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + print $langs->trans("ErrorUnknown"); +} + +llxFooter(); +$db->close(); diff --git a/htdocs/comm/askpricesupplier/index.php b/htdocs/comm/askpricesupplier/index.php new file mode 100644 index 00000000000..a0e8a3409ab --- /dev/null +++ b/htdocs/comm/askpricesupplier/index.php @@ -0,0 +1,528 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/index.php + * \ingroup propal + * \brief Home page of proposal area + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php'; + +$langs->load("propal"); +$langs->load("companies"); + +// Security check +$socid=GETPOST('socid','int'); +if (isset($user->societe_id) && $user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} +$result = restrictedArea($user, 'propal'); + + +/* + * View + */ +$now=dol_now(); +$propalstatic=new Propal($db); +$companystatic=new Societe($db); +$form = new Form($db); +$formfile = new FormFile($db); +$help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos"; + +llxHeader("",$langs->trans("ProspectionArea"),$help_url); + +print_fiche_titre($langs->trans("ProspectionArea")); + +//print ''; +//print '
'; +print '
'; + + +/* + * Search form + */ +$var=false; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "
'.$langs->trans("SearchPropal").'
'; +print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; + + +/* + * Statistics + */ + +$sql = "SELECT count(p.rowid), p.fk_statut"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= ", ".MAIN_DB_PREFIX."propal as p"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE p.fk_soc = s.rowid"; +$sql.= " AND p.entity = ".$conf->entity; +if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql.= " AND p.fk_statut IN (0,1,2,3,4)"; +$sql.= " GROUP BY p.fk_statut"; +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + $total=0; + $totalinprocess=0; + $dataseries=array(); + $vals=array(); + // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) + while ($i < $num) + { + $row = $db->fetch_row($resql); + if ($row) + { + //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) + { + $vals[$row[1]]=$row[0]; + $totalinprocess+=$row[0]; + } + $total+=$row[0]; + } + $i++; + } + $db->free($resql); + + print ''; + print ''."\n"; + $var=true; + $listofstatus=array(0,1,2,3,4); + foreach ($listofstatus as $status) + { + $dataseries[]=array('label'=>$propalstatic->LibStatut($status,1),'data'=>(isset($vals[$status])?(int) $vals[$status]:0)); + if (! $conf->use_javascript_ajax) + { + $var=!$var; + print ""; + print ''; + print ''; + print "\n"; + } + } + if ($conf->use_javascript_ajax) + { + print ''; + } + //if ($totalinprocess != $total) + //print ''; + print ''; + print "
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$propalstatic->LibStatut($status,0).''.(isset($vals[$status])?$vals[$status]:0).'
'; + $data=array('series'=>$dataseries); + dol_print_graph('stats',300,180,$data,1,'pie',1); + print '
'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')'.$totalinprocess.'
'.$langs->trans("Total").''.$total.'

"; +} +else +{ + dol_print_error($db); +} + + +/* + * Draft proposals + */ +if (! empty($conf->propal->enabled)) +{ + $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 0"; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + + $resql=$db->query($sql); + if ($resql) + { + print ''; + print ''; + print ''; + $langs->load("propal"); + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + + $propalstatic->id=$obj->rowid; + $propalstatic->ref=$obj->ref; + print ''; + + $companystatic->id=$obj->socid; + $companystatic->name=$obj->socname; + $companystatic->client=$obj->client; + $companystatic->canvas=$obj->canvas; + print ''; + + print ''; + $i++; + } + } + print "
'.$langs->trans("DraftPropals").'
'.$propalstatic->getNomUrl(1).''.$companystatic->getNomUrl(1,'customer',24).'

"; + } +} + + +//print '
'; +print '
'; + + +$max=5; + +/* + * Last modified proposals + */ + +$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; +$sql.= " date_cloture as datec"; +$sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; +$sql.= ", ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE c.fk_soc = s.rowid"; +$sql.= " AND c.entity = ".$conf->entity; +//$sql.= " AND c.fk_statut > 2"; +if ($socid) $sql .= " AND c.fk_soc = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql.= " ORDER BY c.tms DESC"; +$sql.= $db->plimit($max, 0); + +$resql=$db->query($sql); +if ($resql) +{ + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + + print ""; + print ''; + + $companystatic->id=$obj->socid; + $companystatic->name=$obj->socname; + $companystatic->client=$obj->client; + $companystatic->canvas=$obj->canvas; + print ''; + + print ''; + print ''; + print ''; + $i++; + } + } + print "
'.$langs->trans("LastModifiedProposals",$max).'
'; + + $propalstatic->id=$obj->rowid; + $propalstatic->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $propalstatic->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); + print '
'; + + print '
'.$companystatic->getNomUrl(1,'customer').''.dol_print_date($db->jdate($obj->datec),'day').''.$propalstatic->LibStatut($obj->fk_statut,5).'

"; +} +else dol_print_error($db); + + +/* + * Opened proposals + */ +if (! empty($conf->propal->enabled) && $user->rights->propale->lire) +{ + $langs->load("propal"); + + $now=dol_now(); + + $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE p.fk_soc = s.rowid"; + $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql.= " ORDER BY p.rowid DESC"; + + $result=$db->query($sql); + if ($result) + { + $total = 0; + $num = $db->num_rows($result); + $i = 0; + if ($num > 0) + { + $var=true; + + print ''; + print ''; + + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + while ($i < $nbofloop) + { + $obj = $db->fetch_object($result); + $var=!$var; + print ''; + + // Ref + print '"; + + $companystatic->id=$obj->socid; + $companystatic->name=$obj->socname; + $companystatic->client=$obj->client; + $companystatic->canvas=$obj->canvas; + print ''."\n"; + + print ''."\n"; + print ''; + print ''."\n"; + print ''."\n"; + $i++; + $total += $obj->total_ttc; + } + if ($num > $nbofloop) + { + print '"; + } + else if ($total>0) + { + print '"; + } + print "
'.$langs->trans("ProposalsOpened").' '.$num.'
'; + + $propalstatic->id=$obj->propalid; + $propalstatic->ref=$obj->ref; + + print ''; + print ''; + print ''; + print '
'; + print $propalstatic->getNomUrl(1); + print ''; + if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); + print '
'; + + print "
'.$companystatic->getNomUrl(1,'customer',44).''; + print dol_print_date($db->jdate($obj->dp),'day').''.price($obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut,3).'
'.$langs->trans("XMoreLines", ($num - $nbofloop))."
'.$langs->trans("Total")."".price($total)." 

"; + } + } + else + { + dol_print_error($db); + } +} + +/* + * Proposals to process + */ +/* +if (! empty($conf->propal->enabled)) +{ + $sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as name, s.rowid as socid"; + $sql.=" FROM ".MAIN_DB_PREFIX."propal as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 1"; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " ORDER BY c.rowid DESC"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } + + print "
'.$langs->trans("ProposalsToProcess").' '.$num.'
'; + + $propalstatic->id=$obj->rowid; + $propalstatic->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $propalstatic->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); + print '
'; + + print '
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).''.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).'

"; + } + else dol_print_error($db); +} +*/ + +/* + * Proposal that are in a shipping process + */ +/*if (! empty($conf->propal->enabled)) +{ + $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 2 "; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " ORDER BY c.rowid DESC"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } + print "
'.$langs->trans("OnProcessOrders").' '.$num.'
'; + + $propalstatic->id=$obj->rowid; + $propalstatic->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $propalstatic->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); + print '
'; + + print '
'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).'

"; + } + else dol_print_error($db); +} +*/ + +//print '
'; +print ''; + + +llxFooter(); + +$db->close(); diff --git a/htdocs/comm/askpricesupplier/info.php b/htdocs/comm/askpricesupplier/info.php new file mode 100644 index 00000000000..d3a3899537b --- /dev/null +++ b/htdocs/comm/askpricesupplier/info.php @@ -0,0 +1,65 @@ + + * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/info.php + * \ingroup propal + * \brief Page d'affichage des infos d'une proposition commerciale + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; + +$langs->load('propal'); +$langs->load('compta'); + +$id=GETPOST('id','int'); +$socid=GETPOST('socid','int'); + +// Security check +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result = restrictedArea($user, 'propal', $id); + + +/* + * View + */ + +llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); + +$object = new Propal($db); +$object->fetch($id); +$object->fetch_thirdparty(); + +$head = propal_prepare_head($object); +dol_fiche_head($head, 'info', $langs->trans('Proposal'), 0, 'propal'); + +$object->info($object->id); + +print '
'; +dol_print_object_info($object); +print '
'; + +print ''; + + +llxFooter(); +$db->close(); diff --git a/htdocs/comm/askpricesupplier/list.php b/htdocs/comm/askpricesupplier/list.php new file mode 100644 index 00000000000..c28128e81c5 --- /dev/null +++ b/htdocs/comm/askpricesupplier/list.php @@ -0,0 +1,464 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2011 Philippe Grand + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2013 Cédric Salvador +* + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/list.php + * \ingroup propal + * \brief Page of commercial proposals card and list + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (! empty($conf->projet->enabled)) + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + +$langs->load('companies'); +$langs->load('propal'); +$langs->load('compta'); +$langs->load('bills'); +$langs->load('orders'); +$langs->load('products'); + +$socid=GETPOST('socid','int'); + +$search_user=GETPOST('search_user','int'); +$search_sale=GETPOST('search_sale','int'); +$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); +$search_refcustomer=GETPOST('search_refcustomer','alpha'); +$search_societe=GETPOST('search_societe','alpha'); +$search_montant_ht=GETPOST('search_montant_ht','alpha'); +$search_author=GETPOST('search_author','alpha'); +$search_town=GETPOST('search_town','alpha'); +$viewstatut=$db->escape(GETPOST('viewstatut')); +$object_statut=$db->escape(GETPOST('propal_statut')); + +$sall=GETPOST("sall"); +$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); +$year=GETPOST("year"); +$month=GETPOST("month"); + +// Nombre de ligne pour choix de produit/service predefinis +$NBLINES=4; + +// Security check +$module='propal'; +$dbtable=''; +$objectid=''; +if (! empty($user->societe_id)) $socid=$user->societe_id; +if (! empty($socid)) +{ + $objectid=$socid; + $module='societe'; + $dbtable='&societe'; +} +$result = restrictedArea($user, $module, $objectid, $dbtable); + +if (GETPOST("button_removefilter") || GETPOST("button_removefilter_x")) // Both tests are required to be compatible with all browsers +{ + $search_categ=''; + $search_user=''; + $search_sale=''; + $search_ref=''; + $search_refcustomer=''; + $search_societe=''; + $search_montant_ht=''; + $search_author=''; + $search_town=''; + $year=''; + $month=''; + $viewstatut=''; + $object_statut=''; +} + +if($object_statut != '') +$viewstatut=$object_statut; + + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('propallist')); + + + +/* + * Actions + */ + + +$parameters=array('socid'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + + +/* + * View + */ + +llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); +$formpropal = new FormPropal($db); +$companystatic=new Societe($db); + +$now=dol_now(); + +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +if (! $sortfield) $sortfield='p.datep'; +if (! $sortorder) $sortorder='DESC'; +$limit = $conf->liste_limit; + + +$sql = 'SELECT s.rowid, s.nom as name, s.town, s.client, s.code_client,'; +$sql.= ' p.rowid as propalid, p.note_private, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; +if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; +$sql.= ' u.login'; +$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p'; +if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; +// We'll need this table joined to the select in order to filter by sale +if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_user > 0) +{ + $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; + $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; +} +$sql.= ' WHERE p.fk_soc = s.rowid'; +$sql.= ' AND p.entity = '.$conf->entity; +if (! $user->rights->societe->client->voir && ! $socid) //restriction +{ + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +} +if ($search_town) {//restriction + $sql .= natural_search('s.town', $search_town); +} +if ($search_ref) { + $sql .= natural_search('p.ref', $search_ref); +} +if ($search_refcustomer) { + $sql .= natural_search('p.ref_client', $search_refcustomer); +} +if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); +} +if ($search_author) +{ + $sql.= " AND u.login LIKE '%".$db->escape(trim($search_author))."%'"; +} +if ($search_montant_ht) +{ + $sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'"; +} +if ($sall) { + $sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall); +} +if ($socid) $sql.= ' AND s.rowid = '.$socid; +if ($viewstatut <> '') +{ + $sql.= ' AND p.fk_statut IN ('.$viewstatut.')'; +} +if ($month > 0) +{ + if ($year > 0 && empty($day)) + $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else if ($year > 0 && ! empty($day)) + $sql.= " AND p.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + else + $sql.= " AND date_format(p.datep, '%m') = '".$month."'"; +} +else if ($year > 0) +{ + $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; +} +if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; +if ($search_user > 0) +{ + $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; +} + + +$sql.= ' ORDER BY '.$sortfield.' '.$sortorder.', p.ref DESC'; + +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + + +$sql.= $db->plimit($limit + 1,$offset); +$result=$db->query($sql); + +if ($result) +{ + $objectstatic=new Propal($db); + $userstatic=new User($db); + $num = $db->num_rows($result); + + if ($socid) + { + $soc = new Societe($db); + $soc->fetch($socid); + } + + $param='&socid='.$socid.'&viewstatut='.$viewstatut; + if ($month) $param.='&month='.$month; + if ($year) $param.='&year='.$year; + if ($search_ref) $param.='&search_ref=' .$search_ref; + if ($search_refcustomer) $param.='&search_refcustomer=' .$search_refcustomer; + if ($search_societe) $param.='&search_societe=' .$search_societe; + if ($search_user > 0) $param.='&search_user='.$search_user; + if ($search_sale > 0) $param.='&search_sale='.$search_sale; + if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; + if ($search_author) $param.='&search_author='.$search_author; + if ($search_town) $param.='&search_town='.$search_town; + print_barre_liste($langs->trans('ListOfProposals').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); + + // Lignes des champs de filtre + print '
'; + + $i = 0; + print ''; + + $moreforfilter=''; + + // If the user can view prospects other than his' + if ($user->rights->societe->client->voir || $socid) + { + $langs->load("commercial"); + $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; + $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); + $moreforfilter.='       '; + } + // If the user can view prospects other than his' + if ($user->rights->societe->client->voir || $socid) + { + $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; + $moreforfilter.=$form->select_dolusers($search_user,'search_user',1); + } + if (! empty($moreforfilter)) + { + print ''; + print ''; + } + + print ''; + print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('RefCustomer'),$_SERVER["PHP_SELF"],'p.ref_client','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Company'),$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Town'),$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('DateEndPropalShort'),$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Author'),$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre(''); + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + // Date + print ''; + print ''; + // Amount + print ''; + // Author + print ''; + print ''; + + print ''; + + print "\n"; + + $var=true; + $total=0; + $subtotal=0; + + while ($i < min($num,$limit)) + { + $objp = $db->fetch_object($result); + $now = dol_now(); + $var=!$var; + print ''; + print '\n"; + + // Customer ref + print ''; + + $url = DOL_URL_ROOT.'/comm/card.php?socid='.$objp->rowid; + + // Company + $companystatic->id=$objp->rowid; + $companystatic->name=$objp->name; + $companystatic->client=$objp->client; + $companystatic->code_client=$objp->code_client; + print ''; + + // Town + print ''; + + // Date proposal + print '\n"; + + // Date end validity + if ($objp->dfv) + { + print ''; + } + else + { + print ''; + } + + print '\n"; + + $userstatic->id=$objp->fk_user_author; + $userstatic->login=$objp->login; + print '\n"; + + print '\n"; + + print ''; + + print "\n"; + + $total += $objp->total_ht; + $subtotal += $objp->total_ht; + + $i++; + } + + if ($total>0) + { + if($num<$limit){ + $var=!$var; + print ''; + print ''; + print ''; + } + else + { + $var=!$var; + print ''; + print ''; + print ''; + } + + } + + print '
'; + print $moreforfilter; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print $langs->trans('Month').': '; + print ''; + //print ' '.$langs->trans('Year').': '; + $syear = $year; + $formother->select_year($syear,'year',1, 20, 5); + print ' '; + print ''; + print ''; + print ''; + print ''; + $formpropal->selectProposalStatus($viewstatut,1); + print ''; + print ''; + print ''; + print '
'; + + $objectstatic->id=$objp->propalid; + $objectstatic->ref=$objp->ref; + + print ''; + print ''; + + print ''; + + // Ref + print '
'; + print $objectstatic->getNomUrl(1); + print ''; + if ($objp->fk_statut == 1 && $db->jdate($objp->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + if (! empty($objp->note_private)) + { + print ' '; + print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; + print ''; + } + print ''; + $filename=dol_sanitizeFileName($objp->ref); + $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($objp->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->propalid; + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print '
'; + + print "
'; + print $objp->ref_client; + print ''; + print $companystatic->getNomUrl(1,'customer'); + print ''; + print $objp->town; + print ''; + print dol_print_date($db->jdate($objp->dp), 'day'); + print "'.dol_print_date($db->jdate($objp->dfv),'day'); + print ' '.price($objp->total_ht)."'; + if ($userstatic->id) print $userstatic->getLoginUrl(1); + else print ' '; + print "'.$objectstatic->LibStatut($objp->fk_statut,5)." 
'.$langs->trans("TotalHT").''.price($total).'
'.$langs->trans("TotalHTforthispage").''.price($total).'
'; + + print '
'; + + $db->free($result); +} +else +{ + dol_print_error($db); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/comm/askpricesupplier/note.php b/htdocs/comm/askpricesupplier/note.php new file mode 100644 index 00000000000..9292684d06f --- /dev/null +++ b/htdocs/comm/askpricesupplier/note.php @@ -0,0 +1,151 @@ + + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Florian Henry + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/note.php + * \ingroup propal + * \brief Fiche d'information sur une proposition commerciale + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; + +$langs->load('propal'); +$langs->load('compta'); +$langs->load('bills'); + +$id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'propale', $id, 'propal'); + +$object = new Propal($db); + + + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + +$permissionnote=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + + +/******************************************************************************/ +/* Affichage fiche */ +/******************************************************************************/ + +llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); + +$form = new Form($db); + +if ($id > 0 || ! empty($ref)) +{ + if ($mesg) print $mesg; + + $now=dol_now(); + + if ($object->fetch($id, $ref)) + { + $societe = new Societe($db); + if ( $societe->fetch($object->socid) ) + { + $head = propal_prepare_head($object); + dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal'); + + print ''; + + $linkback = ''.$langs->trans('BackToList').''; + + // Ref + print ''; + + // Ref client + print ''; + print ''; + + // Customer + if ( is_null($object->client) ) + $object->fetch_thirdparty(); + print ""; + print ''; + + // Ligne info remises tiers + print ''; + + // Date + print ''; + print ''; + + // Date fin propal + print ''; + print ''; + print ''; + + print "
'.$langs->trans('Ref').''; + print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); + print '
'; + print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print '
'; + print '
'; + print $object->ref_client; + print '
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$langs->trans('Discounts').''; + if ($societe->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_percent); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount=$societe->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
'.$langs->trans('Date').''; + print dol_print_date($object->date,'daytext'); + print '
'.$langs->trans('DateEndPropal').''; + if ($object->fin_validite) + { + print dol_print_date($object->fin_validite,'daytext'); + if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + } + else + { + print $langs->trans("Unknown"); + } + print '
"; + + print '
'; + + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + dol_fiche_end(); + } + } +} + + +llxFooter(); +$db->close(); diff --git a/htdocs/comm/askpricesupplier/tpl/index.html b/htdocs/comm/askpricesupplier/tpl/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/comm/askpricesupplier/tpl/linkedobjectblock.tpl.php b/htdocs/comm/askpricesupplier/tpl/linkedobjectblock.tpl.php new file mode 100644 index 00000000000..cb920afd5fc --- /dev/null +++ b/htdocs/comm/askpricesupplier/tpl/linkedobjectblock.tpl.php @@ -0,0 +1,79 @@ + + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2014 Marcos García + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal/tpl/linkedobjectblock.tpl.php + * \ingroup propal + * \brief Template to show objects linked to proposals + */ +?> + + + +'; +print_titre($langs->trans('RelatedCommercialProposals')); +?> + + + + + + + + + + > + + + + + + + + + + + +
trans("Ref"); ?>trans('RefCustomer'); ?>trans("Date"); ?>trans("AmountHTShort"); ?>trans("Status"); ?>
+ trans("ShowPropal"),"propal").' '.$object->ref; ?>ref_client; ?>date,'day'); ?>rights->propale->lire) { + $total = $total + $object->total_ht; + echo price($object->total_ht); + } ?>getLibStatut(3); ?>
trans('TotalHT'); ?>rights->propale->lire) { + echo price($total); + } ?> 
+ + diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php new file mode 100644 index 00000000000..9ae6d15ba71 --- /dev/null +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -0,0 +1,226 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Juanjo Menent + * + * 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 3 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, see . + */ + +/** + * \defgroup propale Module commercial proposals + * \brief Module pour gerer la tenue de propositions commerciales + * \file htdocs/core/modules/modPropale.class.php + * \ingroup propale + * \brief Fichier de description et activation du module Propale + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Classe de description et activation du module Propale + */ +class modAskPriceSupplier extends DolibarrModules +{ + + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf; + + $this->db = $db; + $this->numero = 999999; + + $this->family = "products"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + $this->description = "askpricesupplierDESC"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = '0.1'; + + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->special = 0; + $this->picto='askpricesupplier'; + + // Data directories to create when module is enabled + $this->dirs = array(); + + // Dependancies + $this->depends = array('modFournisseur'); + $this->requiredby = array(); + $this->config_page_url = array("askpricesupplier.php"); + $this->langfiles = array("askpricesupplier"); + + // Constants + $this->const = array(); + $r=0; + + /*$this->const[$r][0] = "PROPALE_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "azur"; + $this->const[$r][3] = 'Nom du gestionnaire de generation des propales en PDF'; + $this->const[$r][4] = 0; + $r++;*/ + + // Boxes + $this->boxes = array(); + + // Permissions + $this->rights = array(); + $this->rights_class = 'askpricesupplier'; + $r=0; + + $r++; + $this->rights[$r][0] = $this->numero + $r; // id de la permission + $this->rights[$r][1] = 'Créer/modifier les demandes fournisseurs'; // libelle de la permission + $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'create'; + + $r++; + $this->rights[$r][0] = $this->numero + $r; // id de la permission + $this->rights[$r][1] = 'Lire les demandes fournisseurs'; // libelle de la permission + $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'read'; + + $r++; + $this->rights[$r][0] = $this->numero + $r; // id de la permission + $this->rights[$r][1] = 'Valider les demandes fournisseurs'; // libelle de la permission + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'read'; + $this->rights[$r][5] = 'validate'; + + $r++; + $this->rights[$r][0] = $this->numero + $r; // id de la permission + $this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'read'; + $this->rights[$r][5] = 'send'; + + $r++; + $this->rights[$r][0] = $this->numero + $r; // id de la permission + $this->rights[$r][1] = 'Supprimer les demandes fournisseurs'; // libelle de la permission + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'delete'; + + // Exports + //-------- + $r=0; +/* + $r++; + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='ProposalsAndProposalsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r]=array(array("propale","export")); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.datec'=>"DateCreation",'c.datep'=>"DatePropal",'c.fin_validite'=>"DateEndPropal",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total'=>"TotalTTC",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate','c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); + $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.ref'=>'Text','p.label'=>'Text'); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"propal",'c.ref'=>"propal",'c.ref_client'=>"propal",'c.fk_soc'=>"propal",'c.datec'=>"propal",'c.datep'=>"propal",'c.fin_validite'=>"propal",'c.remise_percent'=>"propal",'c.total_ht'=>"propal",'c.total'=>"propal",'c.fk_statut'=>"propal",'c.note_public'=>"propal",'c.date_livraison'=>"propal",'cd.rowid'=>'propal_line','cd.label'=>"propal_line",'cd.description'=>"propal_line",'cd.product_type'=>'propal_line','cd.tva_tx'=>"propal_line",'cd.qty'=>"propal_line",'cd.total_ht'=>"propal_line",'cd.total_tva'=>"propal_line",'cd.total_ttc'=>"propal_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'); + $this->export_dependencies_array[$r]=array('propal_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s '; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'propal as c'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uc.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'propal_extrafields as extra ON c.rowid = extra.fk_object'; + $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'propaldet as cd'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cd.fk_product = p.rowid)'; + $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; + $this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity; + */ + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=commercial', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'askpricesupplierMENU_LEFT_TITLE', + 'leftmenu'=>'askpricesuppliersubmenu', + 'url'=>'/askpricesupplier/index.php', + 'langs'=>'askpricesupplier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'enabled'=>'$conf->askpricesupplier->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->askpricesupplier->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'user'=>2 // 0=Menu for internal users, 1=external users, 2=both + ); + $r++; + + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu', + 'type'=>'left', + 'titre'=>'askpricesupplierMENU_LEFT_TITLE_NEW', + 'url'=>'/askpricesupplier/card.php?action=create', + 'langs'=>'askpricesupplier', + 'enabled'=>'$conf->askpricesupplier->enabled', + 'perms'=>'$user->rights->askpricesupplier->create', + 'user'=>2 + ); + $r++; + + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu', + 'type'=>'left', + 'titre'=>'askpricesupplierMENU_LEFT_TITLE_LIST', + 'url'=>'/askpricesupplier/list.php', + 'langs'=>'askpricesupplier', + 'enabled'=>'$conf->askpricesupplier->enabled', + 'perms'=>'$user->rights->askpricesupplier->read', + 'user'=>2 + ); + $r++; + } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + //global $conf,$langs; + + $sql = array(); + + $result=$this->_load_tables('/mymodule/sql/'); + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function remove($options='') + { + $sql = array(); + + return $this->_remove($sql,$options); + } + +} diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang new file mode 100644 index 00000000000..784082f42c4 --- /dev/null +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -0,0 +1,6 @@ +# Dolibarr language file - Source file is en_US - askpricesupplier +AskPriceSupplier=Demande de prix fournisseur +askpricesupplierDESC=Gestion des demandes de prix aux fournisseurs +askpricesupplierMENU_LEFT_TITLE=Demandes de prix fourn. +askpricesupplierMENU_LEFT_TITLE_NEW=Nouvelle demande +askpricesupplierMENU_LEFT_TITLE_LIST=Liste \ No newline at end of file diff --git a/htdocs/theme/eldy/img/object_askpricesupplier.png b/htdocs/theme/eldy/img/object_askpricesupplier.png new file mode 100644 index 0000000000000000000000000000000000000000..9ab48924ccb26606d331789871b185e8c015e221 GIT binary patch literal 1038 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmUzPnffIy#(^vlDyqr z82*Fcg1yTp14TFsJR*yMvQ&rUPlPc?>bf)*fbHU{?2ZaSX9I-8(7Q zV{)L#@$)q|uYE|Jw9wCFsp6Iz#@~~~Iz*?`t#DX0;l!dAoovBKDMRtV6p^UgOMHT* zv-EScnt8q-+}7l?GUuvsWZ;vS1yg2k-4^+3|8E;kMUj#RMLX|&w*Fp!?yvA)_s&_>)=GLaBtp^V}&N!QPBgZU4XIf<0_0<6y)1E(hqSNN8 zB)H!*I4CIZ1A~0rdhxk)V_&?kZb;B*IeF64#N6C@X;A5gJ1bbz0vpeM{P^*{kD9R4 zLP-mm^9wJ^G;iE1I9Yi9gA%KSmtP)`W< z3Z5T$AHn?nbX-h+mRnq$+>s>1h&*v^0nGzz^5Yz(Zp*&u=;`6P@wSYmIqu9)zXSGF z0*~eIH-=A}I`!z`gr9obrZjb(IN`C>M{VA8TfB60PLxo-A<2i@&Bi4p3 ztjNsNT(o#`tx)HYGa>IE@9s#;lHmDz+Bh5IwlpO}#QtMhKx?`d&& z_SLfM>gw*e6~JHnm(}D-X7jA%>TKEVr;@v^Eu}1{dOpci{T1OqNuK#;`m-Hg;U_|W zKek@pSe;rihm~aN^%yH%v-I4M4 zcQtq3mCTN^eC3}{qqK5%IqhBtjMJyq8KpTQo~O!eaxLHz$YeDOJ{# z6w?zE{>xP5e`X<1!WKbb{!uM)jVMV;EJ?LWE=mPb3`Pb9mbyS>XdGf_Y-MC_Wo)W# nU}R-raJl_f1&W5;{FKbJO57S2-AXzF)WG2B>gTe~DWM4ff-TFL literal 0 HcmV?d00001 From 6fee87ca56752dc11c764604641045a1835c16f4 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 26 Jan 2015 17:35:37 +0100 Subject: [PATCH 002/120] [CORE] ajout en commentaire de la requete sql de creation de table (#new_ask_price). --- htdocs/core/modules/modAskPriceSupplier.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index 9ae6d15ba71..1c108c572d1 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -201,9 +201,11 @@ class modAskPriceSupplier extends DolibarrModules { //global $conf,$langs; + /*CREATE IF NOT EXISTS llx_askpricesupplier (rowid int auto_increment);*/ + $sql = array(); - $result=$this->_load_tables('/mymodule/sql/'); + //$result=$this->_load_tables('/mymodule/sql/'); return $this->_init($sql, $options); } From aaacca9b136deb2fa7f65192ad949290eb563b05 Mon Sep 17 00:00:00 2001 From: phf Date: Tue, 27 Jan 2015 16:53:27 +0100 Subject: [PATCH 003/120] =?UTF-8?q?[CORE]=20premi=C3=A8re=20partie=20des?= =?UTF-8?q?=20grosses=20modifications=20(#new=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/askpricesupplier.php | 2328 +++++++++++++++++ .../class/askpricesupplier.class.php | 270 +- htdocs/comm/askpricesupplier/index.php | 94 +- .../sql/llx_askpricesupplier.sql | 58 + .../sql/llx_askpricesupplier_extrafields.sql | 8 + .../sql/llx_askpricesupplierdet.sql | 36 + .../llx_askpricesupplierdet_extrafields.sql | 8 + .../tpl/linkedobjectblock.tpl.php | 6 +- htdocs/core/lib/askpricesupplier.lib.php | 148 ++ .../doc/doc_generic_proposal_odt.modules.php | 484 ++++ .../modules/askpricesupplier/doc/index.html | 0 .../askpricesupplier/doc/pdf_azur.modules.php | 1385 ++++++++++ .../core/modules/askpricesupplier/index.html | 0 .../askpricesupplier/mod_propale_marbre.php | 153 ++ .../askpricesupplier/mod_propale_saphir.php | 131 + .../modules_askpricesupplier.php | 165 ++ .../modules/modAskPriceSupplier.class.php | 75 +- .../interface_90_all_Demo.class.php-NORUN | 13 + htdocs/langs/fr_FR/askpricesupplier.lang | 125 +- 19 files changed, 5283 insertions(+), 204 deletions(-) create mode 100644 htdocs/comm/askpricesupplier.php create mode 100644 htdocs/comm/askpricesupplier/sql/llx_askpricesupplier.sql create mode 100644 htdocs/comm/askpricesupplier/sql/llx_askpricesupplier_extrafields.sql create mode 100644 htdocs/comm/askpricesupplier/sql/llx_askpricesupplierdet.sql create mode 100644 htdocs/comm/askpricesupplier/sql/llx_askpricesupplierdet_extrafields.sql create mode 100644 htdocs/core/lib/askpricesupplier.lib.php create mode 100644 htdocs/core/modules/askpricesupplier/doc/doc_generic_proposal_odt.modules.php create mode 100644 htdocs/core/modules/askpricesupplier/doc/index.html create mode 100644 htdocs/core/modules/askpricesupplier/doc/pdf_azur.modules.php create mode 100644 htdocs/core/modules/askpricesupplier/index.html create mode 100644 htdocs/core/modules/askpricesupplier/mod_propale_marbre.php create mode 100644 htdocs/core/modules/askpricesupplier/mod_propale_saphir.php create mode 100644 htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php new file mode 100644 index 00000000000..bd694f4a925 --- /dev/null +++ b/htdocs/comm/askpricesupplier.php @@ -0,0 +1,2328 @@ + + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2011 Philippe Grand + * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2014 Ferran Marcet + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/propal.php + * \ingroup propale + * \brief Page of commercial proposals card and list + */ +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formpropal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/comm/askpricesupplier/class/askpricesupplier.class.php'; +require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/modules/askpricesupplier/modules_askpricesupplier.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/askpricesupplier.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +if (! empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +} + +$langs->load('companies'); +$langs->load('askpricesupplier'); +$langs->load('compta'); +$langs->load('bills'); +$langs->load('orders'); +$langs->load('products'); +$langs->load("deliveries"); +$langs->load('sendings'); +if (! empty($conf->margin->enabled)) + $langs->load('margins'); + +$error = 0; + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'alpha'); +$origin = GETPOST('origin', 'alpha'); +$originid = GETPOST('originid', 'int'); +$confirm = GETPOST('confirm', 'alpha'); +$lineid = GETPOST('lineid', 'int'); +$contactid = GETPOST('contactid','int'); + +// PDF +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); + +// Nombre de ligne pour choix de produit/service predefinis +$NBLINES = 4; + +// Security check +if (! empty($user->societe_id)) $socid = $user->societe_id; +$result = restrictedArea($user, 'askpricesupplier', $id); + +$object = new AskPriceSupplier($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +if ($id > 0 || ! empty($ref)) { + $ret = $object->fetch($id, $ref); + if ($ret > 0) + $ret = $object->fetch_thirdparty(); + if ($ret < 0) + dol_print_error('', $object->error); +} + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('propalcard','globalcard')); + +$permissionnote = $user->rights->askpricesupplier->creer; // Used by the include of actions_setnotes.inc.php + + +/* + * Actions + */ + +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes') + { + if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + { + setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + } + else + { + if ($object->id > 0) { + $result = $object->createFromClone($socid); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + exit(); + } else { + setEventMessage($object->error, 'errors'); + $action = ''; + } + } + } + } + + // Delete proposal + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->askpricesupplier->supprimer) + { + $result = $object->delete($user); + if ($result > 0) { + header('Location: ' . DOL_URL_ROOT . '/comm/askpricesupplier/list.php'); + exit(); + } else { + $langs->load("errors"); + setEventMessage($langs->trans($object->error), 'errors'); + } + } + + // Remove line + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->askpricesupplier->creer) + { + $result = $object->deleteline($lineid); + // reorder lines + if ($result) + $object->line_order(true); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + exit(); + } + + // Validation + else if ($action == 'confirm_validate' && $confirm == 'yes' && + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->validate))) + ) + { + $result = $object->valid($user); + if ($result >= 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + } else { + $langs->load("errors"); + if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); + else setEventMessage($langs->trans($object->error), 'errors'); + } + } + + else if ($action == 'setdate' && $user->rights->askpricesupplier->creer) + { + $datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + + if (empty($datep)) { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); + } + + if (! $error) { + $result = $object->set_date($user, $datep); + if ($result < 0) + dol_print_error($db, $object->error); + } + } + else if ($action == 'setecheance' && $user->rights->askpricesupplier->creer) + { + $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); + if ($result < 0) + dol_print_error($db, $object->error); + } + else if ($action == 'setdate_livraison' && $user->rights->askpricesupplier->creer) + { + $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); + if ($result < 0) + dol_print_error($db, $object->error); + } + + // Positionne ref client + else if ($action == 'set_ref_client' && $user->rights->askpricesupplier->creer) + { + $object->set_ref_client($user, $_POST['ref_client']); + } + + // Create proposal + else if ($action == 'add' && $user->rights->askpricesupplier->creer) + { + $object->socid = $socid; + $object->fetch_thirdparty(); + + $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $duration = GETPOST('duree_validite'); + + if (empty($datep)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); + $action = 'create'; + $error ++; + } + if (empty($duration)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); + $action = 'create'; + $error ++; + } + + if ($socid < 1) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); + $action = 'create'; + $error ++; + } + + if (! $error) + { + $db->begin(); + + // Si on a selectionne une propal a copier, on realise la copie + if (GETPOST('createmode') == 'copy' && GETPOST('copie_askpricesupplier')) + { + if ($object->fetch(GETPOST('copie_askpricesupplier')) > 0) { + $object->ref = GETPOST('ref'); + $object->datep = $datep; + $object->date_livraison = $date_delivery; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); + $object->duree_validite = $duration; + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); + $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = GETPOST('remise_absolue'); + $object->socid = GETPOST('socid'); + $object->contactid = GETPOST('contactid'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); + $object->author = $user->id; // deprecated + $object->note = GETPOST('note'); + $object->statut = 0; + + $id = $object->create_from($user); + } else { + setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_askpricesupplier')), 'errors'); + } + } else { + $object->ref = GETPOST('ref'); + $object->ref_client = GETPOST('ref_client'); + $object->datep = $datep; + $object->date_livraison = $date_delivery; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); + $object->duree_validite = GETPOST('duree_validite'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); + $object->contactid = GETPOST('contactid'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); + $object->author = $user->id; // deprecated + $object->note = GETPOST('note'); + + $object->origin = GETPOST('origin'); + $object->origin_id = GETPOST('originid'); + + for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) + { + if ($_POST['idprod' . $i]) { + $xid = 'idprod' . $i; + $xqty = 'qty' . $i; + $xremise = 'remise' . $i; + $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); + } + } + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + $action = 'create'; + } + } + + if (! $error) + { + if ($origin && $originid) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { + $element = $regs [1]; + $subelement = $regs [2]; + } + + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'askpricesupplier') { + $element = 'comm/askpricesupplier'; + $subelement = 'askpricesupplier'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + if ($element == 'inter') { + $element = $subelement = 'ficheinter'; + } + if ($element == 'shipping') { + $element = $subelement = 'expedition'; + } + + $object->origin = $origin; + $object->origin_id = $originid; + + // Possibility to add external linked objects with hooks + $object->linked_objects [$object->origin] = $object->origin_id; + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { + $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + } + + $id = $object->create($user); + if ($id > 0) + { + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); + + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + { + $srcobject->fetch_lines(); + $lines = $srcobject->lines; + } + + $fk_parent_line=0; + $num=count($lines); + for ($i=0;$i<$num;$i++) + { + $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); + $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + + // Positive line + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); + + // Date start + $date_start = false; + if ($lines[$i]->date_debut_prevue) + $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) + $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) + $date_start = $lines[$i]->date_start; + + // Date end + $date_end = false; + if ($lines[$i]->date_fin_prevue) + $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) + $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) + $date_end = $lines[$i]->date_end; + + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_option = $lines[$i]->array_options; + } + + $tva_tx=get_default_tva($mysoc, $object->thirdparty); + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_option); + + if ($result > 0) { + $lineid = $result; + } else { + $lineid = 0; + $error ++; + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) + $error ++; + } else { + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + $error ++; + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $error ++; + } + } // Standard creation + else + { + $id = $object->create($user); + } + + if ($id > 0) + { + // Insertion contact par defaut si defini + if (GETPOST('contactid') > 0) + { + $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); + if ($result < 0) + { + $error++; + setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + } + } + + if (! $error) + { + $db->commit(); + + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + + $ret = $object->fetch($id); // Reload to get new records + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + exit(); + } + else + { + $db->rollback(); + $action='create'; + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + $action='create'; + } + } + } + } + + // Classify billed + else if ($action == 'classifybilled' && $user->rights->askpricesupplier->cloturer) { + $object->cloture($user, 4, ''); + } + + // Reopen proposal + else if ($action == 'confirm_reopen' && $user->rights->askpricesupplier->cloturer && ! GETPOST('cancel')) { + // prevent browser refresh from reopening proposal several times + if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) { + $object->reopen($user, 1); + } + } + + // Close proposal + else if ($action == 'setstatut' && $user->rights->askpricesupplier->cloturer && ! GETPOST('cancel')) { + if (! GETPOST('statut')) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); + $action = 'statut'; + } else { + // prevent browser refresh from closing proposal several times + if ($object->statut == 1) { + $object->cloture($user, GETPOST('statut'), GETPOST('note')); + } + } + } + + // Classify billed + else if ($action == 'classifybilled' && $user->rights->askpricesupplier->cloturer) { + $object->cloture($user, 4, ''); + } + + // Reopen proposal + else if ($action == 'confirm_reopen' && $user->rights->askpricesupplier->cloturer && ! GETPOST('cancel')) { + // prevent browser refresh from reopening proposal several times + if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) { + $object->reopen($user, 1); + } + } + + // Close proposal + else if ($action == 'setstatut' && $user->rights->askpricesupplier->cloturer && ! GETPOST('cancel')) { + if (! GETPOST('statut')) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); + $action = 'statut'; + } else { + // prevent browser refresh from closing proposal several times + if ($object->statut == 1) { + $object->cloture($user, GETPOST('statut'), GETPOST('note')); + } + } + } + + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + + /* + * Send mail + */ + + // Actions to send emails + $actiontypecode='AC_ASKPRICE'; + $trigger_name='ASKPRICESUPPLIER_SENTBYMAIL'; + $paramname='id'; + $mode='emailfromaskpricesupplier'; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + + + + // Go back to draft + if ($action == 'modif' && $user->rights->askpricesupplier->creer) + { + $object->set_draft($user); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + else if ($action == "setabsolutediscount" && $user->rights->askpricesupplier->creer) { + if ($_POST["remise_id"]) { + if ($object->id > 0) { + $result = $object->insert_discount($_POST["remise_id"]); + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } + } + } + } + + // Add line + else if ($action == 'addline' && $user->rights->askpricesupplier->creer) { + + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } + + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); + } + } + + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; + } + + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); + $error ++; + } + + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + $pu_ht = 0; + $pu_ttc = 0; + $price_min = 0; + $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); + + $db->begin(); + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + if (! empty($idprod)) { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + + // If prices fields are update + $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + + // On defini prix unitaire + if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) + { + $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; + $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result) { + if (count($prodcustprice->lines) > 0) { + $pu_ht = price($prodcustprice->lines [0]->price); + $pu_ttc = price($prodcustprice->lines [0]->price_ttc); + $price_base_type = $prodcustprice->lines [0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines [0]->tva_tx; + } + } + } + + // if price ht is forced (ie: calculated by margin rate and cost price) + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tva_tx != $prod->tva_tx) { + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + } + + $desc = ''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } else { + $desc = $prod->description; + } + + $desc = dol_concatdesc($desc, $product_desc); + + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + } + + $type = $prod->type; + } else { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); + + $date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessage($mesg, 'errors'); + } else { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_option); + + if ($result > 0) { + $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['prod_entry_mode']); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + } else { + $db->rollback(); + + setEventMessage($object->error, 'errors'); + } + } + } + } + + // Mise a jour d'une ligne dans la propale + else if ($action == 'updateligne' && $user->rights->askpricesupplier->creer && GETPOST('save') == $langs->trans("Save")) { + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', GETPOST('tva_tx'))) + $info_bits |= 0x01; + + // Clean parameters + $description = dol_htmlcleanlastbr(GETPOST('product_desc')); + + // Define vat_rate + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty); + $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty); + $pu_ht = GETPOST('price_ht'); + + // Add buying price + $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); + + $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); + } + } + + // Define special_code for special lines + $special_code=GETPOST('special_code'); + if (! GETPOST('qty')) $special_code=3; + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) { + $product = new Product($db); + $res = $product->fetch($productid); + + $type = $product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + $price_min = $product->multiprices_min [$object->thirdparty->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); + + if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + $error ++; + } + } else { + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; + } + } + + if (! $error) { + $db->begin(); + + $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_option); + + if ($result >= 0) { + $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + } else { + $db->rollback(); + + setEventMessage($object->error, 'errors'); + } + } + } + + else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + exit(); + } + + // Generation doc (depuis lien ou depuis cartouche doc) + else if ($action == 'builddoc' && $user->rights->askpricesupplier->creer) { + if (GETPOST('model')) { + $object->setDocModel($user, GETPOST('model')); + } + + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + if ($result <= 0) { + dol_print_error($db, $result); + exit(); + } else { + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); + exit(); + } + } + + // Remove file in doc form + else if ($action == 'remove_file' && $user->rights->askpricesupplier->creer) { + if ($object->id > 0) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $langs->load("other"); + $upload_dir = $conf->askpricesupplier->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) + setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + } + } + + // Set project + else if ($action == 'classin' && $user->rights->askpricesupplier->creer) { + $object->setProject($_POST['projectid']); + } + + // Delai de livraison + else if ($action == 'setavailability' && $user->rights->askpricesupplier->creer) { + $result = $object->availability($_POST['availability_id']); + } + + // Origine de la propale + else if ($action == 'setdemandreason' && $user->rights->askpricesupplier->creer) { + $result = $object->demand_reason($_POST['demand_reason_id']); + } + + // Conditions de reglement + else if ($action == 'setconditions' && $user->rights->askpricesupplier->creer) { + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + } + + else if ($action == 'setremisepercent' && $user->rights->askpricesupplier->creer) { + $result = $object->set_remise_percent($user, $_POST['remise_percent']); + } + + else if ($action == 'setremiseabsolue' && $user->rights->askpricesupplier->creer) { + $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); + } + + // Mode de reglement + else if ($action == 'setmode' && $user->rights->askpricesupplier->creer) { + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + } + + // bank account + else if ($action == 'setbankaccount' && $user->rights->askpricesupplier->creer) { + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + } + + // shipping method + else if ($action == 'setshippingmethod' && $user->rights->askpricesupplier->creer) { + $result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int')); + } + + /* + * Ordonnancement des lignes + */ + + else if ($action == 'up' && $user->rights->askpricesupplier->creer) { + $object->line_up(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); + exit(); + } + + else if ($action == 'down' && $user->rights->askpricesupplier->creer) { + $object->line_down(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); + exit(); + } else if ($action == 'update_extras') { + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) + $error ++; + + if (! $error) { + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('propaldao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been + // modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + } + + if ($error) + $action = 'edit_extras'; + } + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->askpricesupplier->creer) + { + if ($action == 'addcontact') + { + if ($object->id > 0) { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + } else { + setEventMessage($object->error, 'errors'); + } + } + } + + // Bascule du statut d'un contact + else if ($action == 'swapstatut') { + if ($object->fetch($id) > 0) { + $result = $object->swapContactStatus(GETPOST('ligne')); + } else { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact') { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + dol_print_error($db); + } + } + } +} + + +/* + * View + */ + +llxHeader('', $langs->trans('CommRequests'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); +$formpropal = new FormPropal($db); +$companystatic = new Societe($db); + +$now = dol_now(); + +// Add new proposal +if ($action == 'create') +{ + print_fiche_titre($langs->trans("NewAskPrice")); + + $soc = new Societe($db); + if ($socid > 0) + $res = $soc->fetch($socid); + + // Load objectsrc + if (! empty($origin) && ! empty($originid)) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { + $element = $regs [1]; + $subelement = $regs [2]; + } + + if ($element == 'project') { + $projectid = $originid; + } else { + // For compatibility + if ($element == 'order' || $element == 'commande') { + $element = $subelement = 'commande'; + } + if ($element == 'askpricesupplier') { + $element = 'comm/askpricesupplier'; + $subelement = 'askpricesupplier'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + if ($element == 'shipping') { + $element = $subelement = 'expedition'; + } + + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $objectsrc = new $classname($db); + $objectsrc->fetch($originid); + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) + { + $objectsrc->fetch_lines(); + } + $objectsrc->fetch_thirdparty(); + + $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); + $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + $ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); + + $soc = $objectsrc->thirdparty; + + $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + + // Replicate extrafields + $objectsrc->fetch_optionals($originid); + $object->array_options = $objectsrc->array_options; + } + } + + $object = new AskPriceSupplier($db); + + print '
'; + print ''; + print ''; + if ($origin != 'project' && $originid) { + print ''; + print ''; + } + + dol_fiche_head(); + + print ''; + + // Reference + print ''; + + // Ref customer + print ''; + print ''; + + // Third party + print ''; + print ''; + if ($socid > 0) { + print ''; + } else { + print ''; + } + print '' . "\n"; + + // Contacts (ask contact only if thirdparty already defined). TODO do this also into order and invoice. + if ($socid > 0) + { + print "'; + } + + if ($socid > 0) + { + // Ligne info remises tiers + print ''; + } + + // Date + print ''; + + // Validaty duration + print ''; + + // Terms of payment + print ''; + + // Mode of payment + print ''; + + // Bank Account + if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && $conf->banque->enabled) { + print ''; + } + + // What trigger creation + print ''; + + // Delivery delay + print ''; + + // Shipping Method + if (! empty($conf->expedition->enabled)) { + print ''; + } + + // Delivery date (or manufacturing) + print ''; + print ''; + + // Model + print ''; + print ''; + print '"; + + // Project + if (! empty($conf->projet->enabled) && $socid > 0) { + + $formproject = new FormProjets($db); + + $projectid = 0; + if ($origin == 'project') + $projectid = ($originid ? $originid : 0); + + print ''; + print ''; + print ''; + } + + // Other attributes + $parameters = array('colspan' => ' colspan="3"'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified + // by + // hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) { + print $object->showOptionals($extrafields, 'edit'); + } + + + // Lines from source + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + { + // TODO for compatibility + if ($origin == 'contrat') { + // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva + $objectsrc->remise_absolue = $remise_absolue; + $objectsrc->remise_percent = $remise_percent; + $objectsrc->update_price(1, - 1, 1); + } + + print "\n"; + print "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print ''; + print ''; + + $newclassname = $classname; + if ($newclassname == 'Askpricesupplier') + $newclassname = 'CommRequest'; + elseif ($newclassname == 'Commande') + $newclassname = 'Order'; + elseif ($newclassname == 'Expedition') + $newclassname = 'Sending'; + elseif ($newclassname == 'Fichinter') + $newclassname = 'Intervention'; + + print ''; + print ''; + print '"; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0 ) // Localtax1 + { + print '"; + } + + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 + { + print '"; + } + print '"; + } + + print "
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; + print '
' . $langs->trans('Customer') . ''; + print $soc->getNomUrl(1); + print ''; + print ''; + print $form->select_company('', 'socid', 's.client = 1 OR s.client = 2 OR s.client = 3', 1); + print '
" . $langs->trans("DefaultContact") . ''; + $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); + print '
' . $langs->trans('Discounts') . ''; + if ($soc->remise_percent) + print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); + else + print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount = $soc->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency" . $conf->currency)); + else + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
' . $langs->trans('Date') . ''; + $form->select_date('', '', '', '', '', "addask", 1, 1); + print '
' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . '
' . $langs->trans('PaymentConditionsShort') . ''; + $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id'); + print '
' . $langs->trans('PaymentMode') . ''; + $form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id'); + print '
' . $langs->trans('BankAccount') . ''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print '
' . $langs->trans('Source') . ''; + $form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1); + print '
' . $langs->trans('AvailabilityPeriod') . ''; + $form->selectAvailabilityDelay('', 'availability_id', '', 1); + print '
' . $langs->trans('SendingMethod') . ''; + print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); + print '
' . $langs->trans("DeliveryDate") . ''; + if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { + $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + $syear = date("Y", $tmpdte); + $smonth = date("m", $tmpdte); + $sday = date("d", $tmpdte); + $form->select_date($syear."-".$smonth."-".$sday, 'liv_', '', '', '', "addask"); + } else { + $form->select_date(-1, 'liv_', '', '', '', "addask", 1, 1); + } + print '
' . $langs->trans("DefaultModel") . ''; + $liste = ModelePDFAskPriceSupplier::liste_modeles($db); + print $form->selectarray('model', $liste, ($conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_DEFAULT ? $conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_DEFAULT : $conf->global->ASKPRICESUPPLIER_ADDON_PDF)); + print "
' . $langs->trans("Project") . ''; + + $numprojet = $formproject->select_projects($soc->id, $projectid); + if ($numprojet == 0) { + $langs->load("projects"); + print '   ' . $langs->trans("AddProject") . ''; + } + print '
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . '
' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . "
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . "
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
\n"; + + + /* + * Combobox pour la fonction de copie + */ + + if (empty($conf->global->ASKPRICESUPPLIER_CLONE_ON_CREATE_PAGE)) print ''; + + if (! empty($conf->global->ASKPRICESUPPLIER_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '
'; + if (! empty($conf->global->ASKPRICESUPPLIER_CLONE_ON_CREATE_PAGE)) + { + // For backward compatibility + print ''; + print ''; + print ''; + print ''; + + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) + print ''; + + print ''; + print ''; + } + + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) + { + print ''; + } + if (! empty($conf->global->ASKPRICESUPPLIER_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '
' . $langs->trans("CopyAskFrom") . ' '; + $liste_ask = array(); + $liste_ask [0] = ''; + + $sql = "SELECT p.rowid as id, p.ref, s.nom"; + $sql .= " FROM " . MAIN_DB_PREFIX . "askpricesupplier p"; + $sql .= ", " . MAIN_DB_PREFIX . "societe s"; + $sql .= " WHERE s.rowid = p.fk_soc"; + $sql .= " AND p.entity = " . $conf->entity; + $sql .= " AND p.fk_statut <> 0"; + $sql .= " ORDER BY Id"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $row = $db->fetch_row($resql); + $propalRefAndSocName = $row [1] . " - " . $row [2]; + $liste_ask [$row [0]] = $propalRefAndSocName; + $i ++; + } + print $form->selectarray("copie_askpricesupplier", $liste_ask, 0); + } else { + dol_print_error($db); + } + print '
 
' . $langs->trans("CreateEmptyAsk") . '
'; + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { + $lib = $langs->trans("ProductsAndServices"); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { + print ''; + print ''; + print ''; + print ''; + } + print "
' . $lib . '' . $langs->trans("Qty") . '' . $langs->trans("ReductionShort") . '
'; + // multiprix + if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) + $form->select_produits('', "idprod" . $i, '', $conf->product->limit_size, $soc->price_level); + else + $form->select_produits('', "idprod" . $i, '', $conf->product->limit_size); + print '%
"; + } + print '
'; + + dol_fiche_end(); + + $langs->load("bills"); + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print "
"; + + + // Show origin lines + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + print '
'; + + $title = $langs->trans('ProductsAndServices'); + print_titre($title); + + print ''; + + $objectsrc->printOriginLinesList(); + + print '
'; + } + +} else { + /* + * Show object in view mode + */ + + $soc = new Societe($db); + $soc->fetch($object->socid); + + $head = propal_prepare_head($object); + dol_fiche_head($head, 'comm', $langs->trans('CommRequest'), 0, 'CommRequest'); + + $formconfirm = ''; + + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => + // 1), + array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + // Paiement incomplet. On demande si motif = escompte ou autre + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneAsk'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirm delete + else if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteAsk'), $langs->trans('ConfirmDeleteAsk', $object->ref), 'confirm_delete', '', 0, 1); + } + + // Confirm reopen + else if ($action == 'reopen') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenAsk', $object->ref), 'confirm_reopen', '', 0, 1); + } + + // Confirmation delete product/service line + else if ($action == 'ask_deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + } + + // Confirm validate proposal + else if ($action == 'validate') { + $error = 0; + + // on verifie si l'objet est en numerotation provisoire + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') { + $numref = $object->getNextNumRef($soc); + if (empty($numref)) { + $error ++; + setEventMessage($object->error, 'errors'); + } + } else { + $numref = $object->ref; + } + + $text = $langs->trans('ConfirmValidateAsk', $numref); + if (! empty($conf->notification->enabled)) { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('ASKPRICESUPPLIER_VALIDATE', $object->socid); + } + + if (! $error) + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateAsk'), $text, 'confirm_validate', '', 0, 1); + } + + if (! $formconfirm) { + $parameters = array('lineid' => $lineid); + $formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified + // by + // hook + } + + // Print form confirm + print $formconfirm; + + print ''; + + $linkback = '' . $langs->trans("BackToList") . ''; + + // Ref + print ''; + + // Ref customer + print ''; + print ''; + + // Company + print ''; + print ''; + + // Ligne info remises tiers + print ''; + + // Date of proposal + print ''; + print ''; + + // Date end proposal + print ''; + print ''; + print ''; + + // Payment term + print ''; + print ''; + + // Delivery date + $langs->load('deliveries'); + print ''; + print ''; + + // Delivery delay + print ''; + print ''; + + // Shipping Method + if (! empty($conf->expedition->enabled)) { + print ''; + print ''; + } + + // Origin of demand + print ''; + print ''; + + // Payment mode + print ''; + print ''; + + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + print ''; + } else { + print '
' . $langs->trans('Ref') . ''; + print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); + print '
'; + print ''; + if ($action != 'refclient' && ! empty($object->brouillon)) + print ''; + print ''; + print '
'; + print $langs->trans('RefCustomer') . '' . img_edit($langs->trans('Modify')) . '
'; + print '
'; + if ($user->rights->askpricesupplier->creer && $action == 'refclient') { + print '
'; + print ''; + print ''; + print ''; + print ' '; + print '
'; + } else { + print $object->ref_client; + } + print '
' . $langs->trans('Company') . '' . $soc->getNomUrl(1) . '
' . $langs->trans('Discounts') . ''; + if ($soc->remise_percent) + print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); + else + print $langs->trans("CompanyHasNoRelativeDiscount"); + print '. '; + $absolute_discount = $soc->getAvailableDiscounts('', 'fk_facture_source IS NULL'); + $absolute_creditnote = $soc->getAvailableDiscounts('', 'fk_facture_source IS NOT NULL'); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); + if ($absolute_discount) { + if ($object->statut > 0) { + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount, 0, $langs, 0, 0, -1, $conf->currency)); + } else { + // Remise dispo de type non avoir + $filter = 'fk_facture_source IS NULL'; + print '
'; + $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filter); + } + } + if ($absolute_creditnote) { + print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote, 0, $langs, 0, 0, -1, $conf->currency)) . '. '; + } + if (! $absolute_discount && ! $absolute_creditnote) + print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.'; + print '
'; + print ''; + if ($action != 'editdate' && ! empty($object->brouillon)) + print ''; + print '
'; + print $langs->trans('Date'); + print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
'; + print '
'; + if (! empty($object->brouillon) && $action == 'editdate') { + print '
'; + print ''; + print ''; + $form->select_date($object->date, 're', '', '', 0, "editdate"); + print ''; + print '
'; + } else { + if ($object->date) { + print dol_print_date($object->date, 'daytext'); + } else { + print ' '; + } + } + print '
'; + print ''; + if ($action != 'editecheance' && ! empty($object->brouillon)) + print ''; + print '
'; + print $langs->trans('DateEndAsk'); + print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . '
'; + print '
'; + if (! empty($object->brouillon) && $action == 'editecheance') { + print '
'; + print ''; + print ''; + $form->select_date($object->fin_validite, 'ech', '', '', '', "editecheance"); + print ''; + print '
'; + } else { + if (! empty($object->fin_validite)) { + print dol_print_date($object->fin_validite, 'daytext'); + if ($object->statut == 1 && $object->fin_validite < ($now - $conf->askpricesupplier->cloture->warning_delay)) + print img_warning($langs->trans("Late")); + } else { + print ' '; + } + } + print '
'; + print ''; + if ($action != 'editconditions' && ! empty($object->brouillon)) + print ''; + print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetConditions'), 1) . '
'; + print '
'; + if ($action == 'editconditions') { + $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none'); + } + print '
'; + print ''; + if ($action != 'editdate_livraison' && ! empty($object->brouillon)) + print ''; + print '
'; + print $langs->trans('DeliveryDate'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'), 1) . '
'; + print '
'; + if ($action == 'editdate_livraison') { + print '
'; + print ''; + print ''; + $form->select_date($object->date_livraison, 'liv_', '', '', '', "editdate_livraison"); + print ''; + print '
'; + } else { + print dol_print_date($object->date_livraison, 'daytext'); + } + print '
'; + print ''; + if ($action != 'editavailability' && ! empty($object->brouillon)) + print ''; + print '
'; + print $langs->trans('AvailabilityPeriod'); + if (! empty($conf->commande->enabled)) + print ' (' . $langs->trans('AfterOrder') . ')'; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1) . '
'; + print '
'; + if ($action == 'editavailability') { + $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1); + } else { + $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1); + } + + print '
'; + print ''; + if ($action != 'editshippingmethod' && $user->rights->propal->creer) + print ''; + print '
'; + print $langs->trans('SendingMethod'); + print 'id.'">'.img_edit($langs->trans('SetShippingMode'),1).'
'; + print '
'; + if ($action == 'editshippingmethod') { + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); + } else { + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); + } + print '
'; + print ''; + if ($action != 'editdemandreason' && ! empty($object->brouillon)) + print ''; + print '
'; + print $langs->trans('Source'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1) . '
'; + print '
'; + if ($action == 'editdemandreason') { + $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1); + } else { + $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none'); + } + print '
'; + print ''; + if ($action != 'editmode' && ! empty($object->brouillon)) + print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMode'), 1) . '
'; + print '
'; + if ($action == 'editmode') { + $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id'); + } else { + $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); + } + print '
'; + print ''; + if ($user->rights->askpricesupplier->creer) { + if ($action != 'classify') + print ''; + print '
'; + print $langs->trans('Project') . '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '
'; + print '
'; + if ($action == 'classify') { + $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid'); + } else { + $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none'); + } + print '
'; + if (! empty($object->fk_project)) { + print ''; + $proj = new Project($db); + $proj->fetch($object->fk_project); + print ''; + print $proj->ref; + print ''; + print ''; + } else { + print ' '; + } + } + print ''; + } + + if ($soc->outstanding_limit) + { + // Outstanding Bill + print ''; + print $langs->trans('OutstandingBill'); + print ''; + print price($soc->get_OutstandingBill()) . ' / '; + print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); + print ''; + print ''; + } + + if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && $conf->banque->enabled) + { + // Bank Account + print ''; + print ''; + if ($action != 'editbankaccount' && $user->rights->propal->creer) + print ''; + print '
'; + print $langs->trans('BankAccount'); + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print ''; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ''; + print ''; + } + + // Other attributes + $cols = 3; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + // Amount HT + print '' . $langs->trans('AmountHT') . ''; + print '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''; + + // Margin Infos + if (! empty($conf->margin->enabled)) { + print ''; + $object->displayMarginInfos(); + print ''; + } + print ''; + + // Amount VAT + print '' . $langs->trans('AmountVAT') . ''; + print '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''; + + // Amount Local Taxes + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 + { + print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; + print '' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''; + } + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 + { + print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; + print '' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''; + } + + // Amount TTC + print '' . $langs->trans('AmountTTC') . ''; + print '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''; + + // Statut + print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; + + print '
'; + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + } + + /* + * Lines + */ + + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print ''; + + if (! empty($object->lines)) + $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + + // Form to add new line + if ($object->statut == 0 && $user->rights->propal->creer) + { + if ($action != 'editline') + { + $var = true; + + // Add products/services form + $object->formAddObjectLine(1, $mysoc, $soc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + print '
'; + + print "
\n"; + + dol_fiche_end(); + + if ($action == 'statut') + { + /* + * Form to close proposal (signed or not) + */ + $form_close = '
'; + $form_close .= ''; + $form_close .= ''; + $form_close .= ''; + $form_close .= ''; + $form_close .= ''; + $form_close .= '
' . $langs->trans("CloseAs") . ''; + $form_close .= ''; + $form_close .= ''; + $form_close .= '
' . $langs->trans('Note') . '
'; + $form_close .= ''; + $form_close .= '   '; + $form_close .= ' '; + $form_close .= '
'; + + print $form_close; + } + + /* + * Boutons Actions + */ + if ($action != 'presend') { + print '
'; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) + { + if ($action != 'statut' && $action != 'editline') + { + // Validate + if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->validate))) + ) { + if (count($object->lines) > 0) + print ''; + // else print ''.$langs->trans('Validate').''; + } + // Create event + if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + { + print '' . $langs->trans("AddAction") . ''; + } + // Edit + if ($object->statut == 1 && $user->rights->askpricesupplier->creer) { + print ''; + } + + // ReOpen + if (($object->statut == 2 || $object->statut == 3 || $object->statut == 4) && $user->rights->askpricesupplier->cloturer) { + print ''; + } + + // Send + if ($object->statut == 1 || $object->statut == 2) { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->askpricesupplier->propal_advance->send) { + print ''; + } else + print ''; + } + + // Create an order + if (! empty($conf->commande->enabled) && $object->statut == 2) { + if ($user->rights->commande->creer) { + print ''; + } + } + + // Create contract + if ($conf->contrat->enabled && $object->statut == 2) { + $langs->load("contracts"); + + if ($user->rights->contrat->creer) { + print ''; + } + } + + // Create an invoice and classify billed + if ($object->statut == 2) { + if (! empty($conf->facture->enabled) && $user->rights->facture->creer) + { + print ''; + } + + $arrayofinvoiceforpropal = $object->getInvoiceArrayList(); + if ((is_array($arrayofinvoiceforpropal) && count($arrayofinvoiceforpropal) > 0) || ! empty($conf->global->WORKFLOW_PROPAL_CAN_CLASSIFIED_BILLED_WITHOUT_INVOICES)) + { + print ''; + } + } + + // Close + if ($object->statut == 1 && $user->rights->askpricesupplier->cloturer) { + print ''; + } + + // Clone + if ($user->rights->askpricesupplier->creer) { + print ''; + } + + // Delete + if ($user->rights->askpricesupplier->supprimer) { + print ''; + } + } + } + + print '
'; + } + print "
\n"; + + if ($action != 'presend') + { + print '
'; + // print '
'; + // print ''; // ancre + + /* + * Documents generes + */ + $filename = dol_sanitizeFileName($object->ref); + $filedir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->askpricesupplier->creer; + $delallowed = $user->rights->askpricesupplier->supprimer; + + $var = true; + + $somethingshown = $formfile->show_documents('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + + /* + * Linked object block + */ + $somethingshown = $object->showLinkedObjectBlock(); + + print '
'; + // print '
'; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'propal', $socid); + + // print '
'; + print '
'; + } + + /* + * Action presend + */ + if ($action == 'presend') + { + $object->fetch_projet(); + + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/')); + $file = $fileparams ['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->thirdparty->default_lang; + + if (!empty($newlang)) + { + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->load('commercial'); + } + + // Build document if it not exists + if (! $file || ! is_readable($file)) { + $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { + dol_print_error($db, $result); + exit(); + } + $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/')); + $file = $fileparams ['fullname']; + } + + print '
'; + print_titre($langs->trans('SendAskByMail')); + + // Create form object + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom = 1; + $liste = array(); + foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) + $liste [$key] = $value; + $formmail->withto = GETPOST("sendto") ? GETPOST("sendto") : $liste; + $formmail->withtocc = $liste; + $formmail->withtoccc = (! empty($conf->global->MAIN_EMAIL_USECCC) ? $conf->global->MAIN_EMAIL_USECCC : false); + if (empty($object->ref_client)) { + $formmail->withtopic = $outputlangs->trans('SendAskRef', '__ASKREF__'); + } else if (! empty($object->ref_client)) { + $formmail->withtopic = $outputlangs->trans('SendAskRef', '__ASKREF__ (__REFCLIENT__)'); + } + $formmail->withfile = 2; + $formmail->withbody = 1; + $formmail->withdeliveryreceipt = 1; + $formmail->withcancel = 1; + + // Tableau des substitutions + $formmail->substit['__ASKREF__'] = $object->ref; + $formmail->substit['__SIGNATURE__'] = $user->signature; + $formmail->substit['__REFCLIENT__'] = $object->ref_client; + $formmail->substit['__THIRPARTY_NAME__'] = $object->thirdparty->name; + $formmail->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); + $formmail->substit['__PERSONALIZED__'] = ''; + $formmail->substit['__CONTACTCIVNAME__'] = ''; + + // Find the good contact adress + $custcontact = ''; + $contactarr = array(); + $contactarr = $object->liste_contact(- 1, 'external'); + + if (is_array($contactarr) && count($contactarr) > 0) { + foreach ($contactarr as $contact) { + if ($contact ['libelle'] == $langs->trans('TypeContact_askpricesupplier_external_CUSTOMER')) { // TODO Use code and not label + $contactstatic = new Contact($db); + $contactstatic->fetch($contact ['id']); + $custcontact = $contactstatic->getFullName($langs, 1); + } + } + + if (! empty($custcontact)) { + $formmail->substit['__CONTACTCIVNAME__'] = $custcontact; + } + } + + // Tableau des parametres complementaires + $formmail->param['action'] = 'send'; + $formmail->param['models'] = 'propal_send'; + $formmail->param['id'] = $object->id; + $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; + // Init list of files + if (GETPOST("mode") == 'init') { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file, basename($file), dol_mimetype($file)); + } + + print $formmail->get_form(); + + print '
'; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php index f68a1f4f708..b2c7fc4dfb2 100644 --- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php +++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php @@ -37,14 +37,14 @@ require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php'; /** - * Class to manage proposals + * Class to manage price ask supplier */ -class Propal extends CommonObject +class AskPriceSupplier extends CommonObject { - public $element='propal'; - public $table_element='propal'; - public $table_element_line='propaldet'; - public $fk_element='fk_propal'; + public $element='askpricesupplier'; + public $table_element='askpricesupplier'; + public $table_element_line='askpricesupplierdet'; + public $fk_element='fk_askpricesupplier'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** @@ -128,33 +128,33 @@ class Propal extends CommonObject * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param int $propalid Id proposal + * @param int $askpricesupplierid Id askpricesupplier */ - function __construct($db, $socid="", $propalid=0) + function __construct($db, $socid="", $askpricesupplierid=0) { global $conf,$langs; $this->db = $db; $this->socid = $socid; - $this->id = $propalid; + $this->id = $askpricesupplierid; $this->products = array(); $this->remise = 0; $this->remise_percent = 0; $this->remise_absolue = 0; - $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; + $this->duree_validite=$conf->global->ASKPRICESUPPLIER_VALIDITY_DURATION; - $langs->load("propal"); - $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); - $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); - $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); - $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); - $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); - $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); - $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); - $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); - $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); - $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); + $langs->load("askpricesupplier"); + $this->labelstatut[0]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_DRAFT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_DRAFT_LABEL : $langs->trans("AskpricesupplierStatusDraft")); + $this->labelstatut[1]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_VALIDATED_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_VALIDATED_LABEL : $langs->trans("AskpricesupplierStatusValidated")); + $this->labelstatut[2]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_SIGNED_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_SIGNED_LABEL : $langs->trans("AskpricesupplierStatusSigned")); + $this->labelstatut[3]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_NOTSIGNED_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_NOTSIGNED_LABEL : $langs->trans("AskpricesupplierStatusNotSigned")); + $this->labelstatut[4]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_BILLED_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_BILLED_LABEL : $langs->trans("AskpricesupplierStatusBilled")); + $this->labelstatut_short[0]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_DRAFTSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_DRAFTSHORT_LABEL : $langs->trans("AskpricesupplierStatusDraftShort")); + $this->labelstatut_short[1]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); + $this->labelstatut_short[2]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_SIGNEDSHORT_LABEL : $langs->trans("AskpricesupplierStatusSignedShort")); + $this->labelstatut_short[3]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("AskpricesupplierStatusNotSignedShort")); + $this->labelstatut_short[4]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_BILLEDSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_BILLEDSHORT_LABEL : $langs->trans("AskpricesupplierStatusBilledShort")); } @@ -199,7 +199,7 @@ class Propal extends CommonObject $price = $prod->price; } - $line = new PropaleLigne($this->db); + $line = new AskPriceSupplierLigne($this->db); $line->fk_product=$idproduct; $line->desc=$productdesc; @@ -239,8 +239,8 @@ class Propal extends CommonObject return -5; } - $propalligne=new PropaleLigne($this->db); - $propalligne->fk_propal=$this->id; + $propalligne=new AskPriceSupplierLigne($this->db); + $propalligne->fk_askpricesupplier=$this->id; $propalligne->fk_remise_except=$remise->id; $propalligne->desc=$remise->description; // Description ligne $propalligne->tva_tx=$remise->tva_tx; @@ -324,7 +324,7 @@ class Propal extends CommonObject { global $mysoc; - dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); + dol_syslog(get_class($this)."::addline askpricesupplierid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -391,9 +391,9 @@ class Propal extends CommonObject } // Insert line - $this->line=new PropaleLigne($this->db); + $this->line=new AskPriceSupplierLigne($this->db); - $this->line->fk_propal=$this->id; + $this->line->fk_askpricesupplier=$this->id; $this->line->label=$label; $this->line->desc=$desc; $this->line->qty=$qty; @@ -543,10 +543,10 @@ class Propal extends CommonObject } // Update line - $this->line=new PropaleLigne($this->db); + $this->line=new AskPriceSupplierLigne($this->db); // Stock previous line records - $staticline=new PropaleLigne($this->db); + $staticline=new AskPriceSupplierLigne($this->db); $staticline->fetch($rowid); $this->line->oldline = $staticline; @@ -610,7 +610,7 @@ class Propal extends CommonObject $this->update_price(1); - $this->fk_propal = $this->id; + $this->fk_askpricesupplier = $this->id; $this->rowid = $rowid; $this->db->commit(); @@ -625,7 +625,7 @@ class Propal extends CommonObject } else { - dol_syslog(get_class($this)."::updateline Erreur -2 Propal en mode incompatible pour cette action"); + dol_syslog(get_class($this)."::updateline Erreur -2 Askpricesupplier en mode incompatible pour cette action"); return -2; } } @@ -641,7 +641,7 @@ class Propal extends CommonObject { if ($this->statut == 0) { - $line=new PropaleLigne($this->db); + $line=new AskPriceSupplierLigne($this->db); // For triggers $line->fetch($lineid); @@ -720,7 +720,7 @@ class Propal extends CommonObject $this->db->begin(); // Insert into database - $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."askpricesupplier ("; $sql.= "fk_soc"; $sql.= ", price"; $sql.= ", remise"; @@ -779,12 +779,12 @@ class Propal extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."askpricesupplier"); if ($this->id) { $this->ref='(PROV'.$this->id.')'; - $sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->ref."' WHERE rowid=".$this->id; + $sql = 'UPDATE '.MAIN_DB_PREFIX."askpricesupplier SET ref='".$this->ref."' WHERE rowid=".$this->id; dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); @@ -853,7 +853,7 @@ class Propal extends CommonObject // Set delivery address if (! $error && $this->fk_delivery_address) { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier"; $sql.= " SET fk_delivery_address = ".$this->fk_delivery_address; $sql.= " WHERE ref = '".$this->ref."'"; $sql.= " AND entity = ".$conf->entity; @@ -890,7 +890,7 @@ class Propal extends CommonObject if (! $notrigger) { // Call trigger - $result=$this->call_trigger('PROPAL_CREATE',$user); + $result=$this->call_trigger('ASKPRICESUPPLIER_CREATE',$user); if ($result < 0) { $error++; } // End call triggers } @@ -992,7 +992,7 @@ class Propal extends CommonObject $this->id=0; $this->statut=0; - if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) + if (empty($conf->global->ASKPRICESUPPLIER_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/askpricesupplier/".$conf->global->ASKPRICESUPPLIER_ADDON.".php")) { $this->error='ErrorSetupNotComplete'; return -1; @@ -1007,10 +1007,10 @@ class Propal extends CommonObject if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = ''; // Set ref - require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php'; - $obj = $conf->global->PROPALE_ADDON; - $modPropale = new $obj; - $this->ref = $modPropale->getNextValue($objsoc,$this); + require_once DOL_DOCUMENT_ROOT ."/core/modules/askpricesupplier/".$conf->global->ASKPRICESUPPLIER_ADDON.'.php'; + $obj = $conf->global->ASKPRICESUPPLIER_ADDON; + $modAskPriceSupplier = new $obj; + $this->ref = $modAskPriceSupplier->getNextValue($objsoc,$this); // Create clone $result=$this->create($user); @@ -1041,7 +1041,7 @@ class Propal extends CommonObject } // Call trigger - $result=$this->call_trigger('PROPAL_CLONE',$user); + $result=$this->call_trigger('ASKPRICESUPPLIER_CLONE',$user); if ($result < 0) { $error++; } // End call triggers } @@ -1184,13 +1184,13 @@ class Propal extends CommonObject /* * Lignes propales liees a un produit ou non */ - $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql = "SELECT d.rowid, d.fk_askpricesupplier, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; $sql.= ' d.date_start, d.date_end'; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; + $sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplierdet as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; - $sql.= " WHERE d.fk_propal = ".$this->id; + $sql.= " WHERE d.fk_askpricesupplier = ".$this->id; $sql.= " ORDER by d.rang"; $result = $this->db->query($sql); @@ -1203,10 +1203,10 @@ class Propal extends CommonObject { $objp = $this->db->fetch_object($result); - $line = new PropaleLigne($this->db); + $line = new AskPriceSupplierLigne($this->db); $line->rowid = $objp->rowid; - $line->fk_propal = $objp->fk_propal; + $line->fk_askpricesupplier = $objp->fk_askpricesupplier; $line->fk_parent_line = $objp->fk_parent_line; $line->product_type = $objp->product_type; $line->label = $objp->custom_label; @@ -1334,8 +1334,8 @@ class Propal extends CommonObject $error=0; $now=dol_now(); - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate))) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->propal_advance->validate))) { $this->db->begin(); @@ -1354,7 +1354,7 @@ class Propal extends CommonObject } $this->newref = $num; - $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier"; $sql.= " SET ref = '".$num."',"; $sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; @@ -1371,7 +1371,7 @@ class Propal extends CommonObject if (! $error && ! $notrigger) { // Call trigger - $result=$this->call_trigger('PROPAL_VALIDATE',$user); + $result=$this->call_trigger('ASKPRICESUPPLIER_VALIDATE',$user); if ($result < 0) { $error++; } // End call triggers } @@ -1387,8 +1387,8 @@ class Propal extends CommonObject // to not lose the linked files $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->propal->dir_output.'/'.$oldref; - $dirdest = $conf->propal->dir_output.'/'.$newref; + $dirsource = $conf->askpricesupplier->dir_output.'/'.$oldref; + $dirdest = $conf->askpricesupplier->dir_output.'/'.$newref; if (file_exists($dirsource)) { @@ -1397,7 +1397,7 @@ class Propal extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->propal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + $listoffiles=dol_dir_list($conf->askpricesupplier->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); foreach($listoffiles as $fileentry) { $dirsource=$fileentry['name']; @@ -1444,9 +1444,9 @@ class Propal extends CommonObject return -1; } - if (! empty($user->rights->propal->creer)) + if (! empty($user->rights->askpricesupplier->creer)) { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier SET datep = '".$this->db->idate($date)."'"; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; dol_syslog(get_class($this)."::set_date", LOG_DEBUG); @@ -1475,7 +1475,7 @@ class Propal extends CommonObject { if (! empty($user->rights->propal->creer)) { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null'); + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null'); $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql) ) { @@ -1501,7 +1501,7 @@ class Propal extends CommonObject { if (! empty($user->rights->propal->creer)) { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier "; $sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null'); $sql.= " WHERE rowid = ".$this->id; @@ -1530,7 +1530,7 @@ class Propal extends CommonObject { if (! empty($user->rights->propal->creer)) { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier "; $sql.= " SET fk_availability = '".$id."'"; $sql.= " WHERE rowid = ".$this->id; @@ -1559,7 +1559,7 @@ class Propal extends CommonObject { if (! empty($user->rights->propal->creer)) { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier "; $sql.= " SET fk_input_reason = '".$id."'"; $sql.= " WHERE rowid = ".$this->id; @@ -1586,11 +1586,11 @@ class Propal extends CommonObject */ function set_ref_client($user, $ref_client) { - if (! empty($user->rights->propal->creer)) + if (! empty($user->rights->askpricesupplier->creer)) { - dol_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); + dol_syslog('AskPriceSupplier::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'askpricesupplier SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); $sql.= ' WHERE rowid = '.$this->id; if ($this->db->query($sql) ) { @@ -1600,7 +1600,7 @@ class Propal extends CommonObject else { $this->error=$this->db->error(); - dol_syslog('Propale::set_ref_client Erreur '.$this->error.' - '.$sql); + dol_syslog('AskPriceSupplier::set_ref_client Erreur '.$this->error.' - '.$sql); return -2; } } @@ -1625,7 +1625,7 @@ class Propal extends CommonObject { $remise = price2num($remise); - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier SET remise_percent = ".$remise; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; if ($this->db->query($sql) ) @@ -1658,7 +1658,7 @@ class Propal extends CommonObject { $remise = price2num($remise); - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier "; $sql.= " SET remise_absolue = ".$remise; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; @@ -1694,7 +1694,7 @@ class Propal extends CommonObject $this->statut = $statut; $error=0; - $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier"; $sql.= " SET fk_statut = ".$this->statut.","; if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; $sql.= " date_cloture=NULL, fk_user_cloture=NULL"; @@ -1712,7 +1712,7 @@ class Propal extends CommonObject if (! $notrigger) { // Call trigger - $result=$this->call_trigger('PROPAL_REOPEN',$user); + $result=$this->call_trigger('ASKPRICESUPPLIER_REOPEN',$user); if ($result < 0) { $error++; } // End call triggers } @@ -1758,20 +1758,20 @@ class Propal extends CommonObject $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier"; $sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id; $sql.= " WHERE rowid = ".$this->id; $resql=$this->db->query($sql); if ($resql) { - $modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf; - $trigger_name='PROPAL_CLOSE_REFUSED'; + $modelpdf=$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED?$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED:$this->modelpdf; + $trigger_name='ASKPRICESUPPLIER_CLOSE_REFUSED'; if ($statut == 2) { - $trigger_name='PROPAL_CLOSE_SIGNED'; - $modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf; + $trigger_name='ASKPRICESUPPLIER_CLOSE_SIGNED'; + $modelpdf=$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL?$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL:$this->modelpdf; // The connected company is classified as a client $soc=new Societe($this->db); @@ -1787,7 +1787,7 @@ class Propal extends CommonObject } if ($statut == 4) { - $trigger_name='PROPAL_CLASSIFY_BILLED'; + $trigger_name='ASKPRICESUPPLIER_CLASSIFY_BILLED'; } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -1835,7 +1835,7 @@ class Propal extends CommonObject */ function classifyBilled() { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = 4'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'askpricesupplier SET fk_statut = 4'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; if ($this->db->query($sql) ) { @@ -1869,7 +1869,7 @@ class Propal extends CommonObject { global $conf,$langs; - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0"; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier SET fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) @@ -1908,7 +1908,7 @@ class Propal extends CommonObject $sql.= " p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; $sql.= " p.datep as dp, p.fin_validite as datelimite"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."askpricesupplier as p, ".MAIN_DB_PREFIX."c_propalst as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.entity = ".$conf->entity; $sql.= " AND p.fk_soc = s.rowid"; @@ -1944,7 +1944,7 @@ class Propal extends CommonObject } else { - $ga[$i]['id'] = $obj->propalid; + $ga[$i]['id'] = $obj->askpricesupplierid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; } @@ -2075,17 +2075,17 @@ class Propal extends CommonObject if (! $notrigger) { // Call trigger - $result=$this->call_trigger('PROPAL_DELETE',$user); + $result=$this->call_trigger('ASKPRICESUPPLIER_DELETE',$user); if ($result < 0) { $error++; } // End call triggers } if (! $error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."askpricesupplierdet WHERE fk_askpricesupplier = ".$this->id; if ($this->db->query($sql)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."askpricesupplier WHERE rowid = ".$this->id; if ($this->db->query($sql)) { // Delete linked object @@ -2187,10 +2187,10 @@ class Propal extends CommonObject */ function availability($availability_id) { - dol_syslog('Propale::availability('.$availability_id.')'); + dol_syslog('AskPriceSupplier::availability('.$availability_id.')'); if ($this->statut >= 0) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'askpricesupplier'; $sql .= ' SET fk_availability = '.$availability_id; $sql .= ' WHERE rowid='.$this->id; if ( $this->db->query($sql) ) @@ -2200,14 +2200,14 @@ class Propal extends CommonObject } else { - dol_syslog('Propale::availability Erreur '.$sql.' - '.$this->db->error()); + dol_syslog('AskPriceSupplier::availability Erreur '.$sql.' - '.$this->db->error()); $this->error=$this->db->error(); return -1; } } else { - dol_syslog('Propale::availability, etat propale incompatible'); + dol_syslog('AskPriceSupplier::availability, etat propale incompatible'); $this->error='Etat propale incompatible '.$this->statut; return -2; } @@ -2221,10 +2221,10 @@ class Propal extends CommonObject */ function demand_reason($demand_reason_id) { - dol_syslog('Propale::demand_reason('.$demand_reason_id.')'); + dol_syslog('AskPriceSupplier::demand_reason('.$demand_reason_id.')'); if ($this->statut >= 0) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'askpricesupplier'; $sql .= ' SET fk_input_reason = '.$demand_reason_id; $sql .= ' WHERE rowid='.$this->id; if ( $this->db->query($sql) ) @@ -2234,14 +2234,14 @@ class Propal extends CommonObject } else { - dol_syslog('Propale::demand_reason Erreur '.$sql.' - '.$this->db->error()); + dol_syslog('AskPriceSupplier::demand_reason Erreur '.$sql.' - '.$this->db->error()); $this->error=$this->db->error(); return -1; } } else { - dol_syslog('Propale::demand_reason, etat propale incompatible'); + dol_syslog('AskPriceSupplier::demand_reason, etat propale incompatible'); $this->error='Etat propale incompatible '.$this->statut; return -2; } @@ -2259,7 +2259,7 @@ class Propal extends CommonObject $sql = "SELECT c.rowid, "; $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; + $sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as c"; $sql.= " WHERE c.rowid = ".$id; $result = $this->db->query($sql); @@ -2327,7 +2327,7 @@ class Propal extends CommonObject function LibStatut($statut,$mode=1) { global $langs; - $langs->load("propal"); + $langs->load("askpricesupplier"); if ($statut==0) $statuttrans='statut0'; if ($statut==1) $statuttrans='statut1'; @@ -2361,7 +2361,7 @@ class Propal extends CommonObject $clause = " WHERE"; $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; @@ -2376,8 +2376,8 @@ class Propal extends CommonObject $resql=$this->db->query($sql); if ($resql) { - if ($mode == 'opened') $delay_warning=$conf->propal->cloture->warning_delay; - if ($mode == 'signed') $delay_warning=$conf->propal->facturation->warning_delay; + if ($mode == 'opened') $delay_warning=$conf->askpricesupplier->cloture->warning_delay; + if ($mode == 'signed') $delay_warning=$conf->askpricesupplier->facturation->warning_delay; // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) @@ -2456,7 +2456,7 @@ class Propal extends CommonObject $xnbp = 0; while ($xnbp < $nbp) { - $line=new PropaleLigne($this->db); + $line=new AskPriceSupplierLigne($this->db); $line->desc=$langs->trans("Description")." ".$xnbp; $line->qty=1; $line->subprice=100; @@ -2505,7 +2505,7 @@ class Propal extends CommonObject $clause = "WHERE"; $sql = "SELECT count(p.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->societe_id) { @@ -2545,20 +2545,20 @@ class Propal extends CommonObject function getNextNumRef($soc) { global $conf, $db, $langs; - $langs->load("propal"); + $langs->load("askpricesupplier"); - if (! empty($conf->global->PROPALE_ADDON)) + if (! empty($conf->global->ASKPRICESUPPLIER_ADDON)) { $mybool=false; - $file = $conf->global->PROPALE_ADDON.".php"; - $classname = $conf->global->PROPALE_ADDON; + $file = $conf->global->ASKPRICESUPPLIER_ADDON.".php"; + $classname = $conf->global->ASKPRICESUPPLIER_ADDON; // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/propale/"); + $dir = dol_buildpath($reldir."core/modules/askpricesupplier/"); // Load file with numbering class (if found) $mybool|=@include_once $dir.$file; @@ -2606,25 +2606,25 @@ class Propal extends CommonObject global $langs; $result=''; - $label=$langs->trans("ShowPropal").': '.$this->ref; + $label=$langs->trans("ShowAskpricesupplier").': '.$this->ref; if (! empty($this->ref_client)) $label.= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; if ($option == '') { - $lien = 'load("askpricesupplier"); // Positionne le modele sur le nom du modele a utiliser if (! dol_strlen($modele)) { - if (! empty($conf->global->PROPALE_ADDON_PDF)) + if (! empty($conf->global->ASKPRICESUPPLIER_ADDON_PDF)) { - $modele = $conf->global->PROPALE_ADDON_PDF; + $modele = $conf->global->ASKPRICESUPPLIER_ADDON_PDF; } else { @@ -2737,7 +2737,7 @@ class Propal extends CommonObject } } - $modelpath = "core/modules/propale/doc/"; + $modelpath = "core/modules/askpricesupplier/doc/"; return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } @@ -2747,22 +2747,22 @@ class Propal extends CommonObject /** - * \class PropaleLigne - * \brief Class to manage commercial proposal lines + * \class AskPriceSupplierLigne + * \brief Class to manage price ask supplier lines */ -class PropaleLigne extends CommonObject +class AskPriceSupplierLigne extends CommonObject { var $db; var $error; - public $element='propaldet'; - public $table_element='propaldet'; + public $element='askpricesupplierdet'; + public $table_element='askpricesupplierdet'; var $oldline; // From llx_propaldet var $rowid; - var $fk_propal; + var $fk_askpricesupplier; var $fk_parent_line; var $desc; // Description ligne var $fk_product; // Id produit predefini @@ -2833,13 +2833,13 @@ class PropaleLigne extends CommonObject */ function fetch($rowid) { - $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql = 'SELECT pd.rowid, pd.fk_askpricesupplier, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; $sql.= ' pd.date_start, pd.date_end, pd.product_type'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'askpricesupplierdet as pd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; $sql.= ' WHERE pd.rowid = '.$rowid; @@ -2849,7 +2849,7 @@ class PropaleLigne extends CommonObject $objp = $this->db->fetch_object($result); $this->rowid = $objp->rowid; - $this->fk_propal = $objp->fk_propal; + $this->fk_askpricesupplier = $objp->fk_askpricesupplier; $this->fk_parent_line = $objp->fk_parent_line; $this->label = $objp->custom_label; $this->desc = $objp->description; @@ -2939,14 +2939,14 @@ class PropaleLigne extends CommonObject $this->db->begin(); // Insert line into database - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet'; - $sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type,'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'askpricesupplierdet'; + $sql.= ' (fk_askpricesupplier, fk_parent_line, label, description, fk_product, product_type,'; $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; $sql.= ' date_start, date_end)'; - $sql.= " VALUES (".$this->fk_propal.","; + $sql.= " VALUES (".$this->fk_askpricesupplier.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " '".$this->db->escape($this->desc)."',"; @@ -2979,7 +2979,7 @@ class PropaleLigne extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet'); + $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'askpricesupplierdet'); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -2994,7 +2994,7 @@ class PropaleLigne extends CommonObject if (! $notrigger) { // Call trigger - $result=$this->call_trigger('LINEPROPAL_INSERT',$user); + $result=$this->call_trigger('LINEASKPRICESUPPLIER_INSERT',$user); if ($result < 0) { $this->db->rollback(); @@ -3026,8 +3026,8 @@ class PropaleLigne extends CommonObject $error=0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid; - dol_syslog("PropaleLigne::delete", LOG_DEBUG); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."askpricesupplierdet WHERE rowid = ".$this->rowid; + dol_syslog("AskPriceSupplierLigne::delete", LOG_DEBUG); if ($this->db->query($sql) ) { @@ -3044,7 +3044,7 @@ class PropaleLigne extends CommonObject } // Call trigger - $result=$this->call_trigger('LINEPROPAL_DELETE',$user); + $result=$this->call_trigger('LINEASKPRICESUPLLIER_DELETE',$user); if ($result < 0) { $this->db->rollback(); @@ -3105,7 +3105,7 @@ class PropaleLigne extends CommonObject $this->db->begin(); // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplierdet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); $sql.= " , product_type=".$this->product_type; @@ -3154,7 +3154,7 @@ class PropaleLigne extends CommonObject if (! $notrigger) { // Call trigger - $result=$this->call_trigger('LINEPROPAL_UPDATE',$user); + $result=$this->call_trigger('LINEASKPRICESUPPLIER_UPDATE',$user); if ($result < 0) { $this->db->rollback(); @@ -3185,13 +3185,13 @@ class PropaleLigne extends CommonObject $this->db->begin(); // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplierdet SET"; $sql.= " total_ht=".price2num($this->total_ht,'MT').""; $sql.= ",total_tva=".price2num($this->total_tva,'MT').""; $sql.= ",total_ttc=".price2num($this->total_ttc,'MT').""; $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog("PropaleLigne::update_total", LOG_DEBUG); + dol_syslog("AskPriceSupplierLigne::update_total", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/comm/askpricesupplier/index.php b/htdocs/comm/askpricesupplier/index.php index a0e8a3409ab..dcd3436bd25 100644 --- a/htdocs/comm/askpricesupplier/index.php +++ b/htdocs/comm/askpricesupplier/index.php @@ -25,9 +25,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT .'/comm/askpricesupplier/class/askpricesupplier.class.php'; -$langs->load("propal"); +$langs->load("askpricesupplier"); $langs->load("companies"); // Security check @@ -37,22 +37,22 @@ if (isset($user->societe_id) && $user->societe_id > 0) $action = ''; $socid = $user->societe_id; } -$result = restrictedArea($user, 'propal'); +$result = restrictedArea($user, 'askpricesupplier'); /* * View */ $now=dol_now(); -$propalstatic=new Propal($db); +$askpricesupplierstatic=new AskPriceSupplier($db); $companystatic=new Societe($db); $form = new Form($db); $formfile = new FormFile($db); $help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos"; -llxHeader("",$langs->trans("ProspectionArea"),$help_url); +llxHeader("",$langs->trans("AskPriceSupplierArea"),$help_url); -print_fiche_titre($langs->trans("ProspectionArea")); +print_fiche_titre($langs->trans("AskPriceSupplierArea")); //print ''; //print ''; print '
'; @@ -64,9 +64,9 @@ print '
'; */ $var=false; print ''; -print ''; +print ''; print ''; -print ''; +print ''; print ''; print ''; @@ -80,7 +80,7 @@ print "
'.$langs->trans("SearchPropal").'
'.$langs->trans("SearchRequest").'
'; print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; $sql = "SELECT count(p.rowid), p.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."propal as p"; +$sql.= ", ".MAIN_DB_PREFIX."askpricesupplier as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.entity = ".$conf->entity; @@ -116,17 +116,17 @@ if ($resql) $db->free($resql); print ''; - print ''."\n"; + print ''."\n"; $var=true; $listofstatus=array(0,1,2,3,4); foreach ($listofstatus as $status) { - $dataseries[]=array('label'=>$propalstatic->LibStatut($status,1),'data'=>(isset($vals[$status])?(int) $vals[$status]:0)); + $dataseries[]=array('label'=>$askpricesupplierstatic->LibStatut($status,1),'data'=>(isset($vals[$status])?(int) $vals[$status]:0)); if (! $conf->use_javascript_ajax) { $var=!$var; print ""; - print ''; + print ''; print ''; print "\n"; } @@ -155,7 +155,7 @@ else if (! empty($conf->propal->enabled)) { $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; + $sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; @@ -169,8 +169,8 @@ if (! empty($conf->propal->enabled)) { print '
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$langs->trans("Statistics").' - '.$langs->trans("CommRequests").'
'.$propalstatic->LibStatut($status,0).''.$askpricesupplierstatic->LibStatut($status,0).''.(isset($vals[$status])?$vals[$status]:0).'
'; print ''; - print ''; - $langs->load("propal"); + print ''; + $langs->load("askpricesupplier"); $num = $db->num_rows($resql); if ($num) { @@ -182,9 +182,9 @@ if (! empty($conf->propal->enabled)) $obj = $db->fetch_object($resql); print ""; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; - print ''; + $askpricesupplierstatic->id=$obj->rowid; + $askpricesupplierstatic->ref=$obj->ref; + print ''; $companystatic->id=$obj->socid; $companystatic->name=$obj->socname; @@ -213,7 +213,7 @@ $max=5; $sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,"; $sql.= " date_cloture as datec"; -$sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; +$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; @@ -229,7 +229,7 @@ if ($resql) { print '
'.$langs->trans("DraftPropals").'
'.$langs->trans("DraftRequests").'
'.$propalstatic->getNomUrl(1).''.$askpricesupplierstatic->getNomUrl(1).'
'; print ''; - print ''; + print ''; $num = $db->num_rows($resql); if ($num) @@ -244,12 +244,12 @@ if ($resql) print ""; print ''; @@ -272,7 +272,7 @@ if ($resql) print ''; print ''; - print ''; + print ''; print ''; $i++; } @@ -285,15 +285,15 @@ else dol_print_error($db); /* * Opened proposals */ -if (! empty($conf->propal->enabled) && $user->rights->propale->lire) +if (! empty($conf->askpricesupplier->enabled) && $user->rights->askpricesupplier->lire) { - $langs->load("propal"); + $langs->load("askpricesupplier"); $now=dol_now(); $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; + $sql.= ", ".MAIN_DB_PREFIX."askpricesupplier as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.entity = ".$conf->entity; @@ -313,7 +313,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $var=true; print '
'.$langs->trans("LastModifiedProposals",$max).'
'.$langs->trans("LastModifiedRequests",$max).'
'; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; + $askpricesupplierstatic->id=$obj->rowid; + $askpricesupplierstatic->ref=$obj->ref; print ''; print ''; print '
'; - print $propalstatic->getNomUrl(1); + print $askpricesupplierstatic->getNomUrl(1); print ''; @@ -260,7 +260,7 @@ if ($resql) $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); + print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir); print '
'; print '
'.$companystatic->getNomUrl(1,'customer').''.dol_print_date($db->jdate($obj->datec),'day').''.$propalstatic->LibStatut($obj->fk_statut,5).''.$askpricesupplierstatic->LibStatut($obj->fk_statut,5).'
'; - print ''; + print ''; $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); while ($i < $nbofloop) @@ -325,21 +325,21 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) // Ref print '"; @@ -353,7 +353,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) print ''."\n"; print ''; - print ''."\n"; + print ''."\n"; print ''."\n"; $i++; $total += $obj->total_ttc; @@ -412,12 +412,12 @@ if (! empty($conf->propal->enabled)) print ""; print ''; print ''; - print ''; + print ''; print ''; $i++; @@ -484,12 +484,12 @@ if (! empty($conf->propal->enabled)) print ""; print ''; print ''; - print ''; + print ''; print ''; $i++; diff --git a/htdocs/comm/askpricesupplier/sql/llx_askpricesupplier.sql b/htdocs/comm/askpricesupplier/sql/llx_askpricesupplier.sql new file mode 100644 index 00000000000..93389cd5770 --- /dev/null +++ b/htdocs/comm/askpricesupplier/sql/llx_askpricesupplier.sql @@ -0,0 +1,58 @@ +CREATE TABLE `llx_askpricesupplier` ( + `rowid` int(11) NOT NULL AUTO_INCREMENT, + `ref` varchar(30) NOT NULL, + `entity` int(11) NOT NULL DEFAULT '1', + `ref_ext` varchar(255) DEFAULT NULL, + `ref_int` varchar(255) DEFAULT NULL, + `ref_client` varchar(255) DEFAULT NULL, + `fk_soc` int(11) DEFAULT NULL, + `fk_projet` int(11) DEFAULT NULL, + `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `datec` datetime DEFAULT NULL, + `datep` date DEFAULT NULL, + `fin_validite` datetime DEFAULT NULL, + `date_valid` datetime DEFAULT NULL, + `date_cloture` datetime DEFAULT NULL, + `fk_user_author` int(11) DEFAULT NULL, + `fk_user_modif` int(11) DEFAULT NULL, + `fk_user_valid` int(11) DEFAULT NULL, + `fk_user_cloture` int(11) DEFAULT NULL, + `fk_statut` smallint(6) NOT NULL DEFAULT '0', + `price` double DEFAULT '0', + `remise_percent` double DEFAULT '0', + `remise_absolue` double DEFAULT '0', + `remise` double DEFAULT '0', + `total_ht` double(24,8) DEFAULT '0.00000000', + `tva` double(24,8) DEFAULT '0.00000000', + `localtax1` double(24,8) DEFAULT '0.00000000', + `localtax2` double(24,8) DEFAULT '0.00000000', + `total` double(24,8) DEFAULT '0.00000000', + `fk_account` int(11) DEFAULT NULL, + `fk_currency` varchar(3) DEFAULT NULL, + `fk_cond_reglement` int(11) DEFAULT NULL, + `fk_mode_reglement` int(11) DEFAULT NULL, + `note_private` text, + `note_public` text, + `model_pdf` varchar(255) DEFAULT NULL, + `date_livraison` date DEFAULT NULL, + `fk_shipping_method` int(11) DEFAULT NULL, + `fk_availability` int(11) DEFAULT NULL, + `fk_input_reason` int(11) DEFAULT NULL, + `import_key` varchar(14) DEFAULT NULL, + `extraparams` varchar(255) DEFAULT NULL, + `fk_delivery_address` int(11) DEFAULT NULL, + PRIMARY KEY (`rowid`), + UNIQUE KEY `uk_askpricesupplier_ref` (`ref`,`entity`), + KEY `idx_askpricesupplier_fk_soc` (`fk_soc`), + KEY `idx_askpricesupplier_fk_user_author` (`fk_user_author`), + KEY `idx_askpricesupplier_fk_user_valid` (`fk_user_valid`), + KEY `idx_askpricesupplier_fk_user_cloture` (`fk_user_cloture`), + KEY `idx_askpricesupplier_fk_projet` (`fk_projet`), + KEY `idx_askpricesupplier_fk_account` (`fk_account`), + KEY `idx_askpricesupplier_fk_currency` (`fk_currency`), + CONSTRAINT `fk_askpricesupplier_fk_projet` FOREIGN KEY (`fk_projet`) REFERENCES `llx_projet` (`rowid`), + CONSTRAINT `fk_askpricesupplier_fk_soc` FOREIGN KEY (`fk_soc`) REFERENCES `llx_societe` (`rowid`), + CONSTRAINT `fk_askpricesupplier_fk_user_author` FOREIGN KEY (`fk_user_author`) REFERENCES `llx_user` (`rowid`), + CONSTRAINT `fk_askpricesupplier_fk_user_cloture` FOREIGN KEY (`fk_user_cloture`) REFERENCES `llx_user` (`rowid`), + CONSTRAINT `fk_askpricesupplier_fk_user_valid` FOREIGN KEY (`fk_user_valid`) REFERENCES `llx_user` (`rowid`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 diff --git a/htdocs/comm/askpricesupplier/sql/llx_askpricesupplier_extrafields.sql b/htdocs/comm/askpricesupplier/sql/llx_askpricesupplier_extrafields.sql new file mode 100644 index 00000000000..24071c0c5b8 --- /dev/null +++ b/htdocs/comm/askpricesupplier/sql/llx_askpricesupplier_extrafields.sql @@ -0,0 +1,8 @@ +CREATE TABLE `llx_askpricesupplier_extrafields` ( + `rowid` int(11) NOT NULL AUTO_INCREMENT, + `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `fk_object` int(11) NOT NULL, + `import_key` varchar(14) DEFAULT NULL, + PRIMARY KEY (`rowid`), + KEY `idx_askpricesupplier_extrafields` (`fk_object`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 \ No newline at end of file diff --git a/htdocs/comm/askpricesupplier/sql/llx_askpricesupplierdet.sql b/htdocs/comm/askpricesupplier/sql/llx_askpricesupplierdet.sql new file mode 100644 index 00000000000..86c605f2b2d --- /dev/null +++ b/htdocs/comm/askpricesupplier/sql/llx_askpricesupplierdet.sql @@ -0,0 +1,36 @@ +CREATE TABLE `llx_askpricesupplierdet` ( + `rowid` int(11) NOT NULL AUTO_INCREMENT, + `fk_askpricesupplier` int(11) NOT NULL, + `fk_parent_line` int(11) DEFAULT NULL, + `fk_product` int(11) DEFAULT NULL, + `label` varchar(255) DEFAULT NULL, + `description` text, + `fk_remise_except` int(11) DEFAULT NULL, + `tva_tx` double(6,3) DEFAULT '0.000', + `localtax1_tx` double(6,3) DEFAULT '0.000', + `localtax1_type` varchar(10) DEFAULT NULL, + `localtax2_tx` double(6,3) DEFAULT '0.000', + `localtax2_type` varchar(10) DEFAULT NULL, + `qty` double DEFAULT NULL, + `remise_percent` double DEFAULT '0', + `remise` double DEFAULT '0', + `price` double DEFAULT NULL, + `subprice` double(24,8) DEFAULT '0.00000000', + `total_ht` double(24,8) DEFAULT '0.00000000', + `total_tva` double(24,8) DEFAULT '0.00000000', + `total_localtax1` double(24,8) DEFAULT '0.00000000', + `total_localtax2` double(24,8) DEFAULT '0.00000000', + `total_ttc` double(24,8) DEFAULT '0.00000000', + `product_type` int(11) DEFAULT '0', + `date_start` datetime DEFAULT NULL, + `date_end` datetime DEFAULT NULL, + `info_bits` int(11) DEFAULT '0', + `buy_price_ht` double(24,8) DEFAULT '0.00000000', + `fk_product_fournisseur_price` int(11) DEFAULT NULL, + `special_code` int(11) DEFAULT '0', + `rang` int(11) DEFAULT '0', + PRIMARY KEY (`rowid`), + KEY `idx_askpricesupplierdet_fk_askpricesupplierdet` (`fk_askpricesupplier`), + KEY `idx_askpricesupplierdet_fk_product` (`fk_product`), + CONSTRAINT `fk_askpricesupplierdet_fk_propal` FOREIGN KEY (`fk_askpricesupplier`) REFERENCES `llx_askpricesupplier` (`rowid`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 diff --git a/htdocs/comm/askpricesupplier/sql/llx_askpricesupplierdet_extrafields.sql b/htdocs/comm/askpricesupplier/sql/llx_askpricesupplierdet_extrafields.sql new file mode 100644 index 00000000000..dfd7a889560 --- /dev/null +++ b/htdocs/comm/askpricesupplier/sql/llx_askpricesupplierdet_extrafields.sql @@ -0,0 +1,8 @@ +CREATE TABLE `llx_askpricesupplierdet_extrafields` ( + `rowid` int(11) NOT NULL AUTO_INCREMENT, + `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `fk_object` int(11) NOT NULL, + `import_key` varchar(14) DEFAULT NULL, + PRIMARY KEY (`rowid`), + KEY `idx_askpricesupplierdet_extrafields` (`fk_object`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 \ No newline at end of file diff --git a/htdocs/comm/askpricesupplier/tpl/linkedobjectblock.tpl.php b/htdocs/comm/askpricesupplier/tpl/linkedobjectblock.tpl.php index cb920afd5fc..0ae63216086 100644 --- a/htdocs/comm/askpricesupplier/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/askpricesupplier/tpl/linkedobjectblock.tpl.php @@ -52,11 +52,11 @@ foreach($linkedObjectBlock as $object) $var=!$var; ?> > + trans("ShowAskPriceSupplier"),"askpricesupplier").' '.$object->ref; ?> @@ -69,7 +69,7 @@ foreach($linkedObjectBlock as $object) diff --git a/htdocs/core/lib/askpricesupplier.lib.php b/htdocs/core/lib/askpricesupplier.lib.php new file mode 100644 index 00000000000..fd227d512b7 --- /dev/null +++ b/htdocs/core/lib/askpricesupplier.lib.php @@ -0,0 +1,148 @@ + + * Copyright (C) 2005-2012 Regis Houssin + * + * 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 3 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, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/lib/propal.lib.php + * \brief Ensemble de fonctions de base pour le module propal + * \ingroup propal + */ + +/** + * Prepare array with list of tabs + * + * @param object $object Object related to tabs + * @return array Array of tabs to show + */ +function propal_prepare_head($object) +{ + global $langs, $conf, $user; + $langs->load("propal"); + $langs->load("compta"); + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?id='.$object->id; + $head[$h][1] = $langs->trans('ProposalCard'); + $head[$h][2] = 'comm'; + $h++; + + if ((empty($conf->commande->enabled) && ((! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) + || (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) + { + $langs->load("sendings"); + $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; + if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); + if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); + $head[$h][1] = $text; + $head[$h][2] = 'shipping'; + $h++; + } + if (! empty($conf->global->MAIN_USE_PREVIEW_TABS)) + { + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?id='.$object->id; + $head[$h][1] = $langs->trans("Preview"); + $head[$h][2] = 'preview'; + $h++; + } + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; + $h++; + } + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'propal'); + + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $nbNote = 0; + if(!empty($object->note_private)) $nbNote++; + if(!empty($object->note_public)) $nbNote++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; + $head[$h][2] = 'note'; + $h++; + } + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if($nbFiles > 0) $head[$h][1].= ' '.$nbFiles.''; + $head[$h][2] = 'document'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$object->id; + $head[$h][1] = $langs->trans('Info'); + $head[$h][2] = 'info'; + $h++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove'); + + return $head; +} + +/** + * Return array head with list of tabs to view object informations. + * + * @return array head array with tabs + */ +function propal_admin_prepare_head() +{ + global $langs, $conf, $user; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/admin/propal.php'; + $head[$h][1] = $langs->trans("Miscellaneous"); + $head[$h][2] = 'general'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin'); + + $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $head[$h][2] = 'attributeslines'; + $h++; + + complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove'); + + return $head; +} + + diff --git a/htdocs/core/modules/askpricesupplier/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/askpricesupplier/doc/doc_generic_proposal_odt.modules.php new file mode 100644 index 00000000000..8f79094befc --- /dev/null +++ b/htdocs/core/modules/askpricesupplier/doc/doc_generic_proposal_odt.modules.php @@ -0,0 +1,484 @@ + + * Copyright (C) 2012 Juanjo Menent +* +* 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 3 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, see . +* or see http://www.gnu.org/ +*/ + +/** + * \file htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php + * \ingroup societe + * \brief File of class to build ODT documents for third parties + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class doc_generic_proposal_odt extends ModelePDFPropales +{ + var $emetteur; // Objet societe qui emet + + var $phpmin = array(5,2,0); // Minimum version of PHP required by module + var $version = 'dolibarr'; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "ODT templates"; + $this->description = $langs->trans("DocumentModelOdt"); + $this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + + // Dimension page pour format A4 + $this->type = 'odt'; + $this->page_largeur = 0; + $this->page_hauteur = 0; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=0; + $this->marge_droite=0; + $this->marge_haute=0; + $this->marge_basse=0; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + } + + + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + function info($langs) + { + global $conf,$langs; + + $langs->load("companies"); + $langs->load("errors"); + + $form = new Form($this->db); + + $texte = $this->description.".
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) + { + $texte.= ''; + $texte.= ''; + $texte.= ''; + } + $texte.= '
'.$langs->trans("ProposalsOpened").' '.$num.'
'.$langs->trans("RequestsOpened").' '.$num.'
'; - $propalstatic->id=$obj->propalid; - $propalstatic->ref=$obj->ref; + $askpricesupplierstatic->id=$obj->propalid; + $askpricesupplierstatic->ref=$obj->ref; print ''; print ''; print ''; print '
'; - print $propalstatic->getNomUrl(1); + print $askpricesupplierstatic->getNomUrl(1); print ''; - if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + if ($db->jdate($obj->dfv) < ($now - $conf->askpricesupplier->cloture->warning_delay)) print img_warning($langs->trans("Late")); print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); + $filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->askpricesupplierid; + print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir); print '
'; print "
'; print dol_print_date($db->jdate($obj->dp),'day').''.price($obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut,3).''.$askpricesupplierstatic->LibStatut($obj->fk_statut,3).'
'; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; + $askpricesupplierstatic->id=$obj->rowid; + $askpricesupplierstatic->ref=$obj->ref; print ''; print ''; print '
'; - print $propalstatic->getNomUrl(1); + print $askpricesupplierstatic->getNomUrl(1); print ''; @@ -428,14 +428,14 @@ if (! empty($conf->propal->enabled)) $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); + print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir); print '
'; print '
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).''.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).''.$askpricesupplierstatic->LibStatut($obj->fk_statut,$obj->facture,5).'
'; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; + $askpricesupplierstatic->id=$obj->rowid; + $askpricesupplierstatic->ref=$obj->ref; print ''; print ''; print '
'; - print $propalstatic->getNomUrl(1); + print $askpricesupplierstatic->getNomUrl(1); print ''; @@ -500,14 +500,14 @@ if (! empty($conf->propal->enabled)) $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir); + print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir); print '
'; print '
'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).''.$askpricesupplierstatic->LibStatut($obj->fk_statut,$obj->facture,5).'
- trans("ShowPropal"),"propal").' '.$object->ref; ?> ref_client; ?> date,'day'); ?> rights->propale->lire) { + if ($user->rights->askpricesupplier->lire) { $total = $total + $object->total_ht; echo price($object->total_ht); } ?>
trans('TotalHT'); ?> rights->propale->lire) { + if ($user->rights->askpricesupplier->lire) { echo price($total); } ?>  
'; + + // List of directories area + $texte.= ''; + + $texte.= ''; + $texte.= ''; + + $texte.= '
'; + $texttitle=$langs->trans("ListOfDirectories"); + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH))); + $listoffiles=array(); + foreach($listofdir as $key=>$tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); + if (! $tmpdir) { + unset($listofdir[$key]); continue; + } + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); + else + { + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); + } + } + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + // Add list of substitution keys + $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + + // Scan directories + if (count($listofdir)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + + if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) + { + // Model for creation + $liste=ModelePDFPropales::liste_modeles($this->db); + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '"; + + $texte.= ''; + $texte.= ''; + $texte.= '"; + $texte.= ''; + + $texte.= ''; + $texte.= '"; + $texte.= '
'.$langs->trans("DefaultModelPropalCreate").''; + $texte.= $form->selectarray('value2',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT); + $texte.= "
'.$langs->trans("DefaultModelPropalToBill").''; + $texte.= $form->selectarray('value3',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL); + $texte.= "
'.$langs->trans("DefaultModelPropalClosed").''; + $texte.= $form->selectarray('value4',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); + $texte.= "
'; + } + } + + $texte.= '
'; + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte.= '
'; + $texte.= ''; + + return $texte; + } + + /** + * Function to build a document on disk using the generic odt module. + * + * @param Propale $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) + { + global $user,$langs,$conf,$mysoc,$hookmanager; + + if (empty($srctemplatepath)) + { + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); + return -1; + } + + // Add odtgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='UTF-8'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + + if ($conf->propal->dir_output) + { + // If $object is id instead of object + if (! is_object($object)) + { + $id = $object; + $object = new Propale($this->db); + $result=$object->fetch($id); + if ($result < 0) + { + dol_print_error($this->db,$object->error); + return -1; + } + } + + $dir = $conf->propal->dir_output; + $objectref = dol_sanitizeFileName($object->ref); + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".odt"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + if (file_exists($dir)) + { + //print "srctemplatepath=".$srctemplatepath; // Src filename + $newfile=basename($srctemplatepath); + $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); + + $newfiletmp=$objectref.'_'.$newfiletmp; + + // Get extension (ods or odt) + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + { + $filename=$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.'.$newfileformat; + } + else + { + $filename=$newfiletmp.'.'.$newfileformat; + } + $file=$dir.'/'.$filename; + //print "newdir=".$dir; + //print "newfile=".$newfile; + //print "file=".$file; + //print "conf->propal->dir_temp=".$conf->propal->dir_temp; + + dol_mkdir($conf->propal->dir_temp); + + + // If BILLING contact defined on invoice, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external','BILLING'); + if (count($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 (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else $socobject = $object->client; + } + else + { + $socobject=$object->client; + } + + // Make substitution + $substitutionarray=array( + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_vat + ); + complete_substitutions_array($substitutionarray, $langs, $object); + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + // Line of free text + $newfreetext=''; + $paramfreetext='PROPALE_FREE_TEXT'; + if (! empty($conf->global->$paramfreetext)) + { + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); + } + + // Open and load template + require_once ODTPHP_PATH.'odf.php'; + try { + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->propal->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' + ) + ); + } + catch(Exception $e) + { + $this->error=$e->getMessage(); + return -1; + } + // After construction $odfHandler->contentXml contains content and + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by + // [!-- BEGIN lines --]*[!-- END lines --] + //print html_entity_decode($odfHandler->__toString()); + //print exit; + + + // Make substitutions into odt of freetext + try { + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + + // Make substitutions into odt + $array_user=$this->get_substitutionarray_user($user,$outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); + complete_substitutions_array($tmparray, $outputlangs, $object); + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/',$key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + } + catch(OdfException $e) + { + } + } + // Replace tags of lines + try + { + $listlines = $odfHandler->setSegment('lines'); + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); + } + catch(OdfException $e) + { + $this->error=$e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } + + // Call the beforeODTSave hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + // Write new file + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + try { + $odfHandler->exportAsAttachedPDF($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + return -1; + } + } + else { + try { + $odfHandler->saveToDisk($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + return -1; + } + } + + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $odfHandler=null; // Destroy object + + return 1; // Success + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + return -1; + } + +} + diff --git a/htdocs/core/modules/askpricesupplier/doc/index.html b/htdocs/core/modules/askpricesupplier/doc/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/core/modules/askpricesupplier/doc/pdf_azur.modules.php b/htdocs/core/modules/askpricesupplier/doc/pdf_azur.modules.php new file mode 100644 index 00000000000..35953b8521f --- /dev/null +++ b/htdocs/core/modules/askpricesupplier/doc/pdf_azur.modules.php @@ -0,0 +1,1385 @@ + + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * + * 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 3 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, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/propale/doc/pdf_azur.modules.php + * \ingroup propale + * \brief Fichier de la classe permettant de generer les propales au modele Azur + */ +require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + + +/** + * Class to generate PDF proposal Azur + */ +class pdf_azur extends ModelePDFPropales +{ + var $db; + var $name; + var $description; + var $type; + + var $phpmin = array(4,3,0); // Minimum version of PHP required by module + var $version = 'dolibarr'; + + var $page_largeur; + var $page_hauteur; + var $format; + var $marge_gauche; + var $marge_droite; + var $marge_haute; + var $marge_basse; + + var $emetteur; // Objet societe qui emet + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("bills"); + + $this->db = $db; + $this->name = "azur"; + $this->description = $langs->trans('DocModelAzurDescription'); + + // Dimension page pour format A4 + $this->type = 'pdf'; + $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 1; // Affiche mode reglement + $this->option_condreg = 1; // Affiche conditions reglement + $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 1; // Affiche si il y a eu escompte + $this->option_credit_note = 1; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; //Support add of a watermark on drafts + + $this->franchise=!$mysoc->tva_assuj; + + // Get source company + $this->emetteur=$mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined + + // Define position of columns + $this->posxdesc=$this->marge_gauche+1; + $this->posxtva=112; + $this->posxup=126; + $this->posxqty=145; + $this->posxdiscount=162; + $this->postotalht=174; + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; + $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if ($this->page_largeur < 210) // To work with US executive format + { + $this->posxpicture-=20; + $this->posxtva-=20; + $this->posxup-=20; + $this->posxqty-=20; + $this->posxdiscount-=20; + $this->postotalht-=20; + } + + $this->tva=array(); + $this->localtax1=array(); + $this->localtax2=array(); + $this->atleastoneratenotnull=0; + $this->atleastonediscount=0; + } + + /** + * Function to build pdf onto disk + * + * @param Object $object Object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1=OK, 0=KO + */ + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) + { + global $user,$langs,$conf,$mysoc,$db,$hookmanager; + + if (! is_object($outputlangs)) $outputlangs=$langs; + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("products"); + + $nblignes = count($object->lines); + + // Loop on each lines to detect if there is at least one image to show + $realpatharray=array(); + if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) + { + for ($i = 0 ; $i < $nblignes ; $i++) + { + if (empty($object->lines[$i]->fk_product)) continue; + + $objphoto = new Product($this->db); + $objphoto->fetch($object->lines[$i]->fk_product); + + $pdir = get_exdir($object->lines[$i]->fk_product,2) . $object->lines[$i]->fk_product ."/photos/"; + $dir = $conf->product->dir_output.'/'.$pdir; + + $realpath=''; + foreach ($objphoto->liste_photos($dir,1) as $key => $obj) + { + $filename=$obj['photo']; + //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; + $realpath = $dir.$filename; + break; + } + + if ($realpath) $realpatharray[$i]=$realpath; + } + } + if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; + + if ($conf->propal->dir_output) + { + $object->fetch_thirdparty(); + + // $deja_regle = 0; + + // Definition of $dir and $file + if ($object->specimen) + { + $dir = $conf->propal->dir_output; + $file = $dir . "/SPECIMEN.pdf"; + } + else + { + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->propal->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + } + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return 0; + } + } + + if (file_exists($dir)) + { + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + // Create pdf instance + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + $pdf->SetAutoPageBreak(1,0); + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } + + $pdf->Open(); + $pagenb=0; + $pdf->SetDrawColor(128,128,128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialProposal")); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + // Positionne $this->atleastonediscount si on a au moins une remise + for ($i = 0 ; $i < $nblignes ; $i++) + { + if ($object->lines[$i]->remise_percent) + { + $this->atleastonediscount++; + } + } + if (empty($this->atleastonediscount)) + { + $this->posxpicture+=($this->postotalht - $this->posxdiscount); + $this->posxtva+=($this->postotalht - $this->posxdiscount); + $this->posxup+=($this->postotalht - $this->posxdiscount); + $this->posxqty+=($this->postotalht - $this->posxdiscount); + $this->posxdiscount+=($this->postotalht - $this->posxdiscount); + //$this->postotalht; + } + + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $tab_top = 90; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_height = 130; + $tab_height_newpage = 150; + + // Affiche notes + $notetoshow=empty($object->note_public)?'':$object->note_public; + if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + { + // Get first sale rep + if (is_object($object->thirdparty)) + { + $salereparray=$object->thirdparty->getSalesRepresentatives($user); + $salerepobj=new User($this->db); + $salerepobj->fetch($salereparray[0]['id']); + if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); + } + } + if ($notetoshow) + { + $tab_top = 88; + + $pdf->SetFont('','', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $nexY = $pdf->GetY(); + $height_note=$nexY-$tab_top; + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + + // Loop on each lines + for ($i = 0 ; $i < $nblignes ; $i++) + { + $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + // Define size of image if we need it + $imglinesize=array(); + if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); + + $showpricebeforepagebreak=1; + $posYAfterImage=0; + $posYAfterDescription=0; + + // We start with Photo of product line + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposbefore+1); + + $curY = $tab_top_newpage; + $showpricebeforepagebreak=0; + } + + if (isset($imglinesize['width']) && isset($imglinesize['height'])) + { + $curX = $this->posxpicture-1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // $pdf->Image does not increase value return by getY, so we save it manually + $posYAfterImage=$curY+$imglinesize['height']; + } + + // Description of product line + $curX = $this->posxdesc-1; + + $pdf->startTransaction(); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); + + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); + + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription=$pdf->GetY(); + + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description or photo were moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + + // VAT Rate + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) + { + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxtva, $curY); + $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); + } + + // Unit price before discount + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); + + // Quantity + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxqty, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars + + // Discount on line + if ($object->lines[$i]->remise_percent) + { + $pdf->SetXY($this->posxdiscount-2, $curY); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); + $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); + } + + // Total HT line + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + $tvaligne=$object->lines[$i]->total_tva; + $localtax1ligne=$object->lines[$i]->total_localtax1; + $localtax2ligne=$object->lines[$i]->total_localtax2; + $localtax1_rate=$object->lines[$i]->localtax1_tx; + $localtax2_rate=$object->lines[$i]->localtax2_tx; + $localtax1_type=$object->lines[$i]->localtax1_type; + $localtax2_type=$object->lines[$i]->localtax2_type; + + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; + if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; + if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + + $vatrate=(string) $object->lines[$i]->tva_tx; + + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } + + // retrieve global local tax + if ($localtax1_type && $localtax1ligne != 0) + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + if ($localtax2_type && $localtax2ligne != 0) + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; + $this->tva[$vatrate] += $tvaligne; + + if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; + + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } + + $nexY+=2; // Passe espace entre les lignes + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) + { + $pdf->setPage($pagenb); + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + } + + // Show square + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + // Affiche zone infos + $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); + + // Affiche zone versements + /* + if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) + { + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); + } + */ + + // Pied de page + $this->_pagefoot($pdf,$object,$outputlangs); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + + $pdf->Close(); + + $pdf->Output($file,'F'); + + //Add pdfgeneration hook + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } + } + else + { + $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR"); + return 0; + } + + $this->error=$langs->trans("ErrorUnknown"); + return 0; // Erreur par defaut + } + + /** + * Show payments table + * + * @param PDF $pdf Object PDF + * @param Object $object Object proposal + * @param int $posy Position y in PDF + * @param Translate $outputlangs Object langs for output + * @return int <0 if KO, >0 if OK + */ + function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + { + + } + + + /** + * Show miscellaneous information (payment mode, payment term, ...) + * + * @param PDF $pdf Object PDF + * @param Object $object Object to show + * @param int $posy Y + * @param Translate $outputlangs Langs object + * @return void + */ + function _tableau_info(&$pdf, $object, $posy, $outputlangs) + { + global $conf; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $pdf->SetFont('','', $default_font_size - 1); + + // If France, show VAT mention if not applicable + if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) + { + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + + $posy=$pdf->GetY()+4; + } + + $posxval=52; + + // Show shipping date + if (! empty($object->date_livraison)) + { + $outputlangs->load("sendings"); + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; + $pdf->MultiCell(80, 4, $titre, 0, 'L'); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true); + $pdf->MultiCell(80, 4, $dlp, 0, 'L'); + + $posy=$pdf->GetY()+1; + } + elseif ($object->availability_code || $object->availability) // Show availability conditions + { + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; + $pdf->MultiCell(80, 4, $titre, 0, 'L'); + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability); + $lib_availability=str_replace('\n',"\n",$lib_availability); + $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); + + $posy=$pdf->GetY()+1; + } + + // Show payments conditions + if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement)) + { + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentConditions").':'; + $pdf->MultiCell(80, 4, $titre, 0, 'L'); + + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); + $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); + $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); + + $posy=$pdf->GetY()+3; + } + + if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND)) + { + // Check a payment mode is defined + /* Not required on a proposal + if (empty($object->mode_reglement_code) + && ! $conf->global->FACTURE_CHQ_NUMBER + && ! $conf->global->FACTURE_RIB_NUMBER) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); + $pdf->SetTextColor(0,0,0); + + $posy=$pdf->GetY()+1; + } + */ + + // Show payment mode + if ($object->mode_reglement_code + && $object->mode_reglement_code != 'CHQ' + && $object->mode_reglement_code != 'VIR') + { + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); + + $posy=$pdf->GetY()+2; + } + + // Show payment mode CHQ + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') + { + // Si mode reglement non force ou si force a CHQ + if (! empty($conf->global->FACTURE_CHQ_NUMBER)) + { + $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); + + if ($conf->global->FACTURE_CHQ_NUMBER > 0) + { + $account = new Account($this->db); + $account->fetch($conf->global->FACTURE_CHQ_NUMBER); + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('','B', $default_font_size - $diffsizetitle); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0); + $posy=$pdf->GetY()+1; + + if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('','', $default_font_size - $diffsizetitle); + $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + } + if ($conf->global->FACTURE_CHQ_NUMBER == -1) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('','B', $default_font_size - $diffsizetitle); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0); + $posy=$pdf->GetY()+1; + + if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('','', $default_font_size - $diffsizetitle); + $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + } + } + } + + // If payment mode not forced or forced to VIR, show payment with BAN + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') + { + if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) + { + $bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank); + $account = new Account($this->db); + $account->fetch($bankid); + + $curx=$this->marge_gauche; + $cury=$posy; + + $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); + + $posy+=2; + } + } + } + + return $posy; + } + + + /** + * Show total to pay + * + * @param PDF $pdf Object PDF + * @param Facture $object Object invoice + * @param int $deja_regle Montant deja regle + * @param int $posy Position depart + * @param Translate $outputlangs Objet langs + * @return int Position pour suite + */ + function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + { + global $conf,$mysoc; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $tab2_top = $posy; + $tab2_hl = 4; + $pdf->SetFont('','', $default_font_size - 1); + + // Tableau total + $col1x = 120; $col2x = 170; + if ($this->page_largeur < 210) // To work with US executive format + { + $col2x-=20; + } + $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); + + $useborder=0; + $index = 0; + + // Total HT + $pdf->SetFillColor(255,255,255); + $pdf->SetXY($col1x, $tab2_top + 0); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); + + // Show VAT by rates and total + $pdf->SetFillColor(248,248,248); + + $this->atleastoneratenotnull=0; + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) + { + $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) + { + // Nothing to do + } + else + { + //Local tax 1 before VAT + //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + //{ + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach( $localtax_rate as $tvakey => $tvaval ) + { + if ($tvakey!=0) // On affiche pas taux 0 + { + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + } + } + } + //} + //Local tax 2 before VAT + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') + //{ + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach( $localtax_rate as $tvakey => $tvaval ) + { + if ($tvakey!=0) // On affiche pas taux 0 + { + //$this->atleastoneratenotnull++; + + + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + + } + } + } + //} + // VAT + foreach($this->tva as $tvakey => $tvaval) + { + if ($tvakey > 0) // On affiche pas taux 0 + { + $this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat =$outputlangs->transnoentities("TotalVAT").' '; + $totalvat.=vatrate($tvakey,1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + } + } + + //Local tax 1 after VAT + //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') + //{ + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach( $localtax_rate as $tvakey => $tvaval ) + { + if ($tvakey != 0) // On affiche pas taux 0 + { + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + } + } + } + //} + //Local tax 2 after VAT + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') + //{ + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach( $localtax_rate as $tvakey => $tvaval ) + { + // retrieve global local tax + if ($tvakey != 0) // On affiche pas taux 0 + { + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) + { + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + } + } + } + //} + + // Total TTC + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); + } + } + + $pdf->SetTextColor(0,0,0); + + /* + $resteapayer = $object->total_ttc - $deja_regle; + if (! empty($object->paye)) $resteapayer=0; + */ + + if ($deja_regle > 0) + { + $index++; + + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); + + /* + if ($object->close_code == 'discount_vat') + { + $index++; + $pdf->SetFillColor(255,255,255); + + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1); + + $resteapayer=0; + } + */ + + $index++; + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); + + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetTextColor(0,0,0); + } + + $index++; + return ($tab2_top + ($tab2_hl * $index)); + } + + /** + * Show table for lines + * + * @param PDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom bar of array + * @return void + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) + { + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom=0; + if ($hidetop) $hidetop=-1; + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','',$default_font_size - 2); + + if (empty($hidetop)) + { + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + } + + $pdf->SetDrawColor(128,128,128); + $pdf->SetFont('','',$default_font_size - 1); + + // Output Rect + $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + + if (empty($hidetop)) + { + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + + $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); + } + + if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) + { + $pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + //$pdf->SetXY($this->posxpicture-1, $tab_top+1); + //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C'); + } + } + + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) + { + $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxtva-3, $tab_top+1); + $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); + } + } + + $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxup-1, $tab_top+1); + $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); + } + + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxqty-1, $tab_top+1); + $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); + } + + $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + if ($this->atleastonediscount) + { + $pdf->SetXY($this->posxdiscount-1, $tab_top+1); + $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); + } + } + if ($this->atleastonediscount) + { + $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + } + if (empty($hidetop)) + { + $pdf->SetXY($this->postotalht-1, $tab_top+1); + $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C'); + } + } + + /** + * Show top header of page. + * + * @param PDF $pdf Object PDF + * @param Object $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void + */ + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { + global $conf,$langs; + + $outputlangs->load("main"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("companies"); + + $default_font_size = pdf_getPDFFontSize($outputlangs); + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + // Show Draft Watermark + if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) ) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK); + } + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posy=$this->marge_haute; + $posx=$this->page_largeur-$this->marge_droite-100; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + 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'); + } + + $pdf->SetFont('','B',$default_font_size + 3); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $title=$outputlangs->transnoentities("CommercialProposal"); + $pdf->MultiCell(100, 4, $title, '', 'R'); + + $pdf->SetFont('','B',$default_font_size); + + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); + + $posy+=1; + $pdf->SetFont('','', $default_font_size - 2); + + if ($object->ref_client) + { + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + } + + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R'); + + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R'); + + if ($object->client->code_client) + { + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); + } + + $posy+=2; + + // Show list of linked objects + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + + if ($showaddress) + { + // Sender properties + $carac_emetteur=''; + // Add internal contact of proposal if defined + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (count($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, $object->client); + + // Show sender + $posy=42; + $posx=$this->marge_gauche; + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $hautcadre=40; + + // 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("BillFrom").":", 0, 'L'); + $pdf->SetXY($posx,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0,0,60); + + // Show sender name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy=$pdf->getY(); + + // Show sender information + $pdf->SetXY($posx+2,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); + + + // If CUSTOMER contact defined, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); + if (count($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 (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; + else $socname = $object->client->name; + $carac_client_name=$outputlangs->convToOutputCharset($socname); + } + else + { + $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + } + + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target'); + + // Show recipient + $widthrecbox=100; + if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format + $posy=42; + $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; + 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+2,$posy-5); + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); + + // Show recipient name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); + + // Show recipient information + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4)); + $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); + } + + $pdf->SetTextColor(0,0,0); + } + + /** + * Show footer of page. Need this->emetteur object + * + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) + { + $showdetails=0; + return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + } + +} + diff --git a/htdocs/core/modules/askpricesupplier/index.html b/htdocs/core/modules/askpricesupplier/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/core/modules/askpricesupplier/mod_propale_marbre.php b/htdocs/core/modules/askpricesupplier/mod_propale_marbre.php new file mode 100644 index 00000000000..28260de97d8 --- /dev/null +++ b/htdocs/core/modules/askpricesupplier/mod_propale_marbre.php @@ -0,0 +1,153 @@ + + * Copyright (C) 2005-2012 Regis Houssin + * + * 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 3 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, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/propale/mod_propale_marbre.php + * \ingroup propale + * \brief File of class to manage commercial proposal numbering rules Marbre + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; + + +/** + * Class to manage customer order numbering rules Marbre + */ +class mod_propale_marbre extends ModeleNumRefPropales +{ + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' + var $prefix='PR'; + var $error=''; + var $nom = "Marbre"; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); + } + + + /** + * Return an example of numbering module values + * + * @return string Example + */ + function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Test si les numeros deje en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + function canBeActivated() + { + global $conf,$langs,$db; + + $pryymm=''; $max=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal"; + $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; } + } + + if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm)) + { + return true; + } + else + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel',$max); + return false; + } + } + + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Propal $propal Object commercial proposal + * @return string Next value + */ + function getNextValue($objsoc,$propal) + { + global $db,$conf; + + // D'abord on recupere la valeur max + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL + $sql.= " FROM ".MAIN_DB_PREFIX."propal"; + $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); + return -1; + } + + $date = time(); + $yymm = strftime("%y%m",$date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); + + dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } + + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param Object $objforref Object for number to search + * @return string Next free value + */ + function getNumRef($objsoc,$objforref) + { + return $this->getNextValue($objsoc,$objforref); + } + +} diff --git a/htdocs/core/modules/askpricesupplier/mod_propale_saphir.php b/htdocs/core/modules/askpricesupplier/mod_propale_saphir.php new file mode 100644 index 00000000000..503d8754684 --- /dev/null +++ b/htdocs/core/modules/askpricesupplier/mod_propale_saphir.php @@ -0,0 +1,131 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2007 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * + * 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 3 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, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/propale/mod_propale_saphir.php + * \ingroup propale + * \brief File that contains the numbering module rules Saphir + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; + + +/** + * Class of file that contains the numbering module rules Saphir + */ +class mod_propale_saphir extends ModeleNumRefPropales +{ + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' + var $error = ''; + var $nom = 'Saphir'; + + + /** + * Return description of module + * + * @return string Texte descripif + */ + function info() + { + global $conf,$langs; + + $langs->load("bills"); + + $form = new Form($this->db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte.= ''; + $texte.= ''; + + $texte.= ''; + + $texte.= ''; + + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('',$tooltip,1,1).' 
'; + $texte.= '
'; + + return $texte; + } + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + function getExample() + { + global $conf,$langs,$mysoc; + + $old_code_client=$mysoc->code_client; + $mysoc->code_client='CCCCCCCCCC'; + $numExample = $this->getNextValue($mysoc,''); + $mysoc->code_client=$old_code_client; + + if (! $numExample) + { + $numExample = 'NotConfigured'; + } + return $numExample; + } + + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Propal $propal Object commercial proposal + * @return string Value if OK, 0 if KO + */ + function getNextValue($objsoc,$propal) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + // On defini critere recherche compteur + $mask=$conf->global->PROPALE_SAPHIR_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $date=$propal->datep; + $customercode=$objsoc->code_client; + $numFinal=get_next_value($db,$mask,'propal','ref','',$customercode,$date); + + return $numFinal; + } + +} diff --git a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php new file mode 100644 index 00000000000..68465c20512 --- /dev/null +++ b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php @@ -0,0 +1,165 @@ + + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * + * 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 3 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, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/propale/modules_propale.php + * \ingroup propale + * \brief Fichier contenant la classe mere de generation des propales en PDF + * et la classe mere de numerotation des propales + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent + + +/** + * Classe mere des modeles de propale + */ +abstract class ModelePDFAskPriceSupplier extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param string $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='askpricesupplier'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + + return $liste; + } +} + + +/** + * Classe mere des modeles de numerotation des references de propales + */ +abstract class ModeleNumRefPropales +{ + var $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + function isEnabled() + { + return true; + } + + /** + * Renvoi la description par defaut du modele de numerotation + * + * @return string Texte descripif + */ + function info() + { + global $langs; + $langs->load("propale"); + return $langs->trans("NoDescription"); + } + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + function getExample() + { + global $langs; + $langs->load("propale"); + return $langs->trans("NoExample"); + } + + /** + * Test si les numeros deja en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + function canBeActivated() + { + return true; + } + + /** + * Renvoi prochaine valeur attribuee + * + * @param Societe $objsoc Object third party + * @param Propal $propal Object commercial proposal + * @return string Valeur + */ + function getNextValue($objsoc,$propal) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Renvoi version du module numerotation + * + * @return string Valeur + */ + function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} + + +/** + * Create a document onto disk according to template module. + * + * @param DoliDB $db Database handler + * @param object $object Object proposal + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int 0 if KO, 1 if OK + * @deprecated Use the new function generateDocument of Propal class + */ +function propale_pdf_create(DoliDB $db, Propal $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) +{ + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); +} + diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index 1c108c572d1..92906ba7ae7 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -73,12 +73,32 @@ class modAskPriceSupplier extends DolibarrModules $this->const = array(); $r=0; - /*$this->const[$r][0] = "PROPALE_ADDON_PDF"; + $this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "azur"; - $this->const[$r][3] = 'Nom du gestionnaire de generation des propales en PDF'; + $this->const[$r][3] = 'Nom du gestionnaire de generation des demandes de prix fournisseurs en PDF'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ASKPRICESUPPLIER_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_propale_marbre"; + $this->const[$r][3] = 'Nom du gestionnaire de numerotation des demandes de prix fournisseurs'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ASKPRICESUPPLIER_VALIDITY_DURATION"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "15"; + $this->const[$r][3] = 'Durée de validitée des demandes de prix fournisseurs'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/askpricesupplier"; + $this->const[$r][3] = ""; $this->const[$r][4] = 0; - $r++;*/ // Boxes $this->boxes = array(); @@ -90,35 +110,36 @@ class modAskPriceSupplier extends DolibarrModules $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission - $this->rights[$r][1] = 'Créer/modifier les demandes fournisseurs'; // libelle de la permission + $this->rights[$r][1] = 'Lire les demandes fournisseurs'; // libelle de la permission $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'create'; + $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission - $this->rights[$r][1] = 'Lire les demandes fournisseurs'; // libelle de la permission + $this->rights[$r][1] = 'Créer/modifier les demandes fournisseurs'; // libelle de la permission $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'read'; + $this->rights[$r][4] = 'creer'; + $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission $this->rights[$r][1] = 'Valider les demandes fournisseurs'; // libelle de la permission $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'read'; + $this->rights[$r][4] = ''; $this->rights[$r][5] = 'validate'; $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission $this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'read'; + $this->rights[$r][4] = ''; $this->rights[$r][5] = 'send'; $r++; $this->rights[$r][0] = $this->numero + $r; // id de la permission $this->rights[$r][1] = 'Supprimer les demandes fournisseurs'; // libelle de la permission $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'delete'; + $this->rights[$r][4] = 'supprimer'; // Exports //-------- @@ -155,10 +176,10 @@ class modAskPriceSupplier extends DolibarrModules 'type'=>'left', // This is a Left menu entry 'titre'=>'askpricesupplierMENU_LEFT_TITLE', 'leftmenu'=>'askpricesuppliersubmenu', - 'url'=>'/askpricesupplier/index.php', + 'url'=>'/comm/askpricesupplier/index.php', 'langs'=>'askpricesupplier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'enabled'=>'$conf->askpricesupplier->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->rights->askpricesupplier->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->askpricesupplier->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'user'=>2 // 0=Menu for internal users, 1=external users, 2=both ); $r++; @@ -167,10 +188,10 @@ class modAskPriceSupplier extends DolibarrModules 'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu', 'type'=>'left', 'titre'=>'askpricesupplierMENU_LEFT_TITLE_NEW', - 'url'=>'/askpricesupplier/card.php?action=create', + 'url'=>'/comm/askpricesupplier.php?action=create', 'langs'=>'askpricesupplier', 'enabled'=>'$conf->askpricesupplier->enabled', - 'perms'=>'$user->rights->askpricesupplier->create', + 'perms'=>'$user->rights->askpricesupplier->creer', 'user'=>2 ); $r++; @@ -179,10 +200,10 @@ class modAskPriceSupplier extends DolibarrModules 'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu', 'type'=>'left', 'titre'=>'askpricesupplierMENU_LEFT_TITLE_LIST', - 'url'=>'/askpricesupplier/list.php', + 'url'=>'/comm/askpricesupplier/list.php', 'langs'=>'askpricesupplier', 'enabled'=>'$conf->askpricesupplier->enabled', - 'perms'=>'$user->rights->askpricesupplier->read', + 'perms'=>'$user->rights->askpricesupplier->lire', 'user'=>2 ); $r++; @@ -205,8 +226,7 @@ class modAskPriceSupplier extends DolibarrModules $sql = array(); - //$result=$this->_load_tables('/mymodule/sql/'); - + $result=$this->_load_tables('/comm/askpricesupplier/sql/'); return $this->_init($sql, $options); } @@ -226,3 +246,22 @@ class modAskPriceSupplier extends DolibarrModules } } + + +/* + * + * CREATE TABLE IF NOT EXISTS llx_askpricesupplier ( + rowid INT AUTO_INCREMENT, + fk_statut INT NOT NULL, + fk_soc INT NOT NULL, + price DOUBLE(24,8), + date_create TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + date_send TIMESTAMP, + PRIMARY KEY pk_rowid (rowid), + CONSTRAINT fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid) +); + * + * + * + * + */ diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index d3abf17501d..c50a4afcc01 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -151,6 +151,19 @@ class InterfaceDemo extends DolibarrTriggers case 'LINEPROPAL_UPDATE': case 'LINEPROPAL_DELETE': + // Askpricesupplier + case 'ASKPRICESUPPLIER_CREATE': + case 'ASKPRICESUPPLIER_CLONE': + case 'ASKPRICESUPPLIER_MODIFY': + case 'ASKPRICESUPPLIER_VALIDATE': + case 'ASKPRICESUPPLIER_SENTBYMAIL': + case 'ASKPRICESUPPLIER_CLOSE_SIGNED': + case 'ASKPRICESUPPLIER_CLOSE_REFUSED': + case 'ASKPRICESUPPLIER_DELETE': + case 'LINEASKPRICESUPPLIER_INSERT': + case 'LINEASKPRICESUPPLIER_UPDATE': + case 'LINEASKPRICESUPPLIER_DELETE': + // Contracts case 'CONTRACT_CREATE': case 'CONTRACT_ACTIVATE': diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang index 784082f42c4..6daa44ce0ce 100644 --- a/htdocs/langs/fr_FR/askpricesupplier.lang +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -3,4 +3,127 @@ AskPriceSupplier=Demande de prix fournisseur askpricesupplierDESC=Gestion des demandes de prix aux fournisseurs askpricesupplierMENU_LEFT_TITLE=Demandes de prix fourn. askpricesupplierMENU_LEFT_TITLE_NEW=Nouvelle demande -askpricesupplierMENU_LEFT_TITLE_LIST=Liste \ No newline at end of file +askpricesupplierMENU_LEFT_TITLE_LIST=Liste + +# Dolibarr language file - Source file is en_US - propal +Proposals=Propositions commerciales +Proposal=Proposition commerciale +ProposalShort=Proposition +ProposalsDraft=Propositions commerciales brouillons +ProposalDraft=Proposition commerciale brouillon +ProposalsOpened=Propositions commerciales ouvertes +Prop=Propositions commerciales +CommercialProposal=Proposition commerciale +CommercialProposals=Propositions commerciales +ProposalCard=Fiche proposition +NewProp=Nouvelle proposition commerciale +NewProposal=Nouvelle proposition commerciale +NewPropal=Nouvelle proposition +Prospect=Prospect +ProspectList=Liste des prospects +ConfirmDeleteProp=Êtes-vous sûr de vouloir effacer cette proposition commerciale ? +ConfirmValidateProp=Êtes-vous sûr de vouloir valider cette proposition commerciale sous la référence %s ? +LastPropals=Les %s dernières propales +LastClosedProposals=Les %s dernières propositions commerciales fermées +LastModifiedProposals=Les %s dernières propositions commerciales modifiées +AllPropals=Toutes les propales +LastProposals=Dernières propositions +SearchAProposal=Rechercher une proposition commerciale +ProposalsStatistics=Statistiques des propositions commerciales +NumberOfProposalsByMonth=Nombre par mois +AmountOfProposalsByMonthHT=Montant par mois (HT) +NbOfProposals=Nombre de propositions commerciales + + +# # Ajout +ShowAskpricesupplier=Afficher demande +CommRequest=Demande de prix +CommRequests=Demandes de prix +SearchRequest=Rechercher une demande +DraftRequests=Demandes brouillons +LastModifiedRequests=Les %s dernières demandes de prix modifiées +RequestsOpened=Demandes de prix ouvertes +AskPriceSupplierArea=Espace des demandes de prix fournisseurs +NewAskPrice=Nouvelle demande de prix +NewAsk=Nouvelle demande +# # Modifié +DateAsk=Date de demande +DateEndAsk=Date de fin de validité +DateEndAskShort=Date de fin +DeleteAsk=Supprimer demande +ValidateAsk=Valider demande +AddAsk=Créer une demande +AskpricesupplierDraft=Brouillons +AskpricesupplierOpened=Ouvertes +AskpricesupplierNotBilled=Non facturées +AskpricesupplierStatusDraft=Brouillon (à valider) +AskpricesupplierStatusValidated=Validée (demande ouverte) +AskpricesupplierStatusOpened=Validée (demande ouverte) +AskpricesupplierStatusClosed=Fermée +AskpricesupplierStatusSigned=Signée (à facturer) +AskpricesupplierStatusNotSigned=Non signée (fermée) +AskpricesupplierStatusBilled=Facturée +AskpricesupplierStatusDraftShort=Brouillon +AskpricesupplierStatusValidatedShort=Validée +AskpricesupplierStatusOpenedShort=Ouverte +AskpricesupplierStatusClosedShort=Fermée +AskpricesupplierStatusSignedShort=Signée +AskpricesupplierStatusNotSignedShort=Non signée +AskpricesupplierStatusBilledShort=Facturée +AskpricesupplierToClose=Demandes de prix à fermer +AskpricesupplierToBill=Demandes de prix signées à facturer +CopyAskFrom=Créer demande/devis par recopie d'une demande existante +CreateEmptyAsk=Créer demande/devis vierge +CloneAsk=Cloner demande de prix +ConfirmCloneAsk=Êtes-vous sûr de vouloir cloner la demande de prix %s ? +ConfirmReOpenAsk=Êtes-vous sûr de vouloir réouvrir la demande de prix %s ? +SendAskByMail=Envoyer demande de prix par email +SendAskRef=Envoi de la demande de prix %s + + +##### Types de contacts ##### +TypeContact_askpricesupplier_internal_SALESREPFOLL=Commercial suivi demande +TypeContact_askpricesupplier_external_BILLING=Contact client facturation demande +TypeContact_askpricesupplier_external_CUSTOMER=Contact client suivi demande + +# # + + +ListOfProposals=Liste des devis/propositions commerciales +ActionsOnPropal=Événements sur la proposition +NoOpenedPropals=Pas de proposition ouverte +NoOtherOpenedPropals=Pas d'autre proposition brouillon +RefProposal=Réf. proposition commerciale +AssociatedDocuments=Documents associés à la proposition : +ErrorCantOpenDir=Impossible d'ouvrir le répertoire + +ValidityDuration=Durée de validité +CloseAs=Clôturer au statut +ClassifyBilled=Classer facturée +BuildBill=Créer facture +ErrorPropalNotFound=Propale %s inexistante +Estimate=Devis : +EstimateShort=Devis +OtherPropals=Autres propositions +AddToDraftProposals=Ajouter à proposition brouillon +NoDraftProposals=Pas de propositions brouillons +DefaultProposalDurationValidity=Délai de validité par défaut (en jours) +UseCustomerContactAsPropalRecipientIfExist=Utiliser l'adresse de contact suivi client si définie plutôt que l'adresse du tiers comme destinataire des propositions + +ProposalsAndProposalsLines=Propositions commerciales clients et lignes de propositions +ProposalLine=Ligne de proposition +AvailabilityPeriod=Délai de livraison +SetAvailability=Définir le délai de livraison +AfterOrder=après commande +##### Availability ##### +AvailabilityTypeAV_NOW=Immédiate +AvailabilityTypeAV_1W=1 semaine +AvailabilityTypeAV_2W=2 semaines +AvailabilityTypeAV_3W=3 semaines +AvailabilityTypeAV_1M=1 mois +# Document models +DocModelAzurDescription=Modèle de proposition commerciale complet (logo…) +DocModelJauneDescription=Modèle de proposition Jaune +DefaultModelPropalCreate=Modèle par défaut à la création +DefaultModelPropalToBill=Modèle par défaut lors de la clôture d'une proposition commerciale (à facturer) +DefaultModelPropalClosed=Modèle par défaut lors de la clôture d'une proposition commerciale (non facturée) From 49fa0056c87572b220b101b250b4cbed16dec80c Mon Sep 17 00:00:00 2001 From: phf Date: Tue, 27 Jan 2015 17:43:07 +0100 Subject: [PATCH 004/120] [CORE] Avancement des replace (#new_ask_price). --- htdocs/comm/askpricesupplier/list.php | 30 ++--- .../class/html.formaskpricesupplier.class.php | 104 ++++++++++++++++++ .../modules_askpricesupplier.php | 4 +- .../modules/modAskPriceSupplier.class.php | 5 + htdocs/langs/fr_FR/askpricesupplier.lang | 2 +- 5 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 htdocs/core/class/html.formaskpricesupplier.class.php diff --git a/htdocs/comm/askpricesupplier/list.php b/htdocs/comm/askpricesupplier/list.php index c28128e81c5..948482fe4cd 100644 --- a/htdocs/comm/askpricesupplier/list.php +++ b/htdocs/comm/askpricesupplier/list.php @@ -33,14 +33,14 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaskpricesupplier.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load('companies'); -$langs->load('propal'); +$langs->load('askpricesupplier'); $langs->load('compta'); $langs->load('bills'); $langs->load('orders'); @@ -57,7 +57,7 @@ $search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_author=GETPOST('search_author','alpha'); $search_town=GETPOST('search_town','alpha'); $viewstatut=$db->escape(GETPOST('viewstatut')); -$object_statut=$db->escape(GETPOST('propal_statut')); +$object_statut=$db->escape(GETPOST('askpricesupplier_statut')); $sall=GETPOST("sall"); $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); @@ -68,7 +68,7 @@ $month=GETPOST("month"); $NBLINES=4; // Security check -$module='propal'; +$module='askpricesupplier'; $dbtable=''; $objectid=''; if (! empty($user->societe_id)) $socid=$user->societe_id; @@ -121,12 +121,12 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e * View */ -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); +llxHeader('',$langs->trans('CommRequest'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -$formpropal = new FormPropal($db); +$formpropal = new FormAskPriceSupplier($db); $companystatic=new Societe($db); $now=dol_now(); @@ -148,8 +148,8 @@ $sql = 'SELECT s.rowid, s.nom as name, s.town, s.client, s.code_client,'; $sql.= ' p.rowid as propalid, p.note_private, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= ' u.login'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p'; -if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; +$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'askpricesupplier as p'; +if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'askpricesupplierdet as pd ON p.rowid=pd.fk_askpricesupplier'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -208,7 +208,7 @@ else if ($year > 0) if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; if ($search_user > 0) { - $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; + $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='askpricesupplier' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$search_user; } @@ -227,7 +227,7 @@ $result=$db->query($sql); if ($result) { - $objectstatic=new Propal($db); + $objectstatic=new AskPriceSupplier($db); $userstatic=new User($db); $num = $db->num_rows($result); @@ -248,7 +248,7 @@ if ($result) if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; if ($search_author) $param.='&search_author='.$search_author; if ($search_town) $param.='&search_town='.$search_town; - print_barre_liste($langs->trans('ListOfProposals').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); + print_barre_liste($langs->trans('ListOfAskPriceSupplier').' '.($socid?'- '.$soc->name:''), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); // Lignes des champs de filtre print '
'; @@ -344,7 +344,7 @@ if ($result) print '
'; - $objectstatic->id=$objp->propalid; + $objectstatic->id=$objp->askpricesupplierid; $objectstatic->ref=$objp->ref; print ''; @@ -353,11 +353,11 @@ if ($result) print ''; print ''; diff --git a/htdocs/core/class/html.formaskpricesupplier.class.php b/htdocs/core/class/html.formaskpricesupplier.class.php new file mode 100644 index 00000000000..ba7a6d8fee4 --- /dev/null +++ b/htdocs/core/class/html.formaskpricesupplier.class.php @@ -0,0 +1,104 @@ + + * + * 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 3 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, see . + */ + +/** + * \file htdocs/core/class/html.formpropal.class.php + * \ingroup core + * \brief File of class with all html predefined components + */ + + +/** + * Class to manage generation of HTML components for proposal management + */ +class FormAskPriceSupplier +{ + var $db; + var $error; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + /** + * Return combo list of differents status of a proposal + * Values are id of table c_propalst + * + * @param string $selected Preselected value + * @param int $short Use short labels + * @return void + */ + function selectAskPriceSupplierStatus($selected='',$short=0) + { + global $langs; + + $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst"; + $sql .= " WHERE active = 1"; + + dol_syslog(get_class($this)."::selectAskPriceSupplierStatus", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + print ''; + } + else + { + dol_print_error($this->db); + } + } + +} + diff --git a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php index 68465c20512..1662e9a45bf 100644 --- a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php +++ b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php @@ -64,7 +64,7 @@ abstract class ModelePDFAskPriceSupplier extends CommonDocGenerator /** * Classe mere des modeles de numerotation des references de propales */ -abstract class ModeleNumRefPropales +abstract class ModeleNumRefAskPriceSupplier { var $error=''; @@ -158,7 +158,7 @@ abstract class ModeleNumRefPropales * @return int 0 if KO, 1 if OK * @deprecated Use the new function generateDocument of Propal class */ -function propale_pdf_create(DoliDB $db, Propal $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) +function askpricesupplier_pdf_create(DoliDB $db, Propal $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index 92906ba7ae7..e9b4359ee85 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -250,6 +250,11 @@ class modAskPriceSupplier extends DolibarrModules /* * +DROP TABLE llx_askpricesupplier_extrafields; +DROP TABLE llx_askpricesupplierdet_extrafields; +DROP TABLE llx_askpricesupplierdet; +DROP TABLE llx_askpricesupplier; + * * CREATE TABLE IF NOT EXISTS llx_askpricesupplier ( rowid INT AUTO_INCREMENT, fk_statut INT NOT NULL, diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang index 6daa44ce0ce..c67e37dc7c5 100644 --- a/htdocs/langs/fr_FR/askpricesupplier.lang +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -80,6 +80,7 @@ ConfirmReOpenAsk=Êtes-vous sûr de vouloir réouvrir la demande de prix %s Date: Wed, 28 Jan 2015 10:33:15 +0100 Subject: [PATCH 005/120] [CORE] avancement du mercredi matin (#new_ask_price). --- .../admin/askpricesupplier_extrafields.php | 157 +++++++++++++++++ .../admin/askpricesupplierdet_extrafields.php | 159 ++++++++++++++++++ htdocs/comm/askpricesupplier.php | 2 +- htdocs/comm/askpricesupplier/apercu.php | 12 +- htdocs/comm/askpricesupplier/contact.php | 26 +-- htdocs/comm/askpricesupplier/document.php | 20 +-- htdocs/comm/askpricesupplier/info.php | 14 +- htdocs/comm/askpricesupplier/list.php | 8 +- htdocs/comm/askpricesupplier/note.php | 16 +- htdocs/comm/propal.php | 2 +- htdocs/core/lib/askpricesupplier.lib.php | 30 ++-- .../tpl/document_actions_post_headers.tpl.php | 2 +- htdocs/core/tpl/notes.tpl.php | 1 + htdocs/societe/class/societe.class.php | 2 +- 14 files changed, 384 insertions(+), 67 deletions(-) create mode 100644 htdocs/comm/admin/askpricesupplier_extrafields.php create mode 100644 htdocs/comm/admin/askpricesupplierdet_extrafields.php diff --git a/htdocs/comm/admin/askpricesupplier_extrafields.php b/htdocs/comm/admin/askpricesupplier_extrafields.php new file mode 100644 index 00000000000..fa0bd058f0f --- /dev/null +++ b/htdocs/comm/admin/askpricesupplier_extrafields.php @@ -0,0 +1,157 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/admin/propal_extrafields.php + * \ingroup propal + * \brief Page to setup extra fields of third party + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("companies"); +$langs->load("admin"); +$langs->load('askpricesupplier'); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='askpricesupplier'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Proposals"); + + +llxHeader('',$langs->trans("AskPriceSupplierSetup")); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("AskPriceSupplierSetup"),$linkback,'setup'); + + +$head = propal_admin_prepare_head(); + +dol_fiche_head($head, 'attributes', $langs->trans("CommRequests"), 0, 'askpricesupplier'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print "
'; - if ($objp->fk_statut == 1 && $db->jdate($objp->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + if ($objp->fk_statut == 1 && $db->jdate($objp->dfv) < ($now - $conf->askpricesupplier->cloture->warning_delay)) print img_warning($langs->trans("Late")); if (! empty($objp->note_private)) { print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; + print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; print ''; } print '
"; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; + // $i++; +} + +print "
'.$langs->trans("Position").''.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print ''; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel + /* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/comm/admin/askpricesupplierdet_extrafields.php b/htdocs/comm/admin/askpricesupplierdet_extrafields.php new file mode 100644 index 00000000000..85647950276 --- /dev/null +++ b/htdocs/comm/admin/askpricesupplierdet_extrafields.php @@ -0,0 +1,159 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013 Florian Henry + * + * 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 3 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, see . + */ + +/** + * \file htdocs/comm/admin/propaldet_extrafields.php + * \ingroup order + * \brief Page to setup extra fields of order + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + + +if (!$user->admin) + accessforbidden(); + +$langs->load("admin"); +$langs->load("other"); +$langs->load("askpricesupplier"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); + +$elementtype='askpricesupplierdet'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("CommRequests"); + +llxHeader('',$langs->trans("AskPriceSupplierSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("AskPriceSupplierSetup"),$linkback,'setup'); + +$head = propal_admin_prepare_head(); + +dol_fiche_head($head, 'attributeslines', $langs->trans("CommRequests"), 0, 'askpricesupplier'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; +} + +print "
'.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index bd694f4a925..1cdd560bb49 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -1190,7 +1190,7 @@ llxHeader('', $langs->trans('CommRequests'), 'EN:Commercial_Proposals|FR:Proposi $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -$formpropal = new FormPropal($db); +$formaskpricesupplier = new FormAskPriceSupplier($db); $companystatic = new Societe($db); $now = dol_now(); diff --git a/htdocs/comm/askpricesupplier/apercu.php b/htdocs/comm/askpricesupplier/apercu.php index 87281e7ea63..a434bca9354 100644 --- a/htdocs/comm/askpricesupplier/apercu.php +++ b/htdocs/comm/askpricesupplier/apercu.php @@ -27,11 +27,11 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -$langs->load('propal'); +$langs->load('askpricesupplier'); $langs->load("bills"); $langs->load('compta'); @@ -40,7 +40,7 @@ $socid=0; $id = GETPOST('id','int'); $ref = GETPOST("ref"); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'propal', $id); +$result = restrictedArea($user, 'askpricesupplier', $id); /* @@ -52,7 +52,7 @@ llxHeader(); if ($id > 0 || ! empty($ref)) { - $object = new Propal($db); + $object = new AskPriceSupplier($db); if ($object->fetch($id,$ref) > 0) { @@ -60,7 +60,7 @@ if ($id > 0 || ! empty($ref)) $soc->fetch($object->socid); $head = propal_prepare_head($object); - dol_fiche_head($head, 'preview', $langs->trans('Proposal'), 0, 'propal'); + dol_fiche_head($head, 'preview', $langs->trans('CommRequest'), 0, 'askpricesupplier'); /* diff --git a/htdocs/comm/askpricesupplier/contact.php b/htdocs/comm/askpricesupplier/contact.php index 6a0a1076e62..7ebb852d9bb 100644 --- a/htdocs/comm/askpricesupplier/contact.php +++ b/htdocs/comm/askpricesupplier/contact.php @@ -25,9 +25,9 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -43,9 +43,9 @@ $action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'propal', $id); +$result = restrictedArea($user, 'askpricesupplier', $id); -$object = new Propal($db); +$object = new AskPriceSupplier($db); // Load object if ($id > 0 || ! empty($ref)) @@ -69,7 +69,7 @@ if (! $error) } else { - header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); + header('Location: '.DOL_URL_ROOT.'/comm/askpricesupplier/list.php'); exit; } @@ -78,7 +78,7 @@ else * Ajout d'un nouveau contact */ -if ($action == 'addcontact' && $user->rights->propale->creer) +if ($action == 'addcontact' && $user->rights->askpricesupplier->creer) { if ($object->id > 0) { @@ -106,7 +106,7 @@ if ($action == 'addcontact' && $user->rights->propale->creer) } // Bascule du statut d'un contact -else if ($action == 'swapstatut' && $user->rights->propale->creer) +else if ($action == 'swapstatut' && $user->rights->askpricesupplier->creer) { if ($object->id > 0) { @@ -115,7 +115,7 @@ else if ($action == 'swapstatut' && $user->rights->propale->creer) } // Efface un contact -else if ($action == 'deletecontact' && $user->rights->propale->creer) +else if ($action == 'deletecontact' && $user->rights->askpricesupplier->creer) { $result = $object->delete_contact($lineid); @@ -130,7 +130,7 @@ else if ($action == 'deletecontact' && $user->rights->propale->creer) } } -else if ($action == 'setaddress' && $user->rights->propale->creer) +else if ($action == 'setaddress' && $user->rights->askpricesupplier->creer) { $result=$object->setDeliveryAddress($_POST['fk_address']); if ($result < 0) dol_print_error($db,$object->error); @@ -141,7 +141,7 @@ else if ($action == 'setaddress' && $user->rights->propale->creer) * View */ -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); +llxHeader('',$langs->trans('CommRequest'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); $form = new Form($db); $formcompany= new FormCompany($db); @@ -150,14 +150,14 @@ $formother = new FormOther($db); if ($object->id > 0) { $head = propal_prepare_head($object); - dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal'); + dol_fiche_head($head, 'contact', $langs->trans("CommRequest"), 0, 'askpricesupplier'); /* * Propal synthese pour rappel */ print ''; - $linkback=''.$langs->trans("BackToList").''; + $linkback=''.$langs->trans("BackToList").''; // Ref print '
'.$langs->trans('Ref').''; @@ -194,7 +194,7 @@ if ($object->id > 0) if ($action == 'editdelivery_address') { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id); + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','askpricesupplier',$object->id); } else { diff --git a/htdocs/comm/askpricesupplier/document.php b/htdocs/comm/askpricesupplier/document.php index d224c20bc97..5dd239e1cfa 100644 --- a/htdocs/comm/askpricesupplier/document.php +++ b/htdocs/comm/askpricesupplier/document.php @@ -26,8 +26,8 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -47,7 +47,7 @@ if (! empty($user->societe_id)) $action=''; $socid = $user->societe_id; } -$result = restrictedArea($user, 'propal', $id); +$result = restrictedArea($user, 'askpricesupplier', $id); // Get parameters $sortfield = GETPOST("sortfield",'alpha'); @@ -60,12 +60,12 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; -$object = new Propal($db); +$object = new AskPriceSupplier($db); $object->fetch($id,$ref); if ($object->id > 0) { $object->fetch_thirdparty(); - $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->askpricesupplier->dir_output.'/'.dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; } @@ -79,7 +79,7 @@ if ($object->id > 0) * View */ -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); +llxHeader('',$langs->trans('CommRequest'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); $form = new Form($db); @@ -88,7 +88,7 @@ if ($object->id > 0) $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); $head = propal_prepare_head($object); - dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal'); + dol_fiche_head($head, 'document', $langs->trans('CommRequest'), 0, 'askpricesupplier'); // Construit liste des fichiers $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); @@ -101,7 +101,7 @@ if ($object->id > 0) print ''; - $linkback=''.$langs->trans("BackToList").''; + $linkback=''.$langs->trans("BackToList").''; // Ref print ''; print ''; print '
'.$langs->trans('Ref').''; @@ -130,8 +130,8 @@ if ($object->id > 0) print ''; - $modulepart = 'propal'; - $permission = $user->rights->propal->creer; + $modulepart = 'askpricesupplier'; + $permission = $user->rights->askpricesupplier->creer; $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } diff --git a/htdocs/comm/askpricesupplier/info.php b/htdocs/comm/askpricesupplier/info.php index d3a3899537b..caa9f21dd1e 100644 --- a/htdocs/comm/askpricesupplier/info.php +++ b/htdocs/comm/askpricesupplier/info.php @@ -25,10 +25,10 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php'; -$langs->load('propal'); +$langs->load('askpricesupplier'); $langs->load('compta'); $id=GETPOST('id','int'); @@ -36,21 +36,21 @@ $socid=GETPOST('socid','int'); // Security check if (! empty($user->societe_id)) $socid=$user->societe_id; -$result = restrictedArea($user, 'propal', $id); +$result = restrictedArea($user, 'askpricesupplier', $id); /* * View */ -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); +llxHeader('',$langs->trans('CommRequest'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); -$object = new Propal($db); +$object = new AskPriceSupplier($db); $object->fetch($id); $object->fetch_thirdparty(); $head = propal_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans('Proposal'), 0, 'propal'); +dol_fiche_head($head, 'info', $langs->trans('CommRequest'), 0, 'askpricesupplier'); $object->info($object->id); diff --git a/htdocs/comm/askpricesupplier/list.php b/htdocs/comm/askpricesupplier/list.php index 948482fe4cd..47eb078d401 100644 --- a/htdocs/comm/askpricesupplier/list.php +++ b/htdocs/comm/askpricesupplier/list.php @@ -126,7 +126,7 @@ llxHeader('',$langs->trans('CommRequest'),'EN:Commercial_Proposals|FR:Propositio $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -$formpropal = new FormAskPriceSupplier($db); +$formaskpricesupplier = new FormAskPriceSupplier($db); $companystatic=new Societe($db); $now=dol_now(); @@ -145,7 +145,7 @@ $limit = $conf->liste_limit; $sql = 'SELECT s.rowid, s.nom as name, s.town, s.client, s.code_client,'; -$sql.= ' p.rowid as propalid, p.note_private, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; +$sql.= ' p.rowid as askpricesupplierid, p.note_private, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= ' u.login'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'askpricesupplier as p'; @@ -322,7 +322,7 @@ if ($result) print ''; print ''; - $formpropal->selectProposalStatus($viewstatut,1); + $formaskpricesupplier->selectAskPriceSupplierStatus($viewstatut,1); print ''; @@ -366,7 +366,7 @@ if ($result) print ''; $filename=dol_sanitizeFileName($objp->ref); $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($objp->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->propalid; + $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->askpricesupplierid; print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '
'; diff --git a/htdocs/comm/askpricesupplier/note.php b/htdocs/comm/askpricesupplier/note.php index 9292684d06f..c7b430dff8e 100644 --- a/htdocs/comm/askpricesupplier/note.php +++ b/htdocs/comm/askpricesupplier/note.php @@ -26,10 +26,10 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php'; -$langs->load('propal'); +$langs->load('askpricesupplier'); $langs->load('compta'); $langs->load('bills'); @@ -39,7 +39,7 @@ $action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'propale', $id, 'propal'); +$result = restrictedArea($user, 'askpricesupplier', $id, 'askpricesupplier'); $object = new Propal($db); @@ -59,7 +59,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, /* Affichage fiche */ /******************************************************************************/ -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); +llxHeader('',$langs->trans('CommRequest'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); $form = new Form($db); @@ -75,11 +75,11 @@ if ($id > 0 || ! empty($ref)) if ( $societe->fetch($object->socid) ) { $head = propal_prepare_head($object); - dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal'); + dol_fiche_head($head, 'note', $langs->trans('CommRequest'), 0, 'askpricesupplier'); print ''; - $linkback = ''.$langs->trans('BackToList').''; + $linkback = ''.$langs->trans('BackToList').''; // Ref print ''; - print ''; - print ''; + print ''; print ''; @@ -505,7 +505,7 @@ if (! empty($conf->propal->enabled)) print ''; - print ''; + print ''; print ''; diff --git a/htdocs/core/modules/askpricesupplier/mod_propale_marbre.php b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php similarity index 95% rename from htdocs/core/modules/askpricesupplier/mod_propale_marbre.php rename to htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php index 28260de97d8..ec5164b679c 100644 --- a/htdocs/core/modules/askpricesupplier/mod_propale_marbre.php +++ b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; /** * Class to manage customer order numbering rules Marbre */ -class mod_propale_marbre extends ModeleNumRefPropales +class mod_askpricesupplier_marbre extends ModeleNumRefAskPriceSupplier { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $prefix='PR'; @@ -74,7 +74,7 @@ class mod_propale_marbre extends ModeleNumRefPropales $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal"; + $sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; @@ -111,7 +111,7 @@ class mod_propale_marbre extends ModeleNumRefPropales // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL - $sql.= " FROM ".MAIN_DB_PREFIX."propal"; + $sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier"; $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; $sql.= " AND entity = ".$conf->entity; diff --git a/htdocs/core/modules/askpricesupplier/mod_propale_saphir.php b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_saphir.php similarity index 84% rename from htdocs/core/modules/askpricesupplier/mod_propale_saphir.php rename to htdocs/core/modules/askpricesupplier/mod_askpricesupplier_saphir.php index 503d8754684..9bfffcee262 100644 --- a/htdocs/core/modules/askpricesupplier/mod_propale_saphir.php +++ b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_saphir.php @@ -25,13 +25,13 @@ * \brief File that contains the numbering module rules Saphir */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_propale.php'; /** * Class of file that contains the numbering module rules Saphir */ -class mod_propale_saphir extends ModeleNumRefPropales +class mod_propale_saphir extends ModeleNumRefAskPriceSupplier { var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' var $error = ''; @@ -55,18 +55,18 @@ class mod_propale_saphir extends ModeleNumRefPropales $texte.= ''; $texte.= ''; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= '
'.$langs->trans('Ref').''; @@ -122,7 +122,7 @@ if ($id > 0 || ! empty($ref)) // Date fin propal print '
'.$langs->trans('DateEndPropal').''; + print ''.$langs->trans('DateEndAsk').''; if ($object->fin_validite) { print dol_print_date($object->fin_validite,'daytext'); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 35807912c0a..a3fcfa22bc8 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -488,7 +488,7 @@ if (empty($reshook)) setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); } } - + if (! $error) { $db->commit(); diff --git a/htdocs/core/lib/askpricesupplier.lib.php b/htdocs/core/lib/askpricesupplier.lib.php index fd227d512b7..b0b9369f6ee 100644 --- a/htdocs/core/lib/askpricesupplier.lib.php +++ b/htdocs/core/lib/askpricesupplier.lib.php @@ -32,13 +32,13 @@ function propal_prepare_head($object) { global $langs, $conf, $user; - $langs->load("propal"); + $langs->load("askpricesupplier"); $langs->load("compta"); $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier.php?id='.$object->id; $head[$h][1] = $langs->trans('ProposalCard'); $head[$h][2] = 'comm'; $h++; @@ -47,7 +47,7 @@ function propal_prepare_head($object) || (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) { $langs->load("sendings"); - $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/expedition/askpricesupplier.php?id='.$object->id; if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); $head[$h][1] = $text; @@ -56,7 +56,7 @@ function propal_prepare_head($object) } if (! empty($conf->global->MAIN_USE_PREVIEW_TABS)) { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/apercu.php?id='.$object->id; $head[$h][1] = $langs->trans("Preview"); $head[$h][2] = 'preview'; $h++; @@ -64,7 +64,7 @@ function propal_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][2] = 'contact'; $h++; @@ -74,14 +74,14 @@ function propal_prepare_head($object) // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'propal'); + complete_head_from_modules($conf,$langs,$object,$head,$h,'askpricesupplier'); if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; if(!empty($object->note_private)) $nbNote++; if(!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; $head[$h][2] = 'note'; @@ -91,18 +91,18 @@ function propal_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); if($nbFiles > 0) $head[$h][1].= ' '.$nbFiles.''; $head[$h][2] = 'document'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/info.php?id='.$object->id; $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; - complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove'); + complete_head_from_modules($conf,$langs,$object,$head,$h,'askpricesupplier','remove'); return $head; } @@ -119,7 +119,7 @@ function propal_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/admin/propal.php'; + $head[$h][0] = DOL_URL_ROOT.'/admin/askpricesupplier.php'; $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; $h++; @@ -128,19 +128,19 @@ function propal_admin_prepare_head() // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin'); + complete_head_from_modules($conf,$langs,null,$head,$h,'askpricesupplier_admin'); - $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/comm/admin/askpricesupplier_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT.'/comm/admin/askpricesupplierdet_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsLines"); $head[$h][2] = 'attributeslines'; $h++; - complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove'); + complete_head_from_modules($conf,$langs,null,$head,$h,'askpricesupplier_admin','remove'); return $head; } diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index d1a1cedca61..b53e9cbd073 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -46,7 +46,7 @@ $savingdocmask=''; if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) { //var_dump($modulepart); - if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','ficheinter','contract','project','project_task'))) + if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal', 'askpricesupplier','ficheinter','contract','project','project_task'))) { $savingdocmask=$object->ref.'___file__'; } diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 66b310da69d..5773d7ce9d8 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -50,6 +50,7 @@ if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) // Special cases if ($module == 'propal') { $permission=$user->rights->propale->creer;} +elseif ($module == 'askpricesupplier') { $permission=$user->rights->askpricesupplier->creer;} elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;} elseif ($module == 'project') { $permission=$user->rights->projet->creer;} elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;} diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 4ce603ee1ad..5b4f57ae6a4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -42,7 +42,7 @@ class Societe extends CommonObject public $element='societe'; public $table_element = 'societe'; public $fk_element='fk_soc'; - protected $childtables=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur"); // To test if we can delete object + protected $childtables=array("askpricesupplier", "propal","commande","facture","contrat","facture_fourn","commande_fournisseur"); // To test if we can delete object /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe From 778ddf269d660c8a77ccb457d7e1f53ee98483b3 Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 14:32:41 +0100 Subject: [PATCH 006/120] =?UTF-8?q?[CORE]=20maj=20des=20r=C3=A9f=C3=A9renc?= =?UTF-8?q?es=20de=20traductions=20(#new=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/langs/fr_FR/admin.lang | 1 + htdocs/langs/fr_FR/askpricesupplier.lang | 6 +++--- htdocs/langs/fr_FR/other.lang | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 4e783fafce1..e8c8f6dd1a2 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -264,6 +264,7 @@ MAIN_MAIL_EMAIL_FROM=Adresse email de l'émetteur pour l'envoi d'emails automati MAIN_MAIL_ERRORS_TO=Adresse email utilisée pour les retours d'erreurs des emails envoyés MAIN_MAIL_AUTOCOPY_TO= Envoyer systématiquement une copie cachée des emails envoyés à MAIN_MAIL_AUTOCOPY_PROPOSAL_TO= Envoyer systématiquement une copie cachée des propositions envoyées par email à +MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO= Envoyer systématiquement une copie cachée des demandes de prix envoyées par email à MAIN_MAIL_AUTOCOPY_ORDER_TO= Envoyer systématiquement une copie cachée des commandes envoyées par emails à MAIN_MAIL_AUTOCOPY_INVOICE_TO= Envoyer systématiquement une copie cachée des factures envoyées par email à MAIN_DISABLE_ALL_MAILS=Désactiver globalement tout envoi d'emails (pour mode test ou démos) diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang index c67e37dc7c5..863d3749dca 100644 --- a/htdocs/langs/fr_FR/askpricesupplier.lang +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -22,7 +22,7 @@ NewPropal=Nouvelle proposition Prospect=Prospect ProspectList=Liste des prospects ConfirmDeleteProp=Êtes-vous sûr de vouloir effacer cette proposition commerciale ? -ConfirmValidateProp=Êtes-vous sûr de vouloir valider cette proposition commerciale sous la référence %s ? + LastPropals=Les %s dernières propales LastClosedProposals=Les %s dernières propositions commerciales fermées LastModifiedProposals=Les %s dernières propositions commerciales modifiées @@ -36,7 +36,6 @@ NbOfProposals=Nombre de propositions commerciales # # Ajout -ShowAskpricesupplier=Afficher demande CommRequest=Demande de prix CommRequests=Demandes de prix SearchRequest=Rechercher une demande @@ -47,6 +46,7 @@ AskPriceSupplierArea=Espace des demandes de prix fournisseurs NewAskPrice=Nouvelle demande de prix NewAsk=Nouvelle demande # # Modifié +ConfirmValidateAsk=Êtes-vous sûr de vouloir valider cette demande de prix sous la référence %s ? DateAsk=Date de demande DateEndAsk=Date de fin de validité DateEndAskShort=Date de fin @@ -86,11 +86,11 @@ ListOfAskPriceSupplier=Liste des devis/propositions commerciales TypeContact_askpricesupplier_internal_SALESREPFOLL=Commercial suivi demande TypeContact_askpricesupplier_external_BILLING=Contact client facturation demande TypeContact_askpricesupplier_external_CUSTOMER=Contact client suivi demande +ActionsOnAskPriceSupplier=Événements sur la demande # # -ActionsOnPropal=Événements sur la proposition NoOpenedPropals=Pas de proposition ouverte NoOtherOpenedPropals=Pas d'autre proposition brouillon RefProposal=Réf. proposition commerciale diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 1c23cce68cb..972fc5425fd 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -60,6 +60,7 @@ PredefinedMailTestHtml=Ceci est un message de test (le mot test doit êtr PredefinedMailContentSendInvoice=__CONTACTCIVNAME__\n\nVeuillez trouver ci-joint la facture __FACREF__\n\n__PERSONALIZED__Cordialement\n\n__SIGNATURE__ PredefinedMailContentSendInvoiceReminder=__CONTACTCIVNAME__ \n\nNous voudrions porter à votre connaissance que la facture __FACREF__ ne semble pas avoir été réglée. La voici donc, pour rappel, en pièce jointe.\n\n__PERSONALIZED__Cordialement\n\n__SIGNATURE__ PredefinedMailContentSendProposal=__CONTACTCIVNAME__\n\nVeuillez trouver ci-joint la proposition commerciale __PROPREF__\n\n__PERSONALIZED__Cordialement\n\n__SIGNATURE__ +PredefinedMailContentSendAskPriceSupplier=__CONTACTCIVNAME__\n\nVeuillez trouver ci-joint la demande commerciale __ASKREF__\n\n__PERSONALIZED__Cordialement\n\n__SIGNATURE__ PredefinedMailContentSendOrder=__CONTACTCIVNAME__\n\nVeuillez trouver ci-joint la commande __ORDERREF__\n\n__PERSONALIZED__Cordialement\n\n__SIGNATURE__ PredefinedMailContentSendSupplierOrder=__CONTACTCIVNAME__\n\nVeuillez trouver ci-joint notre commande __ORDERREF__\n\n__PERSONALIZED__Cordialement\n\n__SIGNATURE__ PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nVeuillez trouver ci-joint la facture __FACREF__\n\n__PERSONALIZED__Cordialement\n\n__SIGNATURE__ From ec621244f39302befb2c588dde94fdc7f4814cf1 Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 14:34:27 +0100 Subject: [PATCH 007/120] =?UTF-8?q?[CORE]=20ajouts=20des=20conditions=20sp?= =?UTF-8?q?=C3=A9cifiques=20pour=20les=20appels=20depuis=20l'objet=20AskPr?= =?UTF-8?q?iceSupplier=20(#new=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/class/commonobject.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dc39692f08e..e035d0342c2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1768,7 +1768,7 @@ abstract class CommonObject // Specific code for backward compatibility with old field names if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht='total'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; - if ($this->element == 'propal') $fieldttc='total'; + if ($this->element == 'propal' || $this->element == 'askpricesupplier') $fieldttc='total'; if (empty($nodatabaseupdate)) { @@ -1958,6 +1958,9 @@ abstract class CommonObject else if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } + else if ($objecttype == 'askpricesupplier') { + $classpath = 'comm/askpricesupplier/class'; + } else if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; } @@ -2473,6 +2476,10 @@ abstract class CommonObject $tplpath = 'comm/'.$element; if (empty($conf->propal->enabled)) continue; // Do not show if module disabled } + else if ($objecttype == 'askpricesupplier') { + $tplpath = 'comm/'.$element; + if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled + } else if ($objecttype == 'shipping') { $tplpath = 'expedition'; if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled From a9d26efee8ae3aec9cdc57c34b12f6e896a65b93 Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 14:44:48 +0100 Subject: [PATCH 008/120] [CORE] ajout des conditions pour un element de type askpricesupplier (#new_ask_price). --- htdocs/core/class/html.formactions.class.php | 1 + htdocs/core/class/html.formmail.class.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 333969fc3b3..cfab0e52b7c 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -171,6 +171,7 @@ class FormActions if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); + elseif ($typeelement == 'askpricesupplier') $title=$langs->trans('ActionsOnAskPriceSupplier'); elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 07edb962371..118bb0462b6 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -477,6 +477,7 @@ class FormMail $showinfobcc=''; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; + if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'askpricesupplier_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; if ($showinfobcc) $out.=' + '.$showinfobcc; @@ -496,6 +497,7 @@ class FormMail { $defaultvaluefordeliveryreceipt=0; if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt=1; + if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ASKPRICESUPPLIER) && ! empty($this->param['models']) && $this->param['models'] == 'askpricesupplier_send') $defaultvaluefordeliveryreceipt=1; if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt=1; if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1; $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:$defaultvaluefordeliveryreceipt), 1); @@ -718,6 +720,7 @@ class FormMail if ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } elseif ($type_template=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($type_template=='askpricesupplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendAskPriceSupplier"); } elseif ($type_template=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); } elseif ($type_template=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } elseif ($type_template=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } From 3644f4c84cd2dfed1f7a41eef1c3ca2a86ee6752 Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 14:48:59 +0100 Subject: [PATCH 009/120] [CORE] renomage de masse (#new_ask_price). --- htdocs/comm/askpricesupplier.php | 10 +++++----- .../class/askpricesupplier.class.php | 4 ++-- htdocs/comm/askpricesupplier/index.php | 4 ++-- ...bre.php => mod_askpricesupplier_marbre.php} | 6 +++--- ...hir.php => mod_askpricesupplier_saphir.php} | 18 +++++++++--------- .../modules_askpricesupplier.php | 4 ++-- .../core/modules/modAskPriceSupplier.class.php | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) rename htdocs/core/modules/askpricesupplier/{mod_propale_marbre.php => mod_askpricesupplier_marbre.php} (95%) rename htdocs/core/modules/askpricesupplier/{mod_propale_saphir.php => mod_askpricesupplier_saphir.php} (84%) diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index 1cdd560bb49..855f84a72d8 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -33,7 +33,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formpropal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaskpricesupplier.class.php'; require_once DOL_DOCUMENT_ROOT . '/comm/askpricesupplier/class/askpricesupplier.class.php'; require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/modules/askpricesupplier/modules_askpricesupplier.php'; @@ -1497,8 +1497,8 @@ if ($action == 'create') $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); - $propalRefAndSocName = $row [1] . " - " . $row [2]; - $liste_ask [$row [0]] = $propalRefAndSocName; + $askPriceSupplierRefAndSocName = $row [1] . " - " . $row [2]; + $liste_ask [$row [0]] = $askPriceSupplierRefAndSocName; $i ++; } print $form->selectarray("copie_askpricesupplier", $liste_ask, 0); @@ -1579,7 +1579,7 @@ if ($action == 'create') $soc->fetch($object->socid); $head = propal_prepare_head($object); - dol_fiche_head($head, 'comm', $langs->trans('CommRequest'), 0, 'CommRequest'); + dol_fiche_head($head, 'comm', $langs->trans('CommRequest'), 0, 'askpricesupplier'); $formconfirm = ''; @@ -2308,7 +2308,7 @@ if ($action == 'create') // Tableau des parametres complementaires $formmail->param['action'] = 'send'; - $formmail->param['models'] = 'propal_send'; + $formmail->param['models'] = 'askpricesupplier_send'; $formmail->param['id'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; // Init list of files diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php index b2c7fc4dfb2..2deb897a192 100644 --- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php +++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php @@ -1093,7 +1093,7 @@ class AskPriceSupplier extends CommonObject $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."askpricesupplier as p"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; @@ -2664,7 +2664,7 @@ class AskPriceSupplier extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->lines[$i] = new PropaleLigne($this->db); + $this->lines[$i] = new AskPriceSupplierLigne($this->db); $this->lines[$i]->id = $obj->rowid; // for backward compatibility $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->label = $obj->custom_label; diff --git a/htdocs/comm/askpricesupplier/index.php b/htdocs/comm/askpricesupplier/index.php index dcd3436bd25..ef9a37f145c 100644 --- a/htdocs/comm/askpricesupplier/index.php +++ b/htdocs/comm/askpricesupplier/index.php @@ -433,7 +433,7 @@ if (! empty($conf->propal->enabled)) print ''.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).''.img_object($langs->trans("ShowAskPriceSupplier"),"askpricesupplier").' '.dol_trunc($obj->name,24).''.$askpricesupplierstatic->LibStatut($obj->fk_statut,$obj->facture,5).''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''.img_object($langs->trans("ShowAskPriceSupplier"),"askpricesupplier").' '.$obj->name.''.$askpricesupplierstatic->LibStatut($obj->fk_statut,$obj->facture,5).'
'; - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal")); + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest")); $tooltip.=$langs->trans("GenericMaskCodes2"); $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal")); + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest")); $tooltip.=$langs->trans("GenericMaskCodes5"); // Parametrage du prefix $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; @@ -106,14 +106,14 @@ class mod_propale_saphir extends ModeleNumRefPropales * @param Propal $propal Object commercial proposal * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc,$propal) + function getNextValue($objsoc,$askpricesupplier) { global $db,$conf; require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask=$conf->global->PROPALE_SAPHIR_MASK; + $mask=$conf->global->ASKPRICESUPPLIER_SAPHIR_MASK; if (! $mask) { @@ -121,7 +121,7 @@ class mod_propale_saphir extends ModeleNumRefPropales return 0; } - $date=$propal->datep; + $date=$askpricesupplier->datep; $customercode=$objsoc->code_client; $numFinal=get_next_value($db,$mask,'propal','ref','',$customercode,$date); diff --git a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php index 1662e9a45bf..b9efd387da5 100644 --- a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php +++ b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php @@ -86,7 +86,7 @@ abstract class ModeleNumRefAskPriceSupplier function info() { global $langs; - $langs->load("propale"); + $langs->load("askpricesupplier"); return $langs->trans("NoDescription"); } @@ -98,7 +98,7 @@ abstract class ModeleNumRefAskPriceSupplier function getExample() { global $langs; - $langs->load("propale"); + $langs->load("askpricesupplier"); return $langs->trans("NoExample"); } diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index e9b4359ee85..f0cf2a7a40f 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -82,7 +82,7 @@ class modAskPriceSupplier extends DolibarrModules $this->const[$r][0] = "ASKPRICESUPPLIER_ADDON"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "mod_propale_marbre"; + $this->const[$r][2] = "mod_askpricesupplier_marbre"; $this->const[$r][3] = 'Nom du gestionnaire de numerotation des demandes de prix fournisseurs'; $this->const[$r][4] = 0; $r++; From d134fa6a323b3bffaadf6cdf0f800f4b2d70fa78 Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 15:33:52 +0100 Subject: [PATCH 010/120] [CORE] copie du odt propal pour le module askpricesupplier (#new_ask_price). --- .../doctemplates/askpricesupplier/index.html | 0 .../askpricesupplier/template_proposal.odt | Bin 0 -> 25866 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/install/doctemplates/askpricesupplier/index.html create mode 100644 htdocs/install/doctemplates/askpricesupplier/template_proposal.odt diff --git a/htdocs/install/doctemplates/askpricesupplier/index.html b/htdocs/install/doctemplates/askpricesupplier/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/install/doctemplates/askpricesupplier/template_proposal.odt b/htdocs/install/doctemplates/askpricesupplier/template_proposal.odt new file mode 100644 index 0000000000000000000000000000000000000000..8ece83c989c9ff688337dbb0edf6febd47eb0dcf GIT binary patch literal 25866 zcmbTc1yo$i@-K|LLvVL@cXx-NfdIqcFu1#0aF^f?!QCOaLxKl)cbCUG_n!Oi`(&-} z|IJ!^rgzn^OS)@U@9r8^1xP3?FfceUurKab;)a9lNHkzzV1Hd7Brsb`TcERtJ}(0LV{x@JWd<2LSvoO;?16TsAb^W4(9W6J8R+h;`hN(EwSNsVhXMop>-t+5 z(Ak*T-PT4>nAx?;#jhU646lezknOfSJ3z2`;lxE^37ZFAf1euvx0)YJg zXkhv<#hCP?tDO`7zgR-#E{=Bmf7`-uXKV{};&%q{|F=>6|BdGVThYHL?lzWo)~R%pgZ|7B)UUK9;|^3iuDs-o?@8Z?SLQhL5{+TmL`rsmA`|5g@c)kQqj`R#r>-eFZWk&PSXEkezkW5Spfmg zEF4^{wrrH*E|xZ?O#kTk-{Ssq72pW`muO=b$B$Vg{oBQVi2u_6pRjXs{_xVt*%Cnd zw{OnICN@AO0LaD8`6G78|3$R4H8%eb@gto7MuJTKvgRM?KUDkwLbCrGX>aUkZ0=}m zZ}AV9jg|M`EH{v&=|5Bs9*hQnvpYoc(_W=lGw& zIsbzH`)T0+Yn=c0-G8R+Z}PvA5gZ)c-R3^wDwxI{y{KPJbn&PCX^3Enc+F z^J>{gWm#G3OjUS|P$UjT*<61`t9|Mdn1=Y@%yK9f=OsYMOz13NbR!LdpR+=h@2ert zs;{Bs)(&#g9_@L@^&H1Jl&L>i>YTv2$FCn>ymAQqR<}(1AWOq=DbZy$W{i-8@>LF8 z%8r*#1z6PTVicVWQW+r(c*KYRamNcs=Q%%0ChHgwdv}ksc{r$lXjfc6zBv0jL|W+y zb+@*b6}v6O!qC!qdzMz59NzyxbJ!m4iesX7(Gn17uQXflO#Ds09#Xu=HSeGU>UL;% zjPucK2^b#SGj&;FKAogUz2!l3AO>)yw?f;GSZr*L2y;uNZ_m_3nA1yZ} zLc1nJ%dmptii)xAXg^5d?9;EVr!PKbp+in+U=+w`D@zP#+f|)WB&t!j{Y+g8-mBS=yywzo`v~VNh(Rk53 zvS=@i4beiW3lG1z30yajg`5HS@^iz9kUh~We1OQ=IrW>^YBg4J5R{*(*}N$}KIve0y_EHyxx}B41K7i^IhVc zX>XN=%|u{oV9D2(bRqV1))`8syCZsg3Z1krBk*z6;2ML+QTyx4JR0$RylL%H0DWDM z+Cl^(r)kGGtIU|OnlIh< zQ3jeF1B2GGR>|R9TJl;5TmAmoWCi>xY-ssBdsSie>vebBzy=+snUe!p)!But5npo1 z#F|+7UkL=t9%{8cT{&*;JX4=W)a1xdkR3mzKU__mkX3dIFG-+fA=4IEBq?Xb!+#IKM zfc+q?gd@dN*kY}9%higolG zn5a;k0$ZV`s?weq+yBWHF@&@cp3YKVN4JJ=Y^1a3jK}Ryy1eG}o;<wUVJ%;L>6zT|?{60eYCF^r`^;9B zgi%y^+Dm7X5#KN84rNk|DPfs7iz$W7+9=w;w4+T=If}(VJisGF(7pvx#2j)g5xflh zVw{Ymh@Nh}%thPP52$^j=Q7c_r6~J)R9Np#V_>@JKZ#MaNcRLBc&wNhM{TKiI9hR? zJ#Z8~Ml44=q?UDUOhXb)I{#_*q8$Ke!h_PE*$O;r4pqK$3XedD1Q^Z5=nXmziQ+Xb zyUwHT?<|ENnUaRjBfHjI^pLem1+Qpa#5$(1vCT-MK z^8|5!g`w0S^H#elwTc2RXMU3FUd_oW7w|hO-Fy90bcv{{01L+lcgboG4F<+a0S5N} zo~aQ(GBp5X=ls_T=0~DF{qkx@(2D-vty23NT&j9lKE?Fe=Jq6LJJt|Pz!kH|LJbR| zaV$CQg!x|f2had5S7i?NIMI3db=p^sT-$Z)3qF*xEARETJ#QACfpYC*#&IvaVg6HlHeaTJ4_?_Wxi99t+c1?4bz`e zI*fkhx5&7JkhFljuqufqW#b~TQH9|}vYhwCB?}BewK~o?{mj66!}o`WmJ&UuknAj$ z$n@%#FC}3oZ6yN!lxy4=@d& zcY*ctdhXn5?de<`?lO`z(lT=6t`it`bBvnH9kJ+HI0p~=c3zaZ7sGe%Py1Q2(&NwQ3{m}?-n1DutiE%JwoQugXg9Op5z6eR`6jLm>&)C) zXx!u8ZBY3ZU2C_m=SUJCk`t?TbdP*y@q#8-J-^}16X5680K|Gmbs)D`RQUZw(RclR zTu}Xt`5c(?a)%UV1gE3LIH2z!DaniGeuhqAmExKCSpbr|TP!cStIN8JH0yl!*5w2Z zM;D|vT;)ahh3)NO+RJjXO~mjlk7-6>8vhUgcDp6k`HT1i!V2Ky%M| zTc6J$n%|OhpH`kxIj^WJw1i%XGY$prrZ9}SHR}CaR}T&?Q>;eg z3A=6mhr)fO8o}_qFJbVfA`BCQ=A`fC?$bgC=K`$;cz37l{kbB%51T4X&OVO^Z76L) z1>f3;iB5@{)NWtkHHB71Rtv5CP)+;@3|NQ_7CO&nW>7PoiOx{<$~+&T%!Ke!crtI@ zr$GhBzY`BUYor#884RW}f)Y-R)~m}A3iI=ciIn26jR!3V+tf)ARwB;@ryOEp1?srO z?do*@9G?*}RL7AgwWciz-vwLoh6fLnseCzZ7rHGO9vHSku^~fth-b8DFmRO*iQ}@S z_{v?^2PW%p<__!`WXo*tOJzI9A--KQN>vl7TG5Ok_){oV{Nx(u`*w=*y0t>|wA(Cj zQ?bu>V{4;g5!tTi8HFan5t{EY4+iByUqyT(c?97_dpBTO!-Ln4;s>O6FVz;edj7nM zacr%fnPbo}24uJ{ZBTXtprHJI)FZzX-V1bB$n58Ye1Tx}o4t&iLd;w_N&{zAxOJo# ztk&R>IGu(F*1U$GA!aM;(oaypxA_T=u)s4Gq(>rBi1cJe?5jmn8e{l%>XoJ3Tv#FU zx=;d&_nSsWSmC;J%6!xQT$1Af!Nx{9uK!EqZVDB~?hH5|fwvPt*ztFz$XWkB&)HD| zG9BVhts&qy3oe33ety@$sI_qay3MST7@5>`^AqaS)DbizD~p*hyh9W5XM`{P31@Y? z5$pId&c&LsNALJ*OGZx_z+0Lr)_jszza#wOv$FX;^Y5$M)z*&Jqm68azFadk-S_(J z&mdZ*Tak0(!BYO={l4)f1((8BIR;>Hs}zaL`Yq?}JcvI3zWW44amb+AW9J9+{g*q} zh%w|Q=B=S|7s&oy5WZvPWkup`i&*P#tNw4$Jn-ac`R2}Omc*e^=@deWK2?dejt9P zAzE}P+xz*m+FN8#bsb*3e~%ccXK+cX_K#{|>pJ_*JgK0`uh|CrZXmmJyY=q|CDSu74aUL=#agtp%0o_l zOb=1w$9E=3iW_;dMhxxR)&WkfDY+?al{ETBo%Z;r_Br6`jxqv&`b3J{&BvZ^$oJLM7ph-X5L2Y^nCPeAnhg#fiapdI=||n zG8`1f<7=>g-dE8z;lg)-uZ!eN!ILo$}6Qp}p5 z6&jBPz};y>ax#>bj~F!SPAEl!f&!q4;TYpdsYe?VF8U)hF;Wys60w$+99dv`;5DPG zH>PbnlHr)btH$e*a~(A26J)Yx^zW5L7t0Qc5_{72gZ1JPv9Q=jE5@_4nMG7suEzaG1v|+{tU4iJ5Gho#?TK$&gg+* z>J3#g>Q6CxRx*0tL*zggv=A4th;m&FcC`?k_M%MqYRJ&PYkFNMSuvxi&S~6cko_^w zfDrH|{;Bd*9BiEsnML$n@#3^DmpV5k|*OlB)^F@OZ8#ioz zNM&6=U%ri3Cvk)&kXo!K@ckYqR|6L`0{HUNzM% zH(h7K^u(M8Q+l)9ZnC7^_d$XL_jauBUUK+OR%;r$1mb3!<=mIhZDlEPa%$?+rK36; zGFad%$+*bS((PCIc`X*&dYo9;r=yXf`T0P(8CBH=MjHIc2-hM>0NG4=G%q71pI%Hx z8x@r3%l-QM48O+6B*v(Wolv$0BwOyPeUcWUmsL z9iaaaI6I`|b)Nzb)XYF)e0DfxuGg>oGVh{7@oux5xBYY56;F@HRPAaeX`DZ%P))Ba zLWhNFxt8ZQ1z6ecwdd_=$IMk3f)BKFZgUy#m0seii7!$Xwg;J#27SMYeKC4p`ofKMYuzxo~trdG2=8<>wNbOcyw<&3L}%uShN8E%%NI#K?bRcNcM zqWu20_6qZMrduR~9G|*JzQ0F~vq%2X(Ec3HCwEyuKQIbL)(QWIhK@Rfm?;i>tZo7(+P2M9mwCT}+-a(CFrO)#kP2UZB?Pyy^ z;4;%rz99Ue*ebbQMRFA)1Vn{8Vh&u{Dmjt|6mzC5jP95fyYEITyg@&TI=k|`+Q7sY zbuIJDo2SY)^3&N))-*q5k&(I?93|4(wEogYmOI!Av*V2Q+_#e87Tbiv$}l}rW}j&K zB0%7*>~>zTd51?&NPCZvDy*$C;xm0x_B60L_YVHo{$VK2#0~c2Ag4~}pZ&u>XV@S` z7s*)xFtEQa+>iZ(riF{GiJh^fjT4LWKTT$PJM#!tWf^1ye1s1OvYf1>`p0i07#KJh z9K=V|CiJ!bV|Z+ zf5_{8i&^uk;(sC3!ijp|2bGQLudUa^A+|A4vB8SB%8#h!gZMobX8jGC(H(^|8>-qD zDPI8mkSi_`1_2;;Nv)azZRd-M@Qx(8OB#zj`YKvOn5G=CSJHE%Y(x*T5eqa}N{-T%{888V>Vk7JRtwcA% z0FS%1t?zfJg2UOci|av;*P?&ardLp0&!9+r;K~vFaUiD;{V@;_p#7Dhm$~ip;D)*V zPv@VtivrJAM9=uaRQ;tP**JPv1bPzjdR~a#r4ZL>VRTJZJ)z+aNlDSrupzHtu_re~ zdqA)%o#4zqV3R^{hS{)PO&NBA&_A2;zFQ7 zRkdHN@&bgu29}F&>_X#eDgGzBhnhw7E+`9dCLPhDSLNCnX@1 zopcm(hAG#FY*7}BC!WMSU|RMfkcU?n$}u%SsT%xFdaRxSG0sos9_hZtFW0BH7LWqD zZeSEJ_ZTw#PSE4MbBr^;ot%;wtII;f(B$ni?69BU7eF=KJX9qz?j{&TiqQcO2ya?1 z`@`PzZW5k6YW74zy6(wtNgxYhl&H~lcVph`469G?I5Hy{6%p3!GcSDy_;G7}gp=Fj zSu^wGQgo^paJysoOa-+RGp~mRs$F^CR$tk!4)lZVdBE!XWc2QD54|Wt`UU(B6;2!1 z@16BxY>H^jE2woZk8xmA0DjEmH6KC_8`%tv`*Qeh+n3fFB?~P~UGEv<6@(>MSJ1L` zkZ!p995+N_h*ABUwO}zw&nP9y*MZAqjNC6e#!tqq+X_4TeaEveMyktVfyv3!)PMTU zMz|cfSX7%B4O73dj}t@L*-4fEe)d+JKRCPRs~@_iAjLCNkG%thK4{_wp_ENKs1mcQ zI3+Jw4VObC-$~kiGXz}Uvr)SI`YLJM(sq`bSS2zxQo;RG`_&!EbYR|K-vmr0`(ixf z;x3gXUA!-$?i%S_Ggu@QH&BqckpI@KR#@8ifMYHCg%p2)5+{?5^V|rO&~z{ds;S?y zqMvY}{HE=ln_n+6yK=v+R<9FzZ=Uc9!MR{Z=yPqlIQa;!DM%4#Vl;sE!{C_edG_~W z>l9Ga+w(af|WR?a%yWN$JU_MG1&WFnT)j77Fn6 zL|&WuN0n#ClMN7BUOW@anyq|mv@Lhn@u2RGlt7GNC_REN^TzCDSnTnujOA~Q)LR2M z`D0bcT9Ff!d=9%3V!O$op*lW9v}h2u1Jdt?zQSLwnbgX$d>Z9a#Fi&RAMW#Q57hKk zI11``o2VZ~{Qksw5tf*enjpU;*op!K_zJ(wUeZ&rxg1aSsg4W;Ewqxyhg^>^UB5UG zACe4&^0>8qfA^#6G#+zBsV)R zc3_QvqqtqDmSwN&a86DcQUgb-dzwFWrQrIR6WqV?^kDYh!pZ{BH~2JFc&ipad^DIL zJn!S+)2vqnlZ!*=({b7Ngl%I=KDWBeJXDD8fTXD6Lq+E3!H!=Gj4Ob17Rq%eSPsVe zoy{DvemZFQ!;LknhzAqT)F)N;aO`q0mv!)r-txiQ;}0JPQ&Q2nU6~f^nZlsaFmJ2+ znA@U3mVB>zP#1d9^S+I@*k7l6NHx zStOqFF!MqIyW9U}0J~l_X3!oNqIc9{+vGz@Az(}Uc{H=cPvk*S%jDhoz^U3?#9V0f z-J*5dwB~mTG>n~#(d0{MZqoQYNl(nMQDaoYzV}AQbNn6B7lXHrn$+dC@k{p%Cyk)5 z-qr(AlgMl7$GnW*n?UOoi~tVDb=h+f?nruf2L(rfgws~2j{aTWd8JMD{<5L{4ZApz^DVQG~Xny96s$Aoja=(1P_o%NhI5qt(T43pj(YmN2*`Bd45DYtU$AGs%Q7rZ#9 zpUU^-%A8#73VhuPGYRz^?zX~2@UT0sM$ICrJ4n-ARp#i)2E*aKeM>)$^Kl?`=(~Ae zv+GMKCg@gk7(2)Z;71MRE9wP}L<37E$Q!sUmKp3uF_RwbSunIivUqT3bf~@>BLyj+ ziojq#yyVg_>zNC@^j+h)Kfff;X*J<}bbD+-S9(8e&j{+vRp{q4(D^8$K)ulsJS^Ow3sWNA?>cdJCRw-jmq^3v z$jBiF7QX=qOc(A`X6m>4O*)>fin=0v=Ot}EZy(n0x?!a2p&5y6`|JMEU77JLV6oh` zDc)^)M<;m9ULI3Iz!Y)<$oJPS2P^SW6uB^1M^%s$f0w{b2v+wNa4k6X4a%)GsN}J? z)sps*7>XiQ>dX(9RrzLW6uN3+`5i4th6A?q+>eBMTBPQL7RA=iQ*l2&K}cpMk2?9_ zrHT)gIdbNct%uyr{Mr!a4AVYy(gLodD`Q+koby53sKNm7wxMq!@S)_#-7t_okN;?< z@(1YN39?*aogc5p(vngyIwOkJe`Tn8ZRW=C@wmPj+Z1YBY`oZi{(S11jq^R+NU*v~ zTTC2MomOH_tHS!nD#aBIVsfwX)>nlV%JtxJT1y~miX?f$;g-hp@qpn>!w&}Jr?e9! zKMxILC)c){(KRP;BrSE1FtkxHY2Ed29BeAUrc(heH73*Ir#w@CSqM+LYC3==XLnuM ztt=`%JH|Sb310Ot?NWDS?P_=nV===#JdfJZP<(js3hvo5C`W~4>EaXHbFl$xwwAgy zJiK%ch%;lMK1~3`Yd>X&2lRwlvjYX6Fs`tQ*hT-Q98^PF(`t`m5&CpSF$1z7x^RRY zw$>pnLP$c77JMg1P)#4ABPN23Osz=)Tpc3VpS7hS=#zBIcuKn>6l2zl=V?=9loduU zhZ<9q0TzEnvN~k(GB`|vsj6AIa7sqzaO9s#hBKRn8Oz6g>9KVJQ&f&SSJ96rDFCq( z(a4UH=CY6yNOw6WndX#6Pv+V!or0{azMh0vGybc`c$R34^)PZ*e>3X{c=D^ zk`ay3-bnnn|2vwSqjOzKfrtGZft$K zqr3XlRE-)Mel$u@R%^;=eAy&3URN%0L(s{zGk_{=@*0Qo<>di#xOrj)Ru)fTA#5ea zx4r9qr_Tj@`HQuu?6L&gu(r>$N)i0E>kexu56>yQ7d+x``Nr|XguH6`q^lFJkV>)< zj;Lml;4cl_TwDwfetOAXlJaR#MN*w}2#LdBW6@LNj#<((8uNCtGfl}&bmO(ZE`uW> zgSii+W)EQNqz?#x1V{;g@|NyASpD^`8{O@9AQ1Kb*w56kQ280LQATB59F|!>nUU#F z_i+m&x7Y%M5p~rUkxqyEUM<(YNU1D>Z#yq9e4D)awa>FEslKh$h+pf-mDK+b@lq6a zMvtYplMiXroC|wxbO!N;NV3^3wV8goZX6ZH;-LGc=XsJM#wog3Xqj3hQtPyo1;>7c z`YwGLi;Uh-cw|7r8C=!n_v&3Q4+I;}Q=|N8$`&w%%8@aizrp5Mr6Mi6zRS;z0MMkL zMk+=PA)ANyff&BJBQ6`pt(>bDj9INPt&G z{LG(DSIkfA6L-tOF13Hllf*)(4V*REa{hFH?7rJ#S7S_Q|CU)-$oCFo#oV+&xC+h{|_ zQ|c-xg?<0@F%70Iagzm_v+S6bq2eQg0( zek-a)y=1Yp>Ah6BBRnsvUg=8kx=6&7PL5A$bGIzsJd&!2N=Mi6*~m0V9SD!&6Ztiu zNg!GBey~$d8$M-4voAAvBoKSPY`r-iF8DSRpbuv*r!K8ysn>v;CSp1OS z>!J8-+_ZOwVxl;AfWYaYJ8R!@Zyb;pkz4UlKw_7k)nKQxkX$jk*pREsuqTV^qp^DW zdck3x6ej$xea#s)FO`N$sJ_e8XZUz4$t7gYw!g0;pG2skQIIi$Fq(#r4JUQJvl0K$ zKfSUxQLz_~HzRMC+4FOl(?wp5j~79?Ok07H+KV*56vUZkyQ3Tc*Q1km=-!GTMT&8Y zK!stiYN6&@6~%f#tm+uj+F0K>V?OAOxkjV2_F0Ci{D!(#7LO3>&&19~-b2Af5$d%- zaL42!Vh!6aR60t-_lfIjtCh&1r} zy3k=g*w0kZv4B;nd47$V8T-Xwe=g$ubla}slTNLWJp4zftw&JGQ@2jG28t?Oiq-W( zl}dK*!PwXZ^Fb4O#?^f*po`z&y86q5lftp?^o%b zghgjVUmM{0-UK;ED8-H=0#3@ zd0T{kU&y`$kj=7s1}w7(N$&w~`sxED%U~DdO_|yXWX^a*c{3^-(MQ=h%Rx49612J7 zOQF&cFoWb8D5wJ@PQ*IGvcN?lluxIW*4LS_B%ldjS`lA=G~O{iF!D}sTa6YMpEoC* z@yllV)U>cFcrz5PDAwy6ZnFbtYSgLmb$MnImO8}|>SA}E@5@dzsx>Zn^-WUDr|P*u zCi^s7W4a1)xVCrg=JDgk;*Y_yTbkd?aM+`G?){ z678thzF7bx2{=V;4!_FI-9Z>XesJq&@f3s7SRG`~3&Z83@!F=L***jhK3ODO&&?^f^&M}FyY({O+UCBy?qNuW^+ z3LiuZ9D-FDAR*w!pFDIzsN4)xTUOUz*{Ebqd}|_fpjD>Wl+YNHuFpT`cPs8p#E`>< zlfUUGPfO;$H)f-ZW$^Y6u`OPp*3V5MLj8E!byxFaMc(rQmPY8JPw3B4WQ&vER14+* zv{~LAe5{+vJ_Y;qhy>M*P!sS+Oiw?>+jp8n;@x6iPIHE?o3W)`*NN>(aHXM=>Jo#@ zUl3D7jUQ`D@muxEdZxo^IpNn`lvtOHIV*(R|W3~8HC zzQU4EAHH}>u3q)9v+x@|1u2R;`LvHBm0*2WQrmWn?110BZ0CL7y2$r_v_+1@!-A;A zxA7fr=%`P^2)_$zS%tDBv?+ zIaPc3d923M&ok|t1~K6`^Pbw7vLN$4&;XT`*JP4{LszA4h4w7-i7?Z|2=Lf01>Q6( z7fo`t9BVZaK(dgEId zUYMC}cj}8+r3*E`PIR%QnF@Ldta;-aJ;hjHwi}wVB>P44bWD4f1{t|R7y6Oq!yk5V zq<(X z+@TO*Yi=TN*6->gOlcWoMo|#^^YcbsFaUKUKJR=`QtdOnUTZVmHvam4)Q5abGH;W6@I{kH5jq3uBV=Epm0(5wct&0i zJ6RWoO_c`Gkw*wI9i*=Gs*MPBXf)}r>bTqn)V~vI9?ddI5Vcwo4u2jb-+_fGf!-Xc z!(>5Je8JrrTklB5{cyP)gWgDGy+8kQQ?tI#;7`u_Ku{J7Ot~UVnE5foBK^s zYpfngY=mPa3-6vfj(zHv-I}XUf>$%e#fVin>BbS{=I%dcNmR78Y^5@RbsL+A?)f`)1RSoOs@*5cl0Wuc}** zYUd{li=tJBrgN#y+J5yDnH5Y-oeH|(XTOzS^JJXtNwgThr&7bIARY8mYYZg(yuH9} z85#VdTNL7St@BPb#%6@Uouk#LPPY}FP4P3-kD+CjO5i>$@VQD)ZX&S5>3B#=FAT%`X2K3_;ueKE7h*Lm3I#A5#`+zJ=OZs$ru0g@8m*z#t+yg~%pq(i~z8 zZ$&xCIss2GBqA8|9$mv}E9KE949KPPmG>{`66&q_H%*>5B+>$EW@cDPq zG}9Oa)BXu|!S5jYvJH74ML)%*Oj=vl4*mLp@_AWGWV-eog3jfZ4%X}j!&)6 z4=^LtLKj(O3=;8F&|K^xXT`&zCTG{jbCoRA*faUmoSOXvS7;JQx5=@SF+4$uix`k2 zT(rsQlJ<49*tkg2@w0F|UbrYKKS>&SrAp$R)D~= z=vg^XW!cEIu@BcC&$fq9e_KCIuKEHJUfSzE*i3E$e<+^KC+QaW^uDQWO~urr+d3Z` zd>eGsM*#_@Q}@f!l;K=DW>a=#_~PfoQx#g`(6uiZ7r4{Fa}&Th|z|A_D!@I~WETemyrsf?0gy}ll^R0MHf1kS`eIeFX7 zrn^VGpU~sPBt;`l?ZlQv)61pmm<$e)ien9-a2>XF&_N}Nm$C&0ge1|#{jdS-A#$!+ zK>TK5Bo8d)+LY6&k~e2fS7P<@n7vqhYd*eqK4jdnGC^XSsf+0^hYdw*Y4*<++Ux&CfPh(>6Y6iRRxg_B77_u zpA9Tq5d6HlqgLI})ZJTrI^ zOEP#Zi>_mIINC<-csQC$p2<{VeM=J*#PkcMX6|6g3_v5LJHh8yC>x1L0+vw)Q+oXb%=pKk(S^6m+0bS*@ zui<`WKgufCyr5UAK{@Mv7OZL6FNjqR=Uxl46m0shQMIR;>q5I1EG}-QZ)8pwfvwMD zey7qe3hec}IU$+0Z&Znu#Sb%bC#)pjmXN#a->Fsw-oqP zAzo6CR;J#KW||#KK{QcbB_Kb#U5tmV=|14A<*7yyD4=)`q=K{i24o;US{d0|J6x$> zi>(~gPjO9m^dX4PZwrjk3mTIB5cSvi1ZX$8MgA1_L=*gd39F^G@J9;cP*ED!PZ9fG zdA)A(izVyO1LjjiiQ+m$EnVnLFi*spsE>f|s)Wzj+8bDzm>Cq~rsnaAr5R>SIMoNo zl1KQKDFt;&PN%p4ZaT+a1NXM9t*J=MO%_F?dUa;<9#d%F7~mBVKDI4jw< z4dMkpX?gA~EqJ+gw5h`0o|-zG-<-nhDyq}!n}L~LVjZuL4jv}XN~z?r)yP}Twzyrw zQn1p67RMcnO=}L3aCR5+rby=nZ67CwnQzAe%JC{myVrH-znol#{W#qz6JCkbn7kZn zjI8;ruT3?hh8ZC;zMP)(CIS-4Z}Gbw6Fb)HRZn&3p?FH65V{`drH^+X3@zfB`l5=+ zLWoYqY$!bUd^MvlogSxRQ;c1FHI>~))N;GD!62peH4%$h0@c7R(vo@kDb0pdyLGtj z>{su?n+=nfZmqcMUWG~DDyPYah%eUUxMZqM6>gaBrG7o_BJ5LkZ7;CZ&!6G+&7LEH#C0qBez@8wAwsYBF{Fe>hU=zhw#Xl)ePZX7ni2#uO^ zGAt?P2Kbssf9(AtbZ=Ha_W!XmAz(G$e*p8_OL9@qmfKqkyaagackI@bRRZ3B%322G z6xFY;&zDm^;SC@#y5PYIw!ekhzKfP*LuNPI+r#t@M5exmp4bc{BT*J!$SZ~xF>9bq zRlbu6zD-RyX;`0nT+XpIpnh>HtE4V(P~F;y+X4F`zifLRv}(?{_{`|HHt z1yu4YoG@3`w-@Q)^1Yqy?JdAL3N3*^590DXT2&bao zLOGf*;PN8CZieNRPh@KodrZ*nUBGSUt0!%kCX}~CSwgktf6vy5PlDI^ zWiaN4p^eEq1={w|!+Yg&v4)G905S6WW!b)n+*e$uYx_oFL2lJp!dP`1h2 z*Y(coO_gdAHOkJ*2}HVsCl$Zv*<&f;oaFA@_orL!Dd|&z+P7H^zn4Ph-JCFDY@gQ| zw@=Z9qUU`)+C1J5Ogw(j!1JjtmLF%28;SCA3qSf7&0Sx)H@4*7R+DE!t*4lUUiL#% zTeC4{fSSXiJd zrR1Ea@dEZFpZi)wd%!7BZomm!>IN)EnF&TQV_DQncIfu~R+k$zLuV5H$>YDqFr79* z4JjT7ECE8Z$?NhbX_|9xPFsv^4 z@jdrvm>0U5Xpt0t=;~l9LFkzXq=TEH=sNp;=R?+Zn4kBO-`j6(BAISwK-UiM+rrmV z23X>gYUlK+$6?pFUQcuXyG9`?*Uh+5%iUOMp%4Ve5M$epGFflX>qp?G)5y$`9RmVc zxqTCRE!Z=_P~6V35pzTrjW)incR$B5uBJ{c-KhUKM9IM?GEx%YhRb-0wT&}a*O#7( zM2)&Ut4MyLe$svSEgziI#zH?Vi${uXz3+*lYW34SUU(m4uMmJea~59ucg2O;YFH?I zMxZe@6N}n&Z!jqoWQEDS>mGYiA)}{`et8j>IGVAwQcK|UbnFNH?bM_*z?x%ci-)x# zesp=OJUnb4>5N2LP06x|oSufk=%RhNB1RWKg5(qkdnTYq(m~mAH&ijmhj<-$u7<=F z@D>1+ajlloy2Lu#`6iO_7 zHl$~+DEZWd{ZquHQHEIq{g~W%3+Op9)T1MMnuT;8USO^@-5X z(DVyM;AO{3)gO#1bT((|y|T(Kj(vINyGJTdJdbY+)nl`+f*GW(4->w?-n(bn>C z0YuM}N929OPj?h7IYxrA2^wGlmS-tp0|fLTOBF$*qh3;;W$K#j2L@VCD4guPU(}Xt zeweGxBs@_ot)AeGFIOA3<6dQc)Biq7b2A*&e<gE;Le=Ci>0_ z4>A<1U$R}5jX@2a(m;E$cgFy)`oYA*s$mJ$P<$v4sS>P`pBeI*KT@Y*-PyU8xk$(z4AElZx5)h@agP0Ae-Bl#Y{p>G8oXJ&enfd#RvktuGf;;q_DR)sQ$;L(uMUyH*QUaSmsct!U581o$ynmQ&FU7YBQ4dEE}7bY>XVj9AloGdV6Wew4S5O$jnw1L-9c|hz5-m z&g8b)g!aOlSh$Z4&dM&$(D!iuDR(O!=WFnaPk2K1>mx`s;(nB}fS z7L*)mdK649m$Qo2%Zsa@_`3M{syp@qnJKQ$TFv`Cw3q|n0pEL}22~n;sxY1!+O?Q< z>pKd4QogWjh=OHnt5JzpIV_jYGVV9!Ce{zed2vIaD&k(FeXJlC#thA&Wb5bZt)>%K zZLwdR(k|z5j2l174Bywp9g2I|FtvqJh=*AQsyv>yztL*9nrHIpW~qK0x6d2IqDnKY z@N;bj%}<6>shsuwdPqgr+6zZzT)AIxbKdNdiyp(lFH$^2978qpxq_V?`KRIlbZf~H z1u6JCp6_n&+wzT=i+H*j@$}to1(|2LQgB9&-uZaz$+gTKXV<4`c$P`(x-^xkO_+u- z`#MuWwh`R-*uD+?cX2^f0w}vW{iswjd5tpuV4U;7ZWZ$W5eN9OfFQogaW5FPGOg2Z5x+`&$4sXZ!6RsLv}s4j z?z%xOc}+@$X%Y|B=W0RL$OFktkh|I_95|n&=?cW<2ts5U{t8kWiRcIGTn-*|kS&3K1A>$QF2*8J-85CqcG(18vt`+?LDochEigOQR7bP;D@A@N0WH7ks z37Qqs4ET-QdgzLm$Tp$(Vr#9(_ELsu%6xKp;PT3ZGA*3!UPMT9KIYE7lh^alUeWlS z&ok#WVED+h)a)F2wHO4@ZN6U@{G+aY6V)V^s;h(c`TcdKOIN`}PbRMM*CgQFk5$!5 z|7uBKUVUX)2P;0ty4}4&4L@yk@m7xOoAgog9JZ|=-!jc-9b%j`}z6t+cX!O-X+ zP&sY2pj~W>)?Fb_b)}mYtG&j&Y_3M8U5h-Q8p)b}!Sx__qwFh>dKT&Yd~w1B9C=Htd_@*92&}H{o=ScS25sge8}eNW~|mRq0V7jcd+_Qu0Cx3pWWto8ZxV5lDW;X#aHyqgLF)AY8?zbX$+ z0kXtZ)ow%U3+ifAecl zn;?P^xKOHM|WG?q^pQFa>nbI}>y~|Gx zsOAI!8T!zV;j*iZ=LI>31~q{slp`lk>&!A&8f@laTd_`{w<@ds&$0#1o{Q@j#DY(G zoDEJwBt>4NyWi!<@!Tiv4ZNJW>Vs6P;JV?(@wT6%*wwcw?T)Yt&B)c9zurS1r%r9R z(%mJ@J9SG(77>@;Be=U-xYZoLiZEV_|xYpO$m5gXnQ8`gg zjLfmoI4TUT6$9o9piw%*n;evrT^Vj*n=+~Jd!AQW(mbv66_8}42F*7c!qV0H1yY&J zeS!ifk5eOn-$(M7#mzr9;eRqoYn&E}Ff+b2S3s~KQ+uJ~s?(AxDutwv}c5jun(?9?gb;f z-Pxgc@bRLw=}SG+w^7TFWB$QsUejS$R+9={92!MVOML#x!!#qK9Fnl1ZE-#>pit!V zO4&|9$H8U&J9B|lQRK8CS8D_hLU+j}cz0@jOsivL9_PuQSJ{WFVCz>EtJL4hAZ@Fz~KL7l2+qw|-s-y0DZ{}|ua1`qF|zGEv0 zDc;;T#<{HVdA!M^6u8?b-qATtcTqa%zCXtWBtmR?;pCv zGq^ao0Sm8-dLcO#jARQi*j7m;qk!SkM>7kbrHsoe!W*@X^b{*Tde`^48SjpIQCvX5 zA5F)~A+$xIk9PN`kY{|PD`2iw@%J%^LR)ufJ%zuOHj}%&3@+O_(W@652)0q*(3P%$ zuB$Id<+8WP9_a?v8BKpSa+gXqvLUZUSv!R!0o#bFl0*b4KZKZXL!z&?oSB&i5?|ea zu@<0LuU%dEbT&{wJ9T8{DQEff7S28zp6tYnVmoRG&9c>Ne4$xE0Q8QkZ%d$dtor!P0%is^c# zxW0^?IjOJSFf?-qKRE6w(K#ES!*X6`mcorEenu~{H`8~XqLvg%;NXsXCU{B;za0N% zUL^@y3Sn0TssmqKhcmni>{vC0Z!!B3bYgL(zL9K0cbS0+&OhXBIkN7Fo&yCwQgM zW9#3NnxY1(piT)k2rjg4>5gj1>NWQFAI0ZA7+$$XuJ2#OZc3=W*Z;}r+w};0-zcyx zxS1qV=rw1`Y+PDU3k`Mp;yd8xt2Y&@!-?&#=ifsOE%z^X5-`xW*$VJr(fCt`9~RHP z5=!dAHpJjr8(q`9Gki*$6`$z@aR52oPqRmSLfZ@oR$2jdiJ*UM!lJ|1XiQ~|%!W?* z#p%;#5o(LJpwWJ8D)^*?Vn46j+^}!LOf02#IrqR8sqv$?PP)o?cb%D3gh-?De9j|R(es=G-HtyHhw<^YLl=v?z( z+NLKnHwYmuO#XoTJd?aKH9WkWrs$*gAo@i;&{7`L{eBG&;fP#r#$Bz%yg6`1`C2in zFjfqMKFiCIMBPV}skEwTn7CF29|cp=IkDJCw%)1|LMlEOz3s^<&oQrb<-t;j6PCi6 zStQ?&oa5=XzL*6;XYu=51l{I{wkH+jbYZ&hb!C=0Z1+Cjoj!etp)~RR8=e0&&z&yI z?#F@iGfgF)28-CE_H+b``gE{4Av;12fkZdcPup5zZ$JTjG;(%|)t`tVhOLn*l#FUu z4a^|$$uwIURC+o3E0yTGh^tiXdR9hI?QXwc3o@2*K~Y7D$r zQwXl?uDx*Wu7s%z<0aW+$5~H?^`guo^QCH(O;OzrbGqO2aBiq2zR+hNtw|&wOZv>Q z6AR^NpI*y4H5Dsgh#j{z{kRv727+Y1;kdm8dVU^#7U{~+*PKj*Df^_oV2dNX2iyYK znxo`0F*C>+tNg|iU=ofIhb6cPBx*KZX4E+(AoF}?(Sa=@>t0mqt#6ugpejC37Ab{O z^y-3xCkOVkLwY5>GBv-oYes8hFx&L~Ofb;cgG?+ig z+jItG%ms3YGs*%wGch`Gur+wkXWL{^TE35}T&x`vYuzQa%eC1{?J$4B-+LXicw1Gh ze$op}Y$1}>1hx|%z8bH7``G_xB2GBn!|y=ng=EtMoQ8m0LEJJ9_9rlaI~utGEe5z;~w*G>GUD2_|??P?q(>p2EU9CSVz zHBr96eYSlb0v%AaCHoZ4jajt0d{Ez-g94)V*dXM#5>5a`m0c`;&VGmSn=X*y!aVGW z`L^pzhS43fM>37ZdwKSsfpiME5uCOTE}%{@iObzvNpFhBpfifC^Qe@KL!~LO)3@Fy zF@3C34w>e71T^ntKQn#IC8_aVXmatve?Asl+Oi;?b3h`W>`El1fYs3?@8Ig_hNoc3 z0s}~yy(j6r72dOo_`OVM1w z`{thTrQw-?d+d93$STipkxXL1$&M7n8+WjmT)Q1Fy-xMDONf~`fU{efnP}M=#+(B8 zABV;TrEbis*;Npe$8h+JGG8c*Yq4=Sc(GH4#@>F^ZsZ2$;xOMoMkQ@shyN}*W|mhq z7)Ew9ZqLfEHu7ITR7}5qAGiGtw4^jmf47Pma%5;pMb(062X)-QUVtA_X`>b}Szk8h zGnJ&a;i|2*;y~UcX;5gTaMt$4Cp{v)pGadj>FKM9$r7n%{&+Nzcf6+d7+%fr!GHP5 zh#pO5AKj%U3+KJR!G^>;u!z>QvoNn>X7@RYFyLL&DqKG3S&Zv5pxm*T(fot==yp@K zrwx{==PK;HhY%|Hx!HW-BtB#mYuMF7g$_|PnDK!lnFp)?x;x8NT*w_F$W&9$;`hz2 zM(s~ev=2MNJkMW*=opP}nscdKGc#n1gau!;Ob>OP)O#{rGiS|x{m?sxe=|9*TjOTr zn1FBX_3jY8cj`Klwe3=q!cuQ7?Sh=XS{c9#1 z6lyO#{SK^Syi)F3dHW#A>92O!cOK7HnQcD^jRlJyHFO3B;S}_ks`^eoYRF{dh^2S;p_8yK`^%ByuX zW8{FFtUKuR67HFGr|m3|@e8G_QT0Y$&L|&M1oyBn0Hw|7L@{$1Z_HAfyc?IeYu)mK zT?wwIUY>~jf2gx*c7Le30XG`~pshz3d!|5^Cd7n#Vx8g$glr5fL8Ue;rFavnhgnMRS; z%~Yv6?De(1uv^|(+@SBxG{S@DhZcVNSnUl2S7x6(EIxUNxwec=@`X;W=?HWg zCGpMR)+ITnPRMtZKhJdg|GyP^L-27&<+wB9zBYWWE|R>o%Ht|Yld!+m5ke@wIhgu7 zd&1@TOwDa9%`HqUSXazVOfXk0OiXIgc;FgD7?}6tJSvFcYa(8M@5|BD$=1r!-GkH3 z!fGsa%qg6UFyc@o(sF!O0)U3*#yZ?$2kPdJ(nSM&%_jcbnV71rURb^hnqIGx;ayH_ zczIw-Js4M4+Vh0Z{66!roXy)EcHuV8mZAmW`PoKxx@?+byYM0qTdTJdn~-rvB*#Ns zhY$7ntUlRL5!H6a9;mZN(HhvIuKhLTD<7K8alUF1#N%nM6ZILJCLuk-i^Ovf=ssmr=r(q@10sY_0!SKGK~B;NtA!=>nJ2^aT7f z?Z3m({Ra0B*+qANq^*aesf+vHfPc494`*iw7gHxohyN0X(1Y}JH#2qn8yxj-f`zM7 zTDw`g{~t)ijP*aK2NCJtZ|`>~L_Ys}l$C=sTn6;VzWq);5upwH=Lk*B&EbNm|B&kh zz;6XbXlf$#x={XcTEW*xLd>a0*k7Mkhp4Py}*GUoUB0fH-K`*pziPuwb)* zpvhaLhjvyuWRx>`#~0rwrm=-7=9auMbWgKiD&JzLAf_q2+c&d8k1npi8lTLz>*_kq zx&S3LHqPv}@<6IhU+m+;_Svd@)#@9@xGz^{!G8AysB&s7*-`?>v6a)rtd$Z>-10KC zn`2Mwbg|2u^~w0G?aES%SoK!#aY&s^KCqOHugjal6MR)UCr|J?e)hd#D{W^Ta&*0> ze3H~XCNe?166d~&p?m4i6X;_G70Z1`Vm05#eRyM2;@J|vzJ4qyHa;Nfw7xSkqUcbV z-XkB$e#XOF$`_;e-i7cG^jxqI=B+7%&H_LF@me`|bJNAx;7_X5ep&z0_ySm926K@F@a@n4@Q@1O};cw$GuxYx6 zDXW=79C&=69c&{7wquJcRAu3=3~BjD))$%?ZaghScA`WHt3in>lT}>wsNNdTt<#Wu zN>N8)lpFF|FWm_E+WPxWqz1v#FyBE$m=N@i2HvgL)PlgEPo?6YE`nq5O0jK=wp#5I zK7q{Bh#t5m_f-v}rw5XCoLL4i`a>t-EWV*mQ>8Up6{LOv6)s&@Ts#zOQp`26b|Ii-w+OM7g8GW8YWIg2!p|5grVfL5VUx zjhx`b;x#!F(|$go%KRapoQ>DL?uw;(MW0HBx8ia28L*K6P+8x z*pZf{GdMQUDg!#`SAuRGOpS*h-RSxr$uskhMz-q_^F;|t{aVQ1oj4!Vg@Olq8l zqk0;0mCzTp<+?)3MiWH@z?Ascetg=Kim%f#8)iuP-K^y#wO+~Gbgi(SN#~!DPJJk( zeI-@HaCF=xql!g6tq$z&M{W}>nXG&iV%H(w7I(FP7O&U#)nC^0TIzAyfm9gZxb7Ez ze^Gs$EFRlM+l%D6D#{o3vUa6DA;4j42r#dZn~erkMwGoK!cc_e&Lg1 zb!QphAl`D)OpH|n3}{hj@VsSkmU57nS+zOH;c^m2C5 z7P~qFa+$jwM%ts&3q~korn%qln=luvoExlde6_J5@KKChJKZ;qr!yjhm6d*A)_vVA zVA6H0W338$KhfS)qS(2#LvMJ?zA8u4wL7?rH(7QAddMicej_faVNn6RLkN^yDUE6E zkJMR0D@)bHN~cc2D8EE4D;t=Rv~SOP#Ln|Nl$EyKT1m5Eg-)$+A6)6)hDr67d%13I zZv&rTAylM!m0wxRnVEDhtr?0<#+vpP(8`Zd&V`?`DwKA)y!bG3d%bYFt0zfUJ#4*m zB!Oe_p>Hj~uyZK1@x{=2V<}shCbX+#GQb@jn@f0*D6za)5goXvzh|Z^#`A#XjSWX# zgKLUG=po8wA2`MlDg65h6Qt3E<@SD?@e7cM9jRn_y+FlnW7|=(RP8v}rib0BZX|2@ z1HNJUXITwRDAW=7k1RwELaBXYt8KPO4`l@HaXq&VJ5@$?XXaufS&RfUX`pObSwgc9 zZyL$x%lX!2cM5S0tKHL`I z<6gY&{r+UXCHjlP#M)eZm(Uo2w+wWBKQDS)f0A(?`}3=v0igNih406A9vrsZj%d!~ zCsR+kMX6M`mIh2&ZMhB*??7L3iyC;)MduavH{5O)nu>!%YTJ}B!pJ@(btyg%YT?ZW z8DIKTF>~Zsu8d{ns6b+OFMPgE1ky&Opo5KEaKOsygTV}Znl7pUfq=FbTYKf|%=8d$ zTc(KjAD&iaw$dyB{0aCLcmrUy;X(P>tX#|1k?#ANL_w>Om){7KT)N(ISV+%X(;o^< zypff$!)eXf3H(xL{CxfGSB3zFL$iVVWqK0u39kTR+n^^=W5!2P$OVsHr{u{ygmHsP=HZhMHLJ=A}YQ1eTKri)rIT2 zue72<6_Au7Nj7;)VJI7!1U)Hp$6`J-j|vZR7#2Ygu)08^e2g^{6^Ta%(kKaqJ|DBCfM zv2>_~q+?lS-!`Nmfcz!QY%|m$JO;L@hU=MDWyS1vmxg|>5KDw*OePw?44=jS?uKd@N9M%v|c#c!9FeuZMWmxxo zH7cX%mqF}!?P{K^K zq4fRv12T-jK|@L|j8|Oi9n8;JP5vx1^%K}f_Sd3QKfL@1{8!5P$G}J7f>gg!);}YEWm|tl z-qD07>KB6g1NkHJpOGRVA&AjW(|PjmrTwqm?2iZdCk_b-!OnhK(r^6y8&~^lXMYT8 z^f%6a-??A8++X`au(_Wm@*6*Yu3;xr~k1s7^4}K6j1RMNmci`7!{zGo~<6HT|>90dKf(!mMXSma!%<#{+ jUx%REKSA)Nd85A==G7F@&=G4A!~e?R literal 0 HcmV?d00001 From c5398f61f99a18e46ff46f84f100c831afdff6cd Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 15:37:52 +0100 Subject: [PATCH 011/120] [CORE] Modif de trad et renomage pour le module askpricesupplier (#new_ask_price). --- htdocs/comm/askpricesupplier.php | 8 ++--- .../modules/modAskPriceSupplier.class.php | 32 +++++++++++++++--- ...osal.odt => template_askpricesupplier.odt} | Bin 3 files changed, 31 insertions(+), 9 deletions(-) rename htdocs/install/doctemplates/askpricesupplier/{template_proposal.odt => template_askpricesupplier.odt} (100%) diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index 855f84a72d8..ca34e84fb30 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -1285,7 +1285,7 @@ if ($action == 'create') // Third party print ''; - print ''; + print ''; if ($socid > 0) { print ''; } else { print ''; } print '' . "\n"; @@ -2186,14 +2186,14 @@ if ($action == 'create') * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $filedir = $conf->askpricesupplier->dir_output . "/" . dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->askpricesupplier->creer; $delallowed = $user->rights->askpricesupplier->supprimer; $var = true; - $somethingshown = $formfile->show_documents('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + $somethingshown = $formfile->show_documents('askpricesupplier', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); /* * Linked object block diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index f0cf2a7a40f..593ac749b1a 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -48,7 +48,7 @@ class modAskPriceSupplier extends DolibarrModules $this->db = $db; $this->numero = 999999; - $this->family = "products"; + $this->family = "crm"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "askpricesupplierDESC"; @@ -220,11 +220,33 @@ class modAskPriceSupplier extends DolibarrModules */ function init($options='') { - //global $conf,$langs; + global $conf,$langs; - /*CREATE IF NOT EXISTS llx_askpricesupplier (rowid int auto_increment);*/ - - $sql = array(); + // Remove permissions and default values + $this->remove($options); + + //ODT template + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/askpricesupplier/template_askpricesupplier.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/askpricesupplier'; + $dest=$dirodt.'/template_askpricesupplier.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + } + + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','askpricesupplier',".$conf->entity.")", + ); $result=$this->_load_tables('/comm/askpricesupplier/sql/'); return $this->_init($sql, $options); diff --git a/htdocs/install/doctemplates/askpricesupplier/template_proposal.odt b/htdocs/install/doctemplates/askpricesupplier/template_askpricesupplier.odt similarity index 100% rename from htdocs/install/doctemplates/askpricesupplier/template_proposal.odt rename to htdocs/install/doctemplates/askpricesupplier/template_askpricesupplier.odt From a98ce0180786f841b04bd59ee91785e0c4e2ce13 Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 17:27:26 +0100 Subject: [PATCH 012/120] =?UTF-8?q?[CORE]=20renomage=20de=20masse=20+=20co?= =?UTF-8?q?rrection=20des=20noms=20des=20fichiers/fonctions=20par=20copie?= =?UTF-8?q?=20+=20ajout=20de=20cl=C3=A9s=20de=20traductions=20(#new=5Fask?= =?UTF-8?q?=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/askpricesupplier.php | 648 ++++++++++++++++++ htdocs/comm/askpricesupplier.php | 2 +- htdocs/core/lib/askpricesupplier.lib.php | 4 +- ..._generic_askpricesupplier_odt.modules.php} | 44 +- ...zur.modules.php => pdf_aurore.modules.php} | 22 +- .../mod_askpricesupplier_marbre.php | 2 +- .../modules/modAskPriceSupplier.class.php | 2 +- htdocs/langs/fr_FR/askpricesupplier.lang | 16 +- 8 files changed, 695 insertions(+), 45 deletions(-) create mode 100644 htdocs/admin/askpricesupplier.php rename htdocs/core/modules/askpricesupplier/doc/{doc_generic_proposal_odt.modules.php => doc_generic_askpricesupplier_odt.modules.php} (89%) rename htdocs/core/modules/askpricesupplier/doc/{pdf_azur.modules.php => pdf_aurore.modules.php} (98%) diff --git a/htdocs/admin/askpricesupplier.php b/htdocs/admin/askpricesupplier.php new file mode 100644 index 00000000000..819aa64c471 --- /dev/null +++ b/htdocs/admin/askpricesupplier.php @@ -0,0 +1,648 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2011-2013 Juanjo Menent + * + * 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 3 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, see . + */ + +/** + * \file htdocs/admin/propal.php + * \ingroup propale + * \brief Setup page for commercial proposal module + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +$langs->load("admin"); +$langs->load("errors"); +$langs->load('other'); +$langs->load('propal'); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scandir','alpha'); +$type='askpricesupplier'; + +/* + * Actions + */ +$error=0; +if ($action == 'updateMask') +{ + $maskconstaskpricesupplier=GETPOST('maskconstaskpricesupplier','alpha'); + $maskaskpricesupplier=GETPOST('maskaskpricesupplier','alpha'); + if ($maskconstaskpricesupplier) $res = dolibarr_set_const($db,$maskconstaskpricesupplier,$maskaskpricesupplier,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +if ($action == 'specimen') +{ + $modele=GETPOST('module','alpha'); + + $propal = new AskPriceSupplier($db); + $propal->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/askpricesupplier/doc/pdf_".$modele.".modules.php"); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($propal,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=askpricesupplier&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessage($module->error,'errors'); + dol_syslog($module->error, LOG_ERR); + } + } + else + { + setEventMessage($langs->trans("ErrorModuleNotFound"),'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +if ($action == 'set_ASKPRICESUPPLIER_DRAFT_WATERMARK') +{ + $draft = GETPOST('ASKPRICESUPPLIER_DRAFT_WATERMARK','alpha'); + + $res = dolibarr_set_const($db, "ASKPRICESUPPLIER_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +if ($action == 'set_ASKPRICESUPPLIER_FREE_TEXT') +{ + $freetext = GETPOST('ASKPRICESUPPLIER_FREE_TEXT'); // No alpha here, we want exact string + + $res = dolibarr_set_const($db, "ASKPRICESUPPLIER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +if ($action == 'setdefaultduration') +{ + $res = dolibarr_set_const($db, "ASKPRICESUPPLIER_VALIDITY_DURATION",$value,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER') +{ + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER",$value,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) +if ($action == 'setModuleOptions') +{ + $post_size=count($_POST); + + $db->begin(); + + for($i=0;$i < $post_size;$i++) + { + if (array_key_exists('param'.$i,$_POST)) + { + $param=GETPOST("param".$i,'alpha'); + $value=GETPOST("value".$i,'alpha'); + if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + } + if (! $error) + { + $db->commit(); + setEventMessage($langs->trans("SetupSaved")); + } + else + { + $db->rollback(); + setEventMessage($langs->trans("Error"),'errors'); + } +} + +// Activate a model +if ($action == 'set') +{ + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +else if ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->ASKPRICESUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'ASKPRICESUPPLIER_ADDON_PDF',$conf->entity); + } +} + +else if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "ASKPRICESUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + $conf->global->ASKPRICESUPPLIER_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + +else if ($action == 'setmod') +{ + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated + + dolibarr_set_const($db, "ASKPRICESUPPLIER_ADDON",$value,'chaine',0,'',$conf->entity); +} + + +/* + * Affiche page + */ + +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + + +llxHeader('',$langs->trans("AskPriceSupplierSetup")); + +$form=new Form($db); + +//if ($mesg) print $mesg; + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("AskPriceSupplierSetup"),$linkback,'setup'); + +$head = askpricesupplier_admin_prepare_head(); + +dol_fiche_head($head, 'general', $langs->trans("CommRequests"), 0, 'askpricesupplier'); + +/* + * Module numerotation + */ +print_titre($langs->trans("AskPriceSupplierNumberingModules")); + +print '
'.$langs->trans("Mask").':'.$form->textwithpicto('',$tooltip,1,1).''.$form->textwithpicto('',$tooltip,1,1).' 
' . $langs->trans('Customer') . '' . $langs->trans('Supplier') . ''; print $soc->getNomUrl(1); @@ -1293,7 +1293,7 @@ if ($action == 'create') print ''; - print $form->select_company('', 'socid', 's.client = 1 OR s.client = 2 OR s.client = 3', 1); + print $form->select_company('', 'socid', 's.fournisseur = 1', 1); print '
'; +print ''; +print '\n"; +print '\n"; +print '\n"; +print ''; +print ''; +print ''."\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/askpricesupplier/"); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + $var=true; + + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 12) == 'mod_askpricesupplier_' && substr($file, dol_strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file)-4); + + require_once $dir.$file.'.php'; + + $module = new $file; + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + $var=!$var; + print ''; + + // Show example of numbering module + print ''."\n"; + + print ''; + + $propal=new AskPriceSupplier($db); + $propal->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $propal->type=0; + $nextval=$module->getNextValue($mysoc,$propal); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; + } + } + } + closedir($handle); + } + } +} +print "
'.$langs->trans("Name")."'.$langs->trans("Description")."'.$langs->trans("Example")."'.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->nom."\n"; + print $module->info(); + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + if ($conf->global->PROPALE_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print '

\n"; + + +/* + * Document templates generators + */ + +print_titre($langs->trans("AskPriceSupplierPDFModules")); + +// Load array def with activated templates +$def = array(); +$sql = "SELECT nom"; +$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql.= " WHERE type = '".$type."'"; +$sql.= " AND entity = ".$conf->entity; +$resql=$db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dol_print_error($db); +} + + +print "\n"; +print "\n"; +print " \n"; +print " \n"; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +$var=true; +foreach ($dirmodels as $reldir) +{ + foreach (array('','/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/askpricesupplier".$valdir); + + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + + if ($modulequalified) + { + $var = !$var; + print ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } + else + { + print ""; + } + + // Defaut + print "'; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); + //$htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + //$htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark,1,1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + +print '
".$langs->trans("Name")."".$langs->trans("Description")."'.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print '\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print ""; + if ($conf->global->ASKPRICESUPPLIER_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print '
'; +print '
'; + + +/* + * Other options + * + */ +print_titre($langs->trans("OtherOptions")); + +$var=true; +print ""; +print ""; +print "\n"; +print '\n"; +print "\n"; +print ""; + +$var=!$var; +print ""; +print ''; +print ""; +print ""; +print ''; +print '"; +print ''; +print ''; +print ''; + +/* +$var=! $var; +print ''; +print ''; +print ''; +print '\n"; +print ''; +*/ + +$var=! $var; +print ''; +print ''; +print ''; +print '\n"; +print ''; + +$var=!$var; +print ""; +print ''; +print ""; +print '\n"; +print ''; + +if ($conf->banque->enabled) +{ + $var=!$var; + print ''; +} +else +{ + $var=!$var; + print ''; +} + +print '
".$langs->trans("Parameter")."'.$langs->trans("Value")." 
'.$langs->trans("DefaultAskDurationValidity").''."global->ASKPRICESUPPLIER_VALIDITY_DURATION."\">
'; +print $langs->trans("UseCustomerContactAsPropalRecipientIfExist"); +print ''; +print $form->selectyesno("value",$conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT,1); +print ''; +print ''; +print "
'; +print $langs->trans("FreeLegalTextOnAskPriceSupplier").' ('.$langs->trans("AddCRIfTooLong").')
'; +print ''; +print '
'; +print ''; +print "
'; +print $langs->trans("WatermarkOnDraftAskPriceSupplier").'
'; +print ''; +print '
'; +print ''; +print "
'; + print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER").' '; + if (! empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER'); + } + else + { + if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER)) + { + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; + } + else + { + print ''.img_picto($langs->trans("Enabled"),'switch_on').''; + } + } + print '
'; + print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPLLIER").' '.$langs->trans('NotAvailable').'
'; + + + +/* + * Directory + */ +print '
'; +print_titre($langs->trans("PathToDocuments")); + +print "\n"; +print "\n"; +print " \n"; +print " \n"; +print "\n"; +print "\n \n \n\n"; +print "
".$langs->trans("Name")."".$langs->trans("Value")."
".$langs->trans("PathDirectory")."".$conf->askpricesupplier->dir_output."
\n
"; + +$db->close(); + +llxFooter(); diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index ca34e84fb30..f1ea1cde9f0 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -1578,7 +1578,7 @@ if ($action == 'create') $soc = new Societe($db); $soc->fetch($object->socid); - $head = propal_prepare_head($object); + $head = askpricesupplier_prepare_head($object); dol_fiche_head($head, 'comm', $langs->trans('CommRequest'), 0, 'askpricesupplier'); $formconfirm = ''; diff --git a/htdocs/core/lib/askpricesupplier.lib.php b/htdocs/core/lib/askpricesupplier.lib.php index b0b9369f6ee..1c3835e78be 100644 --- a/htdocs/core/lib/askpricesupplier.lib.php +++ b/htdocs/core/lib/askpricesupplier.lib.php @@ -29,7 +29,7 @@ * @param object $object Object related to tabs * @return array Array of tabs to show */ -function propal_prepare_head($object) +function askpricesupplier_prepare_head($object) { global $langs, $conf, $user; $langs->load("askpricesupplier"); @@ -112,7 +112,7 @@ function propal_prepare_head($object) * * @return array head array with tabs */ -function propal_admin_prepare_head() +function askpricesupplier_admin_prepare_head() { global $langs, $conf, $user; diff --git a/htdocs/core/modules/askpricesupplier/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php similarity index 89% rename from htdocs/core/modules/askpricesupplier/doc/doc_generic_proposal_odt.modules.php rename to htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php index 8f79094befc..80c1a0bd347 100644 --- a/htdocs/core/modules/askpricesupplier/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php @@ -23,7 +23,7 @@ * \brief File of class to build ODT documents for third parties */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/askpricesupplier/modules_askpricesupplier.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; /** * Class to build documents using ODF templates generator */ -class doc_generic_proposal_odt extends ModelePDFPropales +class doc_generic_askpricesupplier_odt extends ModelePDFAskPriceSupplier { var $emetteur; // Objet societe qui emet @@ -57,7 +57,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Dimension page pour format A4 $this->type = 'odt'; @@ -105,19 +105,19 @@ class doc_generic_proposal_odt extends ModelePDFPropales $texte.= '
'; $texte.= ''; $texte.= ''; - $texte.= ''; - if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) + $texte.= ''; + if ($conf->global->MAIN_ASKPRICESUPPLIER_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; } $texte.= ''; // List of directories area $texte.= ''; } diff --git a/htdocs/comm/askpricesupplier/document.php b/htdocs/comm/askpricesupplier/document.php index 5dd239e1cfa..0644f932629 100644 --- a/htdocs/comm/askpricesupplier/document.php +++ b/htdocs/comm/askpricesupplier/document.php @@ -85,9 +85,9 @@ $form = new Form($db); if ($object->id > 0) { - $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->askpricesupplier->dir_output.'/'.dol_sanitizeFileName($object->ref); - $head = propal_prepare_head($object); + $head = askpricesupplier_prepare_head($object); dol_fiche_head($head, 'document', $langs->trans('CommRequest'), 0, 'askpricesupplier'); // Construit liste des fichiers diff --git a/htdocs/comm/askpricesupplier/info.php b/htdocs/comm/askpricesupplier/info.php index caa9f21dd1e..a288a3490b3 100644 --- a/htdocs/comm/askpricesupplier/info.php +++ b/htdocs/comm/askpricesupplier/info.php @@ -49,7 +49,7 @@ $object = new AskPriceSupplier($db); $object->fetch($id); $object->fetch_thirdparty(); -$head = propal_prepare_head($object); +$head = askpricesupplier_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans('CommRequest'), 0, 'askpricesupplier'); $object->info($object->id); diff --git a/htdocs/comm/askpricesupplier/note.php b/htdocs/comm/askpricesupplier/note.php index c7b430dff8e..e681121db05 100644 --- a/htdocs/comm/askpricesupplier/note.php +++ b/htdocs/comm/askpricesupplier/note.php @@ -41,7 +41,7 @@ $action=GETPOST('action','alpha'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'askpricesupplier', $id, 'askpricesupplier'); -$object = new Propal($db); +$object = new AskPriceSupplier($db); @@ -49,7 +49,7 @@ $object = new Propal($db); /* Actions */ /******************************************************************************/ -$permissionnote=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote=$user->rights->askpricesupplier->creer; // Used by the include of actions_setnotes.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once @@ -74,7 +74,7 @@ if ($id > 0 || ! empty($ref)) $societe = new Societe($db); if ( $societe->fetch($object->socid) ) { - $head = propal_prepare_head($object); + $head = askpricesupplier_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans('CommRequest'), 0, 'askpricesupplier'); print '
'; $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH))); + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH))); $listoffiles=array(); foreach($listofdir as $key=>$tmpdir) { @@ -141,7 +141,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); $texte.= '
'; $texte.= ''; $texte.= '
'; $texte.= ''; @@ -152,27 +152,27 @@ class doc_generic_proposal_odt extends ModelePDFPropales { $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; - if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) + if ($conf->global->MAIN_ASKPRICESUPPLIER_CHOOSE_ODT_DOCUMENT > 0) { // Model for creation - $liste=ModelePDFPropales::liste_modeles($this->db); + $liste=ModelePDFAskPriceSupplier::liste_modeles($this->db); $texte.= ''; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= '"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= '"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= '"; $texte.= '
'.$langs->trans("DefaultModelPropalCreate").''.$langs->trans("DefaultModelAskPriceSupplierCreate").''; - $texte.= $form->selectarray('value2',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT); + $texte.= $form->selectarray('value2',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_DEFAULT); $texte.= "
'.$langs->trans("DefaultModelPropalToBill").''.$langs->trans("DefaultModelAskPriceSupplierToBill").''; - $texte.= $form->selectarray('value3',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL); + $texte.= $form->selectarray('value3',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL); $texte.= "
'.$langs->trans("DefaultModelPropalClosed").''.$langs->trans("DefaultModelAskPriceSupplierClosed").''; - $texte.= $form->selectarray('value4',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); + $texte.= $form->selectarray('value4',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED); $texte.= "
'; } @@ -236,7 +236,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales if (! is_object($object)) { $id = $object; - $object = new Propale($this->db); + $object = new AskPriceSupplier($this->db); $result=$object->fetch($id); if ($result < 0) { @@ -285,7 +285,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales //print "file=".$file; //print "conf->propal->dir_temp=".$conf->propal->dir_temp; - dol_mkdir($conf->propal->dir_temp); + dol_mkdir($conf->askpricesupplier->dir_temp); // If BILLING contact defined on invoice, we use it @@ -324,7 +324,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales // Line of free text $newfreetext=''; - $paramfreetext='PROPALE_FREE_TEXT'; + $paramfreetext='ASKPRICESUPPLIER_FREE_TEXT'; if (! empty($conf->global->$paramfreetext)) { $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); @@ -336,7 +336,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $odfHandler = new odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->propal->dir_temp, + 'PATH_TO_TMP' => $conf->askpricesupplier->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' diff --git a/htdocs/core/modules/askpricesupplier/doc/pdf_azur.modules.php b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php similarity index 98% rename from htdocs/core/modules/askpricesupplier/doc/pdf_azur.modules.php rename to htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php index 35953b8521f..347677ea1d9 100644 --- a/htdocs/core/modules/askpricesupplier/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php @@ -25,7 +25,7 @@ * \ingroup propale * \brief Fichier de la classe permettant de generer les propales au modele Azur */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/askpricesupplier/modules_askpricesupplier.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** * Class to generate PDF proposal Azur */ -class pdf_azur extends ModelePDFPropales +class pdf_aurore extends ModelePDFAskPriceSupplier { var $db; var $name; @@ -69,8 +69,8 @@ class pdf_azur extends ModelePDFPropales $langs->load("bills"); $this->db = $db; - $this->name = "azur"; - $this->description = $langs->trans('DocModelAzurDescription'); + $this->name = "aurore"; + $this->description = $langs->trans('DocModelAuroreDescription'); // Dimension page pour format A4 $this->type = 'pdf'; @@ -149,14 +149,14 @@ class pdf_azur extends ModelePDFPropales $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); - $outputlangs->load("propal"); + $outputlangs->load("askpricesupplier"); $outputlangs->load("products"); $nblignes = count($object->lines); // Loop on each lines to detect if there is at least one image to show $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) + if (! empty($conf->global->MAIN_GENERATE_ASKPRICESUPPLIER_WITH_PICTURE)) { for ($i = 0 ; $i < $nblignes ; $i++) { @@ -182,7 +182,7 @@ class pdf_azur extends ModelePDFPropales } if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - if ($conf->propal->dir_output) + if ($conf->askpricesupplier->dir_output) { $object->fetch_thirdparty(); @@ -191,13 +191,13 @@ class pdf_azur extends ModelePDFPropales // Definition of $dir and $file if ($object->specimen) { - $dir = $conf->propal->dir_output; + $dir = $conf->askpricesupplier->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->propal->dir_output . "/" . $objectref; + $dir = $conf->askpricesupplier->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } @@ -249,10 +249,10 @@ class pdf_azur extends ModelePDFPropales $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); - $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal")); + $pdf->SetSubject($outputlangs->transnoentities("CommercialAsk")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialProposal")); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right diff --git a/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php index ec5164b679c..096c5a3cec5 100644 --- a/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php +++ b/htdocs/core/modules/askpricesupplier/mod_askpricesupplier_marbre.php @@ -23,7 +23,7 @@ * \brief File of class to manage commercial proposal numbering rules Marbre */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_askpricesupplier.php'; /** diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index 593ac749b1a..53a1552445d 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -75,7 +75,7 @@ class modAskPriceSupplier extends DolibarrModules $this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "azur"; + $this->const[$r][2] = "aurore"; $this->const[$r][3] = 'Nom du gestionnaire de generation des demandes de prix fournisseurs en PDF'; $this->const[$r][4] = 0; $r++; diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang index 863d3749dca..7234366b0e6 100644 --- a/htdocs/langs/fr_FR/askpricesupplier.lang +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -13,8 +13,6 @@ ProposalsDraft=Propositions commerciales brouillons ProposalDraft=Proposition commerciale brouillon ProposalsOpened=Propositions commerciales ouvertes Prop=Propositions commerciales -CommercialProposal=Proposition commerciale -CommercialProposals=Propositions commerciales ProposalCard=Fiche proposition NewProp=Nouvelle proposition commerciale NewProposal=Nouvelle proposition commerciale @@ -88,6 +86,15 @@ TypeContact_askpricesupplier_external_BILLING=Contact client facturation demande TypeContact_askpricesupplier_external_CUSTOMER=Contact client suivi demande ActionsOnAskPriceSupplier=Événements sur la demande +DefaultModelAskPriceSupplierCreate=Modèle par défaut à la création +DefaultModelAskPriceSupplierToBill=Modèle par défaut lors de la clôture d'une proposition commerciale (à facturer) +DefaultModelAskPriceSupplierClosed=Modèle par défaut lors de la clôture d'une proposition commerciale (non facturée) +DefaultAskDurationValidity=Délai de validité par défaut (en jours) + +DocModelAuroreDescription=Modèle de demande de prix fournisseur complet (logo…) + +CommercialAsk=Demande commerciale +CommercialAsks=Demandes commerciales # # @@ -107,7 +114,6 @@ EstimateShort=Devis OtherPropals=Autres propositions AddToDraftProposals=Ajouter à proposition brouillon NoDraftProposals=Pas de propositions brouillons -DefaultProposalDurationValidity=Délai de validité par défaut (en jours) UseCustomerContactAsPropalRecipientIfExist=Utiliser l'adresse de contact suivi client si définie plutôt que l'adresse du tiers comme destinataire des propositions ProposalsAndProposalsLines=Propositions commerciales clients et lignes de propositions @@ -122,8 +128,4 @@ AvailabilityTypeAV_2W=2 semaines AvailabilityTypeAV_3W=3 semaines AvailabilityTypeAV_1M=1 mois # Document models -DocModelAzurDescription=Modèle de proposition commerciale complet (logo…) DocModelJauneDescription=Modèle de proposition Jaune -DefaultModelPropalCreate=Modèle par défaut à la création -DefaultModelPropalToBill=Modèle par défaut lors de la clôture d'une proposition commerciale (à facturer) -DefaultModelPropalClosed=Modèle par défaut lors de la clôture d'une proposition commerciale (non facturée) From 5da4d0262e2eda2f5def95195854ee52ae60a3c1 Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 17:28:44 +0100 Subject: [PATCH 013/120] =?UTF-8?q?[CORE]=20ajouts=20des=20conditions=20n?= =?UTF-8?q?=C3=A9cessaire=20pour=20l'int=C3=A9gration=20du=20module=20(#ne?= =?UTF-8?q?w=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/class/html.formfile.class.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 274fa19a417..ef6f3fe225d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -273,7 +273,7 @@ class FormFile } $printer=0; - if (in_array($modulepart,array('facture','propal','proposal','order','commande','expedition'))) // This feature is implemented only for such elements + if (in_array($modulepart,array('facture', 'askpricesupplier','propal','proposal','order','commande','expedition'))) // This feature is implemented only for such elements { $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; } @@ -316,6 +316,15 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; $modellist=ModelePDFPropales::liste_modeles($this->db); } + } + else if ($modulepart == 'askpricesupplier') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once DOL_DOCUMENT_ROOT.'/core/modules/askpricesupplier/modules_askpricesupplier.php'; + $modellist=ModelePDFAskPriceSupplier::liste_modeles($this->db); + } } else if ($modulepart == 'commande') { @@ -923,6 +932,11 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $object_instance=new Propal($this->db); } + else if ($modulepart == 'askpricesupplier') + { + include_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; + $object_instance=new AskPriceSupplier($this->db); + } else if ($modulepart == 'order') { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -984,6 +998,7 @@ class FormFile if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } if ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices if ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } + if ($modulepart == 'askpricesupplier') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } if ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } if ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } if ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); } From b3b9527e32d0bbd7c250fa4d911b88509e503d6b Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 28 Jan 2015 17:29:14 +0100 Subject: [PATCH 014/120] [CORE] ajouts de traductions pour le module (#new_ask_price). --- htdocs/langs/fr_FR/admin.lang | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index e8c8f6dd1a2..49e6a6a22ec 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1151,6 +1151,13 @@ UseOptionLineIfNoQuantity=Une ligne de produit/service ayant une quantité nulle FreeLegalTextOnProposal=Mention complémentaire sur les propositions commerciales WatermarkOnDraftProposal=Filigrane sur les brouillons de propositions commerciales (aucun si vide) BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL=Saisir le compte bancaire cible lors de la proposition commerciale +##### AskPriceSupplier ##### +AskPriceSupplierSetup=Configuration du module Demandes de Prix Fournisseurs +AskPriceSupplierNumberingModules=Modèles de numérotation des demandes de prix fournisseurs +AskPriceSupplierPDFModules=Modèles de documents de demandes de prix fournisseurs +AskPriceSupplierPDFModules=Modèles de documents de demandes de prix fournisseurs +FreeLegalTextOnAskPriceSupplier=Mention complémentaire sur les demandes de prix fournisseurs +WatermarkOnDraftAskPriceSupplier=Filigrane sur les brouillons de demandes de prix (aucun si vide) ##### Orders ##### OrdersSetup=Configuration du module Commandes OrdersNumberingModules=Modèles de numérotation des commandes From a58899d354cd7ebf1471b0ec7a5dab9eb3c61633 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 10:41:08 +0100 Subject: [PATCH 015/120] [CORE] ajout d'une condition pour le fonctionnement du module (#new_ask_price). --- htdocs/core/tpl/contacts.tpl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 6aaf0f5f28d..b8b124b731a 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -27,6 +27,7 @@ $module = $object->element; // Special cases if ($module == 'propal') { $permission=$user->rights->propale->creer; } +elseif ($module == 'askpricesupplier') { $permission=$user->rights->askpricesupplier->creer; } elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; } From 77e4619fe2da1aa9d9a3e8db54db92a27d443bfe Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 10:41:46 +0100 Subject: [PATCH 016/120] [CORE] correction de nom de fonction pour un appel correct (#new_ask_price). --- htdocs/comm/askpricesupplier/contact.php | 4 ++-- htdocs/comm/askpricesupplier/document.php | 4 ++-- htdocs/comm/askpricesupplier/info.php | 2 +- htdocs/comm/askpricesupplier/note.php | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/askpricesupplier/contact.php b/htdocs/comm/askpricesupplier/contact.php index 7ebb852d9bb..fbaf02ba7d8 100644 --- a/htdocs/comm/askpricesupplier/contact.php +++ b/htdocs/comm/askpricesupplier/contact.php @@ -149,7 +149,7 @@ $formother = new FormOther($db); if ($object->id > 0) { - $head = propal_prepare_head($object); + $head = askpricesupplier_prepare_head($object); dol_fiche_head($head, 'contact', $langs->trans("CommRequest"), 0, 'askpricesupplier'); /* @@ -198,7 +198,7 @@ if ($object->id > 0) } else { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id); + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','askpricesupplier',$object->id); } print '
'; @@ -126,7 +126,7 @@ if ($id > 0 || ! empty($ref)) if ($object->fin_validite) { print dol_print_date($object->fin_validite,'daytext'); - if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + if ($object->statut == 1 && $object->fin_validite < ($now - $conf->askpricesupplier->cloture->warning_delay)) print img_warning($langs->trans("Late")); } else { From 87398c7d43bafe7dff78b3dc22b97b5768d72c75 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 10:42:53 +0100 Subject: [PATCH 017/120] =?UTF-8?q?[CORE]=20renomage=20de=20variables=20po?= =?UTF-8?q?ur=20=C3=AAtre=20en=20rapport=20avec=20le=20module=20(#new=5Fas?= =?UTF-8?q?k=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/askpricesupplier.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/askpricesupplier.php b/htdocs/admin/askpricesupplier.php index 819aa64c471..ae3f78ca3ce 100644 --- a/htdocs/admin/askpricesupplier.php +++ b/htdocs/admin/askpricesupplier.php @@ -31,11 +31,11 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/askpricesupplier/class/askpricesupplier.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/askpricesupplier.lib.php'; $langs->load("admin"); $langs->load("errors"); $langs->load('other'); -$langs->load('propal'); +$langs->load('askpricesupplier'); if (! $user->admin) accessforbidden(); @@ -324,7 +324,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; print '' . "\n"; // Contacts (ask contact only if thirdparty already defined). TODO do this also into order and invoice. + /* PHFAVRE retrait en temporaire if ($socid > 0) { print "'; } - + */ // Date print ''; // Validaty duration + /* PHFAVRE retrait en temporaire print ''; - + */ + // Terms of payment print '"; // Project + /* PHFAVRE retrait en temporaire if (! empty($conf->projet->enabled) && $socid > 0) { $formproject = new FormProjets($db); @@ -1408,7 +1412,8 @@ if ($action == 'create') print ''; print ''; } - + */ + // Other attributes $parameters = array('colspan' => ' colspan="3"'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified From a3c29f2e9ca89be6a3b8dc01e549e376995a1dd9 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 2 Feb 2015 15:41:14 +0100 Subject: [PATCH 036/120] =?UTF-8?q?[CORE]=20Avancement=20du=20fonctionneme?= =?UTF-8?q?nt=20du=20module,=20correction=20bug=20et=20=C3=A9puration=20de?= =?UTF-8?q?=20l'affichage=20(#new=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/askpricesupplier.php | 73 ++++++++++----- .../class/askpricesupplier.class.php | 92 +++++++++++++++---- .../mod_askpricesupplier_marbre.php | 6 +- .../mod_askpricesupplier_saphir.php | 6 +- .../modules/modAskPriceSupplier.class.php | 14 --- htdocs/langs/fr_FR/askpricesupplier.lang | 4 +- 6 files changed, 135 insertions(+), 60 deletions(-) diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index 46533a84210..cf296ef9417 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -249,18 +249,12 @@ if (empty($reshook)) $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $duration = GETPOST('duree_validite'); if (empty($datep)) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); $action = 'create'; $error ++; } - if (empty($duration)) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); - $action = 'create'; - $error ++; - } if ($socid < 1) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); @@ -969,7 +963,7 @@ if (empty($reshook)) } } - else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) { + else if ($action == 'updateligne' && $user->rights->askpricesupplier->creer && GETPOST('cancel') == $langs->trans('Cancel')) { header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -1664,6 +1658,7 @@ if ($action == 'create') print ''; // Ref customer + /* PHFAVRE retrait en temporaire print '
'; - if ($conf->global->PROPALE_ADDON == "$file") + if ($conf->global->ASKPRICESUPPLIER_ADDON == "$file") { print img_picto($langs->trans("Activated"),'switch_on'); } From 770ce6b4ccbb22da54398ac8a524b07fdddd8c1d Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 10:43:46 +0100 Subject: [PATCH 018/120] =?UTF-8?q?[CORE]=20renomage=20d=20evariables=20po?= =?UTF-8?q?ur=20=C3=AAtre=20en=20rapport=20avec=20le=20module=20(#new=5Fas?= =?UTF-8?q?k=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/askpricesupplier.php | 4 ++-- htdocs/comm/askpricesupplier/class/askpricesupplier.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index f1ea1cde9f0..da35edf54a9 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -2028,7 +2028,7 @@ if ($action == 'create') $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line - if ($object->statut == 0 && $user->rights->propal->creer) + if ($object->statut == 0 && $user->rights->askpricesupplier->creer) { if ($action != 'editline') { @@ -2117,7 +2117,7 @@ if ($action == 'create') // Send if ($object->statut == 1 || $object->statut == 2) { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->askpricesupplier->propal_advance->send) { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->askpricesupplier->send) { print ''; } else print ''; diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php index 2deb897a192..49af98252e4 100644 --- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php +++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php @@ -1335,7 +1335,7 @@ class AskPriceSupplier extends CommonObject $now=dol_now(); if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->propal_advance->validate))) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->validate))) { $this->db->begin(); From c9e74fbceaf211953b43358ad969d4ee4ba3b6a6 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 10:44:03 +0100 Subject: [PATCH 019/120] [CORE] ajout d'une trad (#new_ask_price). --- htdocs/langs/fr_FR/askpricesupplier.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang index 7234366b0e6..e05a66dad10 100644 --- a/htdocs/langs/fr_FR/askpricesupplier.lang +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -19,7 +19,6 @@ NewProposal=Nouvelle proposition commerciale NewPropal=Nouvelle proposition Prospect=Prospect ProspectList=Liste des prospects -ConfirmDeleteProp=Êtes-vous sûr de vouloir effacer cette proposition commerciale ? LastPropals=Les %s dernières propales LastClosedProposals=Les %s dernières propositions commerciales fermées @@ -78,6 +77,7 @@ ConfirmReOpenAsk=Êtes-vous sûr de vouloir réouvrir la demande de prix %s Date: Thu, 29 Jan 2015 10:44:23 +0100 Subject: [PATCH 020/120] [CORE] maj mineur (#new_ask_price). --- htdocs/core/modules/modAskPriceSupplier.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAskPriceSupplier.class.php b/htdocs/core/modules/modAskPriceSupplier.class.php index 53a1552445d..66861061981 100644 --- a/htdocs/core/modules/modAskPriceSupplier.class.php +++ b/htdocs/core/modules/modAskPriceSupplier.class.php @@ -48,13 +48,13 @@ class modAskPriceSupplier extends DolibarrModules $this->db = $db; $this->numero = 999999; - $this->family = "crm"; + $this->family = "products"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "askpricesupplierDESC"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = '0.1'; + $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; @@ -140,6 +140,12 @@ class modAskPriceSupplier extends DolibarrModules $this->rights[$r][1] = 'Supprimer les demandes fournisseurs'; // libelle de la permission $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'supprimer'; + + $r++; + $this->rights[$r][0] = $this->numero + $r; // id de la permission + $this->rights[$r][1] = 'Cloturer les demandes de prix fournisseurs'; // libelle de la permission + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'cloturer'; // Exports //-------- From ffb533a4e462724788dc5b61a152321b2f5ce6b3 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 12:11:14 +0100 Subject: [PATCH 021/120] =?UTF-8?q?[CORE]=20gestion=20du=20prix=20lors=20d?= =?UTF-8?q?e=20l'ajout=20d'un=20produit=20d=C3=A9j=C3=A0=20existant=20(#ne?= =?UTF-8?q?w=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/askpricesupplier.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index da35edf54a9..fdace17d19b 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -696,8 +696,13 @@ if (empty($reshook)) // If prices fields are update $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; + + //On garde le prix indiqué dans l'input pour la demande de prix fournisseur + //$pu_ht = $prod->price; + $pu_ht = price2num($price_ht, 'MU'); + //$pu_ttc = $prod->price_ttc; + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; From 2f8ceea587a91751c7548b9ee155c8428350252c Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 12:12:22 +0100 Subject: [PATCH 022/120] [CORE] renomage de variables pour le module + modification de traductions (#new_ask_price). --- htdocs/comm/askpricesupplier/apercu.php | 2 +- htdocs/core/lib/askpricesupplier.lib.php | 4 ++-- .../doc/doc_generic_askpricesupplier_odt.modules.php | 4 ++-- htdocs/langs/fr_FR/askpricesupplier.lang | 5 ++--- htdocs/langs/fr_FR/main.lang | 1 + 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/askpricesupplier/apercu.php b/htdocs/comm/askpricesupplier/apercu.php index a434bca9354..2486091f184 100644 --- a/htdocs/comm/askpricesupplier/apercu.php +++ b/htdocs/comm/askpricesupplier/apercu.php @@ -133,7 +133,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - print ''; + print ''; print ''; diff --git a/htdocs/core/lib/askpricesupplier.lib.php b/htdocs/core/lib/askpricesupplier.lib.php index 1c3835e78be..0cdf15a09a0 100644 --- a/htdocs/core/lib/askpricesupplier.lib.php +++ b/htdocs/core/lib/askpricesupplier.lib.php @@ -39,7 +39,7 @@ function askpricesupplier_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier.php?id='.$object->id; - $head[$h][1] = $langs->trans('ProposalCard'); + $head[$h][1] = $langs->trans('AskPriceSupplierCard'); $head[$h][2] = 'comm'; $h++; @@ -89,7 +89,7 @@ function askpricesupplier_prepare_head($object) } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->askpricesupplier->dir_output . "/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); $head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); diff --git a/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php b/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php index 80c1a0bd347..ddc995cc69a 100644 --- a/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php @@ -230,7 +230,7 @@ class doc_generic_askpricesupplier_odt extends ModelePDFAskPriceSupplier $outputlangs->load("companies"); $outputlangs->load("bills"); - if ($conf->propal->dir_output) + if ($conf->askpricesupplier->dir_output) { // If $object is id instead of object if (! is_object($object)) @@ -245,7 +245,7 @@ class doc_generic_askpricesupplier_odt extends ModelePDFAskPriceSupplier } } - $dir = $conf->propal->dir_output; + $dir = $conf->askpricesupplier->dir_output; $objectref = dol_sanitizeFileName($object->ref); if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; $file = $dir . "/" . $objectref . ".odt"; diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang index e05a66dad10..a945774f836 100644 --- a/htdocs/langs/fr_FR/askpricesupplier.lang +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -13,7 +13,6 @@ ProposalsDraft=Propositions commerciales brouillons ProposalDraft=Proposition commerciale brouillon ProposalsOpened=Propositions commerciales ouvertes Prop=Propositions commerciales -ProposalCard=Fiche proposition NewProp=Nouvelle proposition commerciale NewProposal=Nouvelle proposition commerciale NewPropal=Nouvelle proposition @@ -77,6 +76,7 @@ ConfirmReOpenAsk=Êtes-vous sûr de vouloir réouvrir la demande de prix %s Date: Thu, 29 Jan 2015 12:13:06 +0100 Subject: [PATCH 023/120] [CORE] ajouts des conditions pour le fonctionnement avec le module (#new_ask_price). --- htdocs/core/tpl/objectline_create.tpl.php | 17 +++++++++++------ htdocs/core/tpl/objectline_edit.tpl.php | 4 ++-- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 0c345aee5ac..136c751a87c 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -31,7 +31,7 @@ $usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal', 'askpricesupplier','commande'))) $usemargins=1; global $forceall, $senderissupplier, $inputalsopricewithtax; if (empty($dateSelector)) $dateSelector=0; @@ -43,7 +43,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; // Define colspan for button Add $colspan = 3; // Col total ht + col edit + col delete if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc -if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button +if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button ?> @@ -211,7 +211,7 @@ else { @@ -270,6 +270,9 @@ else { elseif ($this->table_element_line=='propaldet') { $newline = new PropaleLigne($this->db); } + elseif ($this->table_element_line=='askpricesupplierdet') { + $newline = new AskPriceSupplierLigne($this->db); + } elseif ($this->table_element_line=='facturedet') { $newline = new FactureLigne($this->db); } @@ -287,7 +290,7 @@ if (! empty($conf->service->enabled) && $dateSelector && GETPOST('type') != '0') else $colspan = 9; if($this->situation_cycle_ref) $colspan++; if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc - if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button + if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button if (! empty($usemargins)) { @@ -562,12 +565,14 @@ function setforpredef() { jQuery("#select_type").val(-1); jQuery("#prod_entry_mode_free").attr('checked',false); jQuery("#prod_entry_mode_predef").attr('checked',true); - jQuery("#price_ht").hide(); + element != 'askpricesupplier') { ?> + jQuery("#price_ht").hide(); + jQuery("#title_up_ht").hide(); + jQuery("#price_ttc").hide(); // May no exists jQuery("#tva_tx").hide(); jQuery("#buying_price").show(); jQuery("#title_vat").hide(); - jQuery("#title_up_ht").hide(); jQuery("#title_up_ttc").hide(); jQuery("#np_marginRate").hide(); // May no exists jQuery("#np_markRate").hide(); // May no exists diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index fd2e3e0d469..fa4dcdc5a4a 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -31,7 +31,7 @@ $usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal', 'askpricesupplier','commande'))) $usemargins=1; global $forceall, $senderissupplier, $inputalsopricewithtax; if (empty($dateSelector)) $dateSelector=0; @@ -43,7 +43,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; // Define colspan for button Add $colspan = 3; // Col total ht + col edit + col delete if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc -if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button +if (in_array($object->element,array('propal', 'askpricesupplier','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 2e1cc0f3678..f484b013ba2 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -32,7 +32,7 @@ */ $usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal', 'askpricesupplier','commande'))) $usemargins=1; global $forceall, $senderissupplier, $inputalsopricewithtax; if (empty($dateSelector)) $dateSelector=0; From aba3ec06120cbdebc770801004ecbc7ac63e4800 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 12:26:50 +0100 Subject: [PATCH 024/120] [CORE] modification de l'affiche du PDF (#new_ask_price). --- .../doc/pdf_aurore.modules.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php index 347677ea1d9..ed486d4f076 100644 --- a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php @@ -102,8 +102,8 @@ class pdf_aurore extends ModelePDFAskPriceSupplier // Define position of columns $this->posxdesc=$this->marge_gauche+1; - $this->posxtva=112; - $this->posxup=126; + $this->posxtva=102; + $this->posxup=116; $this->posxqty=145; $this->posxdiscount=162; $this->postotalht=174; @@ -425,7 +425,7 @@ class pdf_aurore extends ModelePDFAskPriceSupplier { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); + $pdf->MultiCell($this->posxup-$this->posxtva-3, 3, $vat_rate, 0, 'R'); } // Unit price before discount @@ -1124,19 +1124,20 @@ class pdf_aurore extends ModelePDFAskPriceSupplier if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); + //$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); + $pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtva-3, $tab_top+1); + $pdf->SetXY($this->posxtva-5, $tab_top+1); $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); } } - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + $pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); + $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("AskPriceSupplierUHT"),'','C'); } $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); @@ -1181,7 +1182,7 @@ class pdf_aurore extends ModelePDFAskPriceSupplier $outputlangs->load("main"); $outputlangs->load("bills"); - $outputlangs->load("propal"); + $outputlangs->load("askpricesupplier"); $outputlangs->load("companies"); $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1228,7 +1229,7 @@ class pdf_aurore extends ModelePDFAskPriceSupplier $pdf->SetFont('','B',$default_font_size + 3); $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $title=$outputlangs->transnoentities("CommercialProposal"); + $title=$outputlangs->transnoentities("CommercialAsk"); $pdf->MultiCell(100, 4, $title, '', 'R'); $pdf->SetFont('','B',$default_font_size); From 3b0fd5ec98a3f96870131da0b1ab2417ce3f7cf0 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 29 Jan 2015 17:36:12 +0100 Subject: [PATCH 025/120] =?UTF-8?q?[CORE]=20modification=20l=C3=A9g=C3=A8r?= =?UTF-8?q?e,=20d=C3=A9but=20de=20redirection=20pour=20cr=C3=A9er=20une=20?= =?UTF-8?q?commande=20fournisseur=20si=20la=20demande=20est=20acc=C3=A9pt?= =?UTF-8?q?=C3=A9=20(#new=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/askpricesupplier.php | 2 +- htdocs/fourn/commande/card.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index fdace17d19b..cf40e62643e 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -2131,7 +2131,7 @@ if ($action == 'create') // Create an order if (! empty($conf->commande->enabled) && $object->statut == 2) { if ($user->rights->commande->creer) { - print ''; + print ''; } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 15fdbc70722..e6104d866aa 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -52,6 +52,7 @@ $langs->load('sendings'); $langs->load('companies'); $langs->load('bills'); $langs->load('propal'); +$langs->load('askpricesupplier'); $langs->load('deliveries'); $langs->load('products'); $langs->load('stocks'); From 9a289537be97cd69b89cd85d390045f1475fc0e9 Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 30 Jan 2015 16:50:46 +0100 Subject: [PATCH 026/120] [CORE] maj du code + ajout d'une fonction pour le module (#new_ask_price). --- htdocs/comm/askpricesupplier.php | 29 ++++++++---------- .../class/askpricesupplier.class.php | 30 +++++++++++++++++++ htdocs/comm/askpricesupplier/index.php | 8 ++--- htdocs/comm/askpricesupplier/list.php | 4 +-- 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index cf40e62643e..dc0abc68642 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -177,7 +177,7 @@ if (empty($reshook)) ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->validate))) ) - { + { $result = $object->valid($user); if ($result >= 0) { @@ -543,19 +543,6 @@ if (empty($reshook)) } } - // Close proposal - else if ($action == 'setstatut' && $user->rights->askpricesupplier->cloturer && ! GETPOST('cancel')) { - if (! GETPOST('statut')) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); - $action = 'statut'; - } else { - // prevent browser refresh from closing proposal several times - if ($object->statut == 1) { - $object->cloture($user, GETPOST('statut'), GETPOST('note')); - } - } - } - // Classify billed else if ($action == 'classifybilled' && $user->rights->askpricesupplier->cloturer) { $object->cloture($user, 4, ''); @@ -1284,9 +1271,11 @@ if ($action == 'create') print ''; // Ref customer + /* PHFAVRE retrait en temporaire print ''; print ''; + */ // Third party print ''; @@ -1355,15 +1344,19 @@ if ($action == 'create') } // What trigger creation + /* PHFAVRE retrait en temporaire print ''; - + */ + // Delivery delay + /* PHFAVRE retrait en temporaire print ''; - + */ + // Shipping Method if (! empty($conf->expedition->enabled)) { print ''; print ''; - + */ + // Model print ''; print ''; diff --git a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php index 49af98252e4..8ac09582339 100644 --- a/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php +++ b/htdocs/comm/askpricesupplier/class/askpricesupplier.class.php @@ -31,6 +31,7 @@ * \brief File of class to manage proposals */ +require_once DOL_DOCUMENT_ROOT .'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php'; @@ -1784,6 +1785,10 @@ class AskPriceSupplier extends CommonObject $this->db->rollback(); return -2; } + else + { + $this->updatePriceFournisseur(); + } } if ($statut == 4) { @@ -1828,6 +1833,31 @@ class AskPriceSupplier extends CommonObject } } + function updatePriceFournisseur() + { + $productsupplier = new ProductFournisseur($this->db); + + dol_syslog(get_class($this)."::updatePriceFournisseur", LOG_DEBUG); + foreach ($this->lines as $product) { + $idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty); + $res = $productsupplier->fetch($idProductFourn); + + $price=price2num($product->subprice*$product->qty,'MU'); + //$qty=price2num($product->qty); + $unitPrice = price2num($product->subprice,'MU'); + + //$sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET price ='.$price.', quantity ='.$qty.', unitprice ='.$unitPrice.' WHERE rowid = '.$productsupplier->product_fourn_price_id; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$productsupplier->product_fourn_price_id; + + $resql=$this->db->query($sql); + if (!resql) { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + } + /** * Class invoiced the Propal * diff --git a/htdocs/comm/askpricesupplier/index.php b/htdocs/comm/askpricesupplier/index.php index ef9a37f145c..7684664c56b 100644 --- a/htdocs/comm/askpricesupplier/index.php +++ b/htdocs/comm/askpricesupplier/index.php @@ -152,7 +152,7 @@ else /* * Draft proposals */ -if (! empty($conf->propal->enabled)) +if (! empty($conf->askpricesupplier->enabled)) { $sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client"; $sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as c"; @@ -258,7 +258,7 @@ if ($resql) print '
'.$langs->trans("Documents").'
'.$langs->trans("Proposal").' PDF
'.$langs->trans("CommRequest").' PDF'.$object->ref.'.pdf - + element == 'askpricesupplier' || GETPOST('prod_entry_mode') != 'predef') { ?> ">
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; print '
' . $langs->trans('Source') . ''; $form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1); print '
' . $langs->trans('AvailabilityPeriod') . ''; $form->selectAvailabilityDelay('', 'availability_id', '', 1); print '
' . $langs->trans('SendingMethod') . ''; @@ -1372,6 +1365,7 @@ if ($action == 'create') } // Delivery date (or manufacturing) + /* PHFAVRE retrait en temporaire print '
' . $langs->trans("DeliveryDate") . ''; if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { @@ -1384,7 +1378,8 @@ if ($action == 'create') $form->select_date(-1, 'liv_', '', '', '', "addask", 1, 1); } print '
' . $langs->trans("DefaultModel") . ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir); print '
'; @@ -291,7 +291,7 @@ if (! empty($conf->askpricesupplier->enabled) && $user->rights->askpricesupplier $now=dol_now(); - $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; + $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as askpricesupplierid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."askpricesupplier as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -325,7 +325,7 @@ if (! empty($conf->askpricesupplier->enabled) && $user->rights->askpricesupplier // Ref print '
'; - $askpricesupplierstatic->id=$obj->propalid; + $askpricesupplierstatic->id=$obj->askpricesupplierid; $askpricesupplierstatic->ref=$obj->ref; print ''; diff --git a/htdocs/comm/askpricesupplier/list.php b/htdocs/comm/askpricesupplier/list.php index 47eb078d401..148156f4da2 100644 --- a/htdocs/comm/askpricesupplier/list.php +++ b/htdocs/comm/askpricesupplier/list.php @@ -357,7 +357,7 @@ if ($result) if (! empty($objp->note_private)) { print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; + print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; print ''; } print ''; @@ -365,7 +365,7 @@ if ($result) // Ref print '
'; $filename=dol_sanitizeFileName($objp->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($objp->ref); + $filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->askpricesupplierid; print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '
'; From d2cd78884e22c229e081213611543eb67bd68e9c Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 30 Jan 2015 16:52:14 +0100 Subject: [PATCH 027/120] =?UTF-8?q?[CORE]=20ajout=20de=20code=20n=C3=A9ces?= =?UTF-8?q?saire=20pour=20le=20fonctionnement=20du=20module=20pour=20cr?= =?UTF-8?q?=C3=A9er=20une=20code=20fournisseur=20depuis=20une=20demande=20?= =?UTF-8?q?valid=C3=A9=20et=20acc=C3=A9pt=C3=A9=20(#new=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/fourn/commande/card.php | 301 ++++++++++++++++++++++++++++++--- 1 file changed, 275 insertions(+), 26 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index e6104d866aa..5073d5433cb 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -65,6 +65,10 @@ $comclientid = GETPOST('comid','int'); $socid = GETPOST('socid','int'); $projectid = GETPOST('projectid','int'); +$lineid = GETPOST('lineid', 'int'); +$origin = GETPOST('origin', 'alpha'); +$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility + //PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); @@ -846,29 +850,180 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer) $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + // If creation from another object of another module (Example: origin=propal, originid=1) + if (! empty($origin) && ! empty($originid)) { + // Parse element/subelement (ex: project_task) + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { + $element = $regs [1]; + $subelement = $regs [2]; + } - $id = $object->create($user); - if ($id < 0) - { - $error++; + $element = 'comm/askpricesupplier'; + $subelement = 'askpricesupplier'; + + $object->origin = $origin; + $object->origin_id = $originid; + + // Possibility to add external linked objects with hooks + $object->linked_objects [$object->origin] = $object->origin_id; + $other_linked_objects = GETPOST('other_linked_objects', 'array'); + if (! empty($other_linked_objects)) { + $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); + } + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) + $error ++; + + if (! $error) + { + $object_id = $object->create($user); + + if ($object_id > 0) + { + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + { + $srcobject->fetch_lines(); + $lines = $srcobject->lines; + } + + $fk_parent_line = 0; + $num = count($lines); + + $productsupplier = new ProductFournisseur($db); + + for($i = 0; $i < $num; $i ++) + { + $label = (! empty($lines [$i]->label) ? $lines [$i]->label : ''); + $desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle); + $product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0); + + // Dates + // TODO mutualiser + $date_start = $lines [$i]->date_debut_prevue; + if ($lines [$i]->date_debut_reel) + $date_start = $lines [$i]->date_debut_reel; + if ($lines [$i]->date_start) + $date_start = $lines [$i]->date_start; + $date_end = $lines [$i]->date_fin_prevue; + if ($lines [$i]->date_fin_reel) + $date_end = $lines [$i]->date_fin_reel; + if ($lines [$i]->date_end) + $date_end = $lines [$i]->date_end; + + // Reset fk_parent_line for no child products and special product + if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) // For avoid conflicts if + // trigger used + { + $lines [$i]->fetch_optionals($lines [$i]->rowid); + $array_option = $lines [$i]->array_options; + } +/* + $idprod=$productsupplier->get_buyprice($lines [$i]->fk_fournprice, $qty); + $res = $productsupplier->fetch($idprod); + */ + + $idprod = $productsupplier->find_min_price_product_fournisseur($lines [$i]->fk_product, $qty); + $res = $productsupplier->fetch($idProductFourn); + + $result = $object->addline( + $desc, + $lines [$i]->subprice, + $lines [$i]->qty, + $lines [$i]->tva_tx, + $lines [$i]->localtax1_tx, + $lines [$i]->localtax2_tx, + $productsupplier->id, + $lines [$i]->fk_product, + $productsupplier->ref_fourn, + $lines [$i]->remise_percent, + 'HT', + 0, + $lines [$i]->product_type, + '', + '', + $date_start, + $date_end + ); + + if ($result < 0) { + $error ++; + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines [$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) + $error ++; + } else { + setEventMessage($srcobject->error, 'errors'); + $error ++; + } + } else { + setEventMessage($object->error, 'errors'); + $error ++; + } + } else { + // Required extrafield left blank, error message already defined by setOptionalsFromPost() + $action = 'create'; + } + } else { + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) + $error ++; + + if (! $error) { + $object_id = $object->create($user); + + // If some invoice's lines already known + $NBLINES = 8; + for($i = 1; $i <= $NBLINES; $i ++) { + if ($_POST['idprod' . $i]) { + $xid = 'idprod' . $i; + $xqty = 'qty' . $i; + $xremise = 'remise_percent' . $i; + $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); + } + } + } + } + + // End of object creation, we show it + if ($object_id > 0 && ! $error) { + $db->commit(); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object_id); + exit(); + } else { + $db->rollback(); + $action = 'create'; + setEventMessage($object->error, 'errors'); } - - if ($error) - { - $langs->load("errors"); - $db->rollback(); - setEventMessage($langs->trans($object->error), 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; - } - else - { - $db->commit(); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; - } } } @@ -1221,7 +1376,7 @@ $productstatic = new Product($db); /* *************************************************************************** */ $now=dol_now(); -if ($action=="create") +if ($action=='create') { print_fiche_titre($langs->trans('NewOrder')); @@ -1234,12 +1389,67 @@ if ($action=="create") $societe->fetch($socid); } - $cond_reglement_id = $societe->cond_reglement_supplier_id; - $mode_reglement_id = $societe->mode_reglement_supplier_id; + if (! empty($origin) && ! empty($originid)) { + // Parse element/subelement (ex: project_task) + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { + $element = $regs [1]; + $subelement = $regs [2]; + } + + $element = 'comm/askpricesupplier'; + $subelement = 'askpricesupplier'; + + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + $classname = ucfirst($subelement); + $objectsrc = new $classname($db); + $objectsrc->fetch($originid); + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) + $objectsrc->fetch_lines(); + $objectsrc->fetch_thirdparty(); + + // Replicate extrafields + $objectsrc->fetch_optionals($originid); + $object->array_options = $objectsrc->array_options; + + $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); + $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + + $soc = $objectsrc->client; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); + $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); + $shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + + $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + + $note_private = (! empty($objectsrc->note_private) ? $objectsrc->note_private : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); + $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); + + // Object source contacts list + $srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1); + + } + else + { + $cond_reglement_id = $societe->cond_reglement_supplier_id; + $mode_reglement_id = $societe->mode_reglement_supplier_id; + } + print ''; print ''; print ''; + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; // Ref @@ -1287,7 +1497,7 @@ if ($action=="create") print ''; print ''; //print ''; @@ -1295,13 +1505,40 @@ if ($action=="create") print ''; print ''; //print ''; print ''; + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + print "\n"; + print "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print ''; + print ''; + + $newclassname = $classname; + if ($newclassname == 'AskPriceSupplier') + $newclassname = 'CommercialAskPriceSupplier'; + print ''; + print ''; + print '"; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE + { + print '"; + } + + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF + { + print '"; + } + + print '"; + } // Other options $parameters=array(); @@ -1318,6 +1555,18 @@ if ($action=="create") print '
'; print "\n"; + + // Show origin lines + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + $title = $langs->trans('ProductsAndServices'); + print_titre($title); + + print '
'.$langs->trans('NotePublic').''; - $doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); print '
'.$langs->trans('NotePrivate').''; - $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); print '
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . '
' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . "
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . "
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
'; + + $objectsrc->printOriginLinesList(); + + print '
'; + } } elseif (! empty($object->id)) { From f60ed2b1538ed248ee23f0457f6a31a95c5c01c2 Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 30 Jan 2015 16:53:31 +0100 Subject: [PATCH 028/120] [CORE] ajout de traductions pour le module (#new_ask_price). --- htdocs/langs/fr_FR/askpricesupplier.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang index a945774f836..146a0db9938 100644 --- a/htdocs/langs/fr_FR/askpricesupplier.lang +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -39,8 +39,10 @@ DraftRequests=Demandes brouillons LastModifiedRequests=Les %s dernières demandes de prix modifiées RequestsOpened=Demandes de prix ouvertes AskPriceSupplierArea=Espace des demandes de prix fournisseurs +Askpricesupplier=Demande de prix fournisseur NewAskPrice=Nouvelle demande de prix NewAsk=Nouvelle demande +ShowAskpricesupplier=Afficher la demande de prix # # Modifié ConfirmValidateAsk=Êtes-vous sûr de vouloir valider cette demande de prix sous la référence %s ? DateAsk=Date de demande From 18cb313348d6382f4cbf5b3e16055075e53d290a Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 30 Jan 2015 16:54:50 +0100 Subject: [PATCH 029/120] [CORE] ajout du nom du module dans $childtables pour le bon fonctionnement du module (#new_ask_price). --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a889136de01..5c75ba4dbf6 100755 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -42,7 +42,7 @@ class Product extends CommonObject public $element='product'; public $table_element='product'; public $fk_element='fk_product'; - protected $childtables=array('propaldet','commandedet','facturedet','contratdet','facture_fourn_det','commande_fournisseurdet'); // To test if we can delete object + protected $childtables=array('askpricesupplierdet', 'propaldet','commandedet','facturedet','contratdet','facture_fourn_det','commande_fournisseurdet'); // To test if we can delete object protected $isnolinkedbythird = 1; // No field fk_soc protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe From d39439437e49cb75354be441b701e749d618b18d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 31 Jan 2015 13:50:18 +0100 Subject: [PATCH 030/120] Add fetch optionnals extrafield on contract lines --- htdocs/contrat/class/contrat.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9619ae462f4..d5d0d3309dc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -641,6 +641,11 @@ class Contrat extends CommonObject $now=dol_now(); + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafieldsline=new ExtraFields($this->db); + $line = new ContratLigne($this->db); + $extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true); + $this->lines=array(); // Selectionne les lignes contrats liees a un produit @@ -719,6 +724,11 @@ class Contrat extends CommonObject $line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite); $line->date_fin_reel = $this->db->jdate($objp->date_cloture); + // Retreive all extrafield for propal + // fetch optionals attributes and labels + + $line->fetch_optionals($line->id,$extralabelsline); + $this->lines[] = $line; //dol_syslog("1 ".$line->desc); @@ -814,6 +824,13 @@ class Contrat extends CommonObject if ($line->statut == 4 && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; if ($line->statut == 5) $this->nbofservicesclosed++; + + // Retreive all extrafield for propal + // fetch optionals attributes and labels + + $line->fetch_optionals($line->id,$extralabelsline); + + $this->lines[] = $line; $total_ttc+=$objp->total_ttc; From 1eb73d0e495b4067454b2ead144f0c07ecb7f54e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 31 Jan 2015 13:52:23 +0100 Subject: [PATCH 031/120] fetch optional extrafeild lines on propal fetch --- htdocs/comm/propal/class/propal.class.php | 16 +++++++++------- htdocs/contrat/class/contrat.class.php | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f68a1f4f708..be945c7027e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1196,6 +1196,11 @@ class Propal extends CommonObject $result = $this->db->query($sql); if ($result) { + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafieldsline=new ExtraFields($this->db); + $line = new PropaleLigne($this->db); + $extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true); + $num = $this->db->num_rows($result); $i = 0; @@ -1205,7 +1210,8 @@ class Propal extends CommonObject $line = new PropaleLigne($this->db); - $line->rowid = $objp->rowid; + $line->rowid = $objp->rowid; //Deprecated + $line->id = $objp->rowid; $line->fk_propal = $objp->fk_propal; $line->fk_parent_line = $objp->fk_parent_line; $line->product_type = $objp->product_type; @@ -1246,6 +1252,8 @@ class Propal extends CommonObject $line->date_start = $objp->date_start; $line->date_end = $objp->date_end; + $line->fetch_optionals($line->id,$extralabelsline); + $this->lines[$i] = $line; //dol_syslog("1 ".$line->fk_product); //print "xx $i ".$this->lines[$i]->fk_product; @@ -1259,12 +1267,6 @@ class Propal extends CommonObject return -1; } - // Retreive all extrafield for propal - // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); return 1; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d5d0d3309dc..21430ecca5b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -726,7 +726,6 @@ class Contrat extends CommonObject // Retreive all extrafield for propal // fetch optionals attributes and labels - $line->fetch_optionals($line->id,$extralabelsline); $this->lines[] = $line; From 85a4df4ce25766652002cf514ac7cf8b7d186d40 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 2 Feb 2015 10:06:36 +0100 Subject: [PATCH 032/120] [CORE] maj du pdf, champs PU HT et Total HT vide (#new_ask_price). --- .../core/modules/askpricesupplier/doc/pdf_aurore.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php index ed486d4f076..a1c613339a3 100644 --- a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php @@ -431,7 +431,7 @@ class pdf_aurore extends ModelePDFAskPriceSupplier // Unit price before discount $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); + //$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); @@ -449,7 +449,7 @@ class pdf_aurore extends ModelePDFAskPriceSupplier // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + //$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $tvaligne=$object->lines[$i]->total_tva; From 0f7af613f11b41f13bfc27aad02990332cd470c0 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 2 Feb 2015 10:24:42 +0100 Subject: [PATCH 033/120] =?UTF-8?q?[CORE]=20ajout=20du=20bouton=20"cr?= =?UTF-8?q?=C3=A9er=20une=20demande=20de=20prix"=20sur=20la=20fiche=20four?= =?UTF-8?q?nisseur=20(#new=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/fourn/card.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 0fefa8d4555..8cb1a36d09e 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -490,6 +490,11 @@ if ($object->id > 0) $langs->load("bills"); print ''.$langs->trans("AddBill").''; } + + if ($conf->askpricesupplier->enabled && $user->rights->askpricesupplier->creer) { + $langs->load("askpricesupplier"); + print ''.$langs->trans("AddAskPriceSupplier").''; + } if ($user->rights->fournisseur->facture->creer) { From fedf4769876e5a35e0f09e3dc88c28ef6643a521 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 2 Feb 2015 10:25:27 +0100 Subject: [PATCH 034/120] =?UTF-8?q?[CORE]=20ajout=20d'une=20traduction=20p?= =?UTF-8?q?our=20le=20bouton=20cr=C3=A9er=20demande=20de=20prix=20sur=20la?= =?UTF-8?q?=20fiche=20fournisseur=20(#new=5Fask=5Fprice).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/langs/fr_FR/askpricesupplier.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/fr_FR/askpricesupplier.lang b/htdocs/langs/fr_FR/askpricesupplier.lang index 146a0db9938..0f0e39b7c43 100644 --- a/htdocs/langs/fr_FR/askpricesupplier.lang +++ b/htdocs/langs/fr_FR/askpricesupplier.lang @@ -43,6 +43,7 @@ Askpricesupplier=Demande de prix fournisseur NewAskPrice=Nouvelle demande de prix NewAsk=Nouvelle demande ShowAskpricesupplier=Afficher la demande de prix +AddAskPriceSupplier=Créer une demande de prix # # Modifié ConfirmValidateAsk=Êtes-vous sûr de vouloir valider cette demande de prix sous la référence %s ? DateAsk=Date de demande From 5573c6a2504a73cdde0d903b3956b0ef7d93efa8 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 2 Feb 2015 10:26:04 +0100 Subject: [PATCH 035/120] =?UTF-8?q?[CORE]=20mise=20en=20commentaire=20des?= =?UTF-8?q?=20champs=20inutile=20lors=20de=20la=201ere=20=C3=A9tape=20de?= =?UTF-8?q?=20cr=C3=A9er=20de=20demande=20de=20prix=20(#new=5Fask=5Fprice)?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/askpricesupplier.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/askpricesupplier.php b/htdocs/comm/askpricesupplier.php index dc0abc68642..46533a84210 100644 --- a/htdocs/comm/askpricesupplier.php +++ b/htdocs/comm/askpricesupplier.php @@ -1293,6 +1293,7 @@ if ($action == 'create') print '
" . $langs->trans("DefaultContact") . ''; @@ -1317,15 +1318,17 @@ if ($action == 'create') print '.'; print '
' . $langs->trans('Date') . ''; $form->select_date('', '', '', '', '', "addask", 1, 1); print '
' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . '
' . $langs->trans('PaymentConditionsShort') . ''; $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id'); @@ -1389,6 +1392,7 @@ if ($action == 'create') print "
'; print ''; @@ -1684,12 +1679,14 @@ if ($action == 'create') } print ''; print ''; - + */ + // Company - print ''; + print ''; print ''; // Ligne info remises tiers + /* PHFAVRE retrait en temporaire print ''; - + */ + // Date of proposal print ''; print ''; // Date end proposal + /* PHFAVRE retrait en temporaire print ''; print '
'; print $langs->trans('RefCustomer') . '
' . $langs->trans('Company') . '' . $soc->getNomUrl(1) . '
' . $langs->trans('Supplier') . '' . $soc->getNomUrl(1) . '
' . $langs->trans('Discounts') . ''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); @@ -1716,7 +1713,8 @@ if ($action == 'create') if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.'; print '
'; @@ -1744,6 +1742,7 @@ if ($action == 'create') print '
'; print ''; print ''; - + */ + // Payment term print '
'; @@ -1771,7 +1770,8 @@ if ($action == 'create') } print '
'; print ''; // Delivery date + /* PHFAVRE retrait en temporaire $langs->load('deliveries'); print '\n"; print ''; - print ''; + print ''; // Other attributes $parameters=array('colspan' => 3); @@ -612,11 +612,11 @@ else print '
'; @@ -1790,6 +1790,7 @@ if ($action == 'create') print '
'; print ''; print ''; - + */ + // Delivery delay + /* PHFAVRE retrait en temporaire print ''; foreach ($showextcals as $val) { - $htmlname = dol_string_nospecial($val['name']); + $htmlname = md5($val['name']); print ''; - print ''; + print ''; // Type print ''; @@ -299,15 +297,17 @@ if ($action == 'create') print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print ''; - // Country - print ''; - print ''; + print ''; @@ -333,10 +333,10 @@ if ($action == 'create') print ''; - + // Other attributes $parameters=array('colspan' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook @@ -353,7 +353,7 @@ if ($action == 'create') // Sold print ''; - print ''; + print ''; print ''; print ''; + print ''; print ''; - print ''; + print ''; print ''; print '
'; @@ -1811,8 +1812,10 @@ if ($action == 'create') } print '
'; print ''; print ''; - + */ + // Shipping Method + /* PHFAVRE retrait en temporaire if (! empty($conf->expedition->enabled)) { print ''; $form_close .= '"; - - print ''; - print ''; - - print '"; - - } - - print '
'; print $langs->trans('AvailabilityPeriod'); @@ -1831,8 +1834,10 @@ if ($action == 'create') print '
'; print ''; print ''; } - + */ + // Origin of demand + /* PHFAVRE retrait en temporaire print '
'; @@ -1850,8 +1855,10 @@ if ($action == 'create') print '
'; print ''; print ''; - + */ + // Payment mode print ''; print ''; // Project + /* if (! empty($conf->projet->enabled)) { $langs->load("projects"); print ''; } - + */ + if ($soc->outstanding_limit) { // Outstanding Bill @@ -1938,7 +1948,7 @@ if ($action == 'create') print '
'; print $langs->trans('Source'); @@ -1867,7 +1874,8 @@ if ($action == 'create') } print '
'; @@ -1886,6 +1894,7 @@ if ($action == 'create') print '
'; @@ -1918,7 +1927,8 @@ if ($action == 'create') } print '
'; - if ($action != 'editbankaccount' && $user->rights->propal->creer) + if ($action != 'editbankaccount' && $user->rights->askpricesupplier->creer) print ''; print '
'; print $langs->trans('BankAccount'); print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; print '
'; @@ -2033,6 +2043,7 @@ if ($action == 'create') $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line + /* PHFAVRE retrait en temporaire*/ if ($object->statut == 0 && $user->rights->askpricesupplier->creer) { if ($action != 'editline') @@ -2046,7 +2057,25 @@ if ($action == 'create') $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } } + + + /* + // Form to add new line + if ($object->statut == 0 && $user->rights->askpricesupplier->creer) + { + // Add free products/services form + global $forceall, $senderissupplier, $dateSelector; + $forceall=1; $senderissupplier=1; $dateSelector=0; + $var = true; + + // Add free products/services + $object->formAddObjectLine(1, $mysoc, $object); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } +*/ print '
'; print "\n"; @@ -2065,8 +2094,8 @@ if ($action == 'create') $form_close .= ''; $form_close .= ''; $form_close .= '
' . $langs->trans('Note') . '
'.$langs->trans("BankAccountOwner").''; - print '
'.$langs->trans("BankAccountOwnerAddress").''; - print "
'; - - print '
'; - - print '
'; - print ''; - print '   '; - print '
'; - - print ''; -} - - -llxFooter(); - -$db->close(); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index c44dd2058b7..359090ea655 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -2,8 +2,8 @@ /* Copyright (C) 2002-2003 Rodolphe Quiedeville * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2012 Laurent Destailleur - * Copytight (C) 2005-2009 Regis Houssin - * Copytight (C) 2014 Alexandre Spangaro + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2014-2015 Alexandre Spangaro * * 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 @@ -21,16 +21,16 @@ /** * \file htdocs/compta/bank/card.php - * \ingroup banque + * \ingroup bank * \brief Page to create/view a bank account */ require('../../main.inc.php'); -require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $langs->load("banks"); @@ -70,6 +70,18 @@ if ($_POST["action"] == 'add') $account->clos = $_POST["clos"]; $account->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; $account->url = $_POST["url"]; + + $account->bank = trim($_POST["bank"]); + $account->code_banque = trim($_POST["code_banque"]); + $account->code_guichet = trim($_POST["code_guichet"]); + $account->number = trim($_POST["number"]); + $account->cle_rib = trim($_POST["cle_rib"]); + $account->bic = trim($_POST["bic"]); + $account->iban = trim($_POST["iban"]); + $account->domiciliation = trim($_POST["domiciliation"]); + + $account->proprio = trim($_POST["proprio"]); + $account->owner_address = trim($_POST["owner_address"]); $account->account_number = trim($_POST["account_number"]); $account->accountancy_journal = trim($_POST["accountancy_journal"]); @@ -233,6 +245,15 @@ if ($action == 'create') if ($conf->use_javascript_ajax) { + print "\n".''."\n"; + print "\n".''."\n"; - - print "\n".''; print ' ' . $langs->trans("LocalAgenda") . '
'; print ' ' . $val ['name']; From 5335a6affae5fd2d5421a26ba8e3b79bb7c63311 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 16:28:29 +0100 Subject: [PATCH 105/120] NEW: Add close date and user for projects. --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 5 +++++ htdocs/install/mysql/tables/llx_projet.sql | 2 ++ htdocs/projet/class/project.class.php | 14 +++++++++++--- test/phpunit/ProjectTest.php | 8 ++++++-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 84990967856..fd9006fa303 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -227,3 +227,8 @@ ALTER TABLE llx_commande_fournisseurdet ADD COLUMN special_code integer DEFAULT ALTER TABLE llx_commande_fournisseurdet ADD COLUMN rang integer DEFAULT 0; ALTER TABLE llx_commande_fournisseurdet ADD COLUMN fk_parent_line integer NULL after fk_commande; +ALTER TABLE llx_projet ADD COLUMN date_close datetime DEFAULT NULL; +ALTER TABLE llx_projet ADD COLUMN fk_user_close integer DEFAULT NULL; + + + \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index 0bfde5c026b..d9192c191ba 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -32,6 +32,8 @@ create table llx_projet fk_user_creat integer NOT NULL, -- createur du projet public integer, -- project is public or not fk_statut smallint DEFAULT 0 NOT NULL, + date_close datetime DEFAULT NULL, + fk_user_close integer DEFAULT NULL, note_private text, note_public text, --budget_days real, -- budget in days is sum of field planned_workload of tasks diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 1d5daf2110a..eb15f80ff6d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -49,8 +49,10 @@ class Project extends CommonObject var $title; var $date_start; var $date_end; + var $date_close; var $socid; var $user_author_id; //!< Id of project creator. Not defined if shared project. + var $user_close_id; var $public; //!< Tell if this is a public or private project var $note_private; var $note_public; @@ -212,6 +214,8 @@ class Project extends CommonObject $sql.= ", datec=" . ($this->date_c != '' ? "'".$this->db->idate($this->date_c)."'" : 'null'); $sql.= ", dateo=" . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); $sql.= ", datee=" . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); + $sql.= ", date_close=" . ($this->date_close != '' ? "'".$this->db->idate($this->date_close)."'" : 'null'); + $sql.= ", fk_user_close=" . ($this->fk_user_close > 0 ? $this->fk_user_close : "null"); $sql.= ", budget_amount = " . ($this->budget_amount > 0 ? $this->budget_amount : "null"); $sql.= " WHERE rowid = " . $this->id; @@ -299,7 +303,7 @@ class Project extends CommonObject if (empty($id) && empty($ref)) return -1; $sql = "SELECT rowid, ref, title, description, public, datec, budget_amount,"; - $sql.= " tms, dateo, datee, fk_soc, fk_user_creat, fk_statut, note_private, note_public,model_pdf"; + $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, note_private, note_public,model_pdf"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; if (! empty($id)) { @@ -330,10 +334,12 @@ class Project extends CommonObject $this->datem = $this->db->jdate($obj->tms); // TODO deprecated $this->date_start = $this->db->jdate($obj->dateo); $this->date_end = $this->db->jdate($obj->datee); + $this->date_close = $this->db->jdate($obj->date_close); $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->socid = $obj->fk_soc; $this->user_author_id = $obj->fk_user_creat; + $this->user_close_id = $obj->fk_user_close; $this->public = $obj->public; $this->statut = $obj->fk_statut; $this->budget_amount = $obj->budget_amount; @@ -682,13 +688,15 @@ class Project extends CommonObject /** * Close a project * - * @param User $user User that validate + * @param User $user User that close project * @return int <0 if KO, >0 if OK */ function setClose($user) { global $langs, $conf; + $now = dol_now(); + $error=0; if ($this->statut != 2) @@ -696,7 +704,7 @@ class Project extends CommonObject $this->db->begin(); $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; - $sql.= " SET fk_statut = 2"; + $sql.= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'"; $sql.= " WHERE rowid = " . $this->id; $sql.= " AND entity = " . $conf->entity; $sql.= " AND fk_statut = 1"; diff --git a/test/phpunit/ProjectTest.php b/test/phpunit/ProjectTest.php index e27cd1e0223..c2f5d5b8161 100644 --- a/test/phpunit/ProjectTest.php +++ b/test/phpunit/ProjectTest.php @@ -189,7 +189,7 @@ class ProjectTest extends PHPUnit_Framework_TestCase } /** - * testProjectOther + * testProjectClose * * @param Project $localobject Project * @return int @@ -205,6 +205,10 @@ class ProjectTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; + $result=$localobject->setClose($user); + + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); return $localobject->id; } @@ -214,7 +218,7 @@ class ProjectTest extends PHPUnit_Framework_TestCase * @param int $id Id of project * @return void * - * @depends testProjectOther + * @depends testProjectClose * The depends says test is run only if previous is ok */ public function testProjectDelete($id) From d1c44d549840c9f4fb0a6d02cc98790f04d08998 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 16:30:38 +0100 Subject: [PATCH 106/120] Update doc --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e2282654fc9..ef6dd3a834a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,8 +47,8 @@ Long description (Can span accross multiple lines). Where KEYWORD is one of: -- "FIXED:" for bug fixes (May be followed by the bug number i.e: #456) -- "NEW:" for new features (May be followed by the task number i.e: #123) +- "FIXED:" for bug fixes. In upper case to appear into ChangeLog. (May be followed by the bug number i.e: #456) +- "NEW:" for new features. In upper case to appear into ChangeLog. (May be followed by the task number i.e: #123) - void, don't put a keyword if the commit is not introducing feature or closing a bug. ### Resources From 1a02f6aa806b811129edb58f2e5d10cad0f5590b Mon Sep 17 00:00:00 2001 From: fmarcet Date: Wed, 4 Mar 2015 18:18:55 +0100 Subject: [PATCH 107/120] Fix: Masks works with thirdparty type --- htdocs/contrat/card.php | 2 +- htdocs/core/modules/commande/mod_commande_saphir.php | 2 +- htdocs/core/modules/contract/mod_contract_magre.php | 2 +- htdocs/core/modules/fichinter/mod_arctic.php | 2 +- htdocs/core/modules/livraison/mod_livraison_saphir.php | 2 +- htdocs/core/modules/propale/mod_propale_saphir.php | 2 +- .../modules/supplier_invoice/mod_facture_fournisseur_tulip.php | 2 +- .../supplier_order/mod_commande_fournisseur_orchidee.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 6d10442caf7..edb20d91d35 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1097,7 +1097,7 @@ else $ref = substr($object->ref, 1, 4); if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { - $numref = $object->getNextNumRef($soc); + $numref = $object->getNextNumRef($object->thirdparty); } else { diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 87ba0d57c98..1996717e506 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -121,7 +121,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes return 0; } - $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc->code_client,$object->date); + $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$object->date); return $numFinal; } diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index 289b474de5e..54da8fc55c4 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -112,7 +112,7 @@ class mod_contract_magre extends ModelNumRefContracts return 0; } - $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc->code_client,$contract->date_contrat); + $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat); return $numFinal; } diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index ab06d1417e6..278e20ae7de 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -120,7 +120,7 @@ class mod_arctic extends ModeleNumRefFicheinter return 0; } - $numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc->code_client,$object->datec); + $numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc,$object->datec); return $numFinal; } diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index 5f8a6b93686..1192656bf8d 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -120,7 +120,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder return 0; } - $numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc->code_client,$object->date_livraison); + $numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison); return $numFinal; } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 503d8754684..25ccecb253c 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -123,7 +123,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $date=$propal->datep; $customercode=$objsoc->code_client; - $numFinal=get_next_value($db,$mask,'propal','ref','',$customercode,$date); + $numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date); return $numFinal; } diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 15bef66bf8f..ba31d979864 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -126,7 +126,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices } //Supplier invoices take invoice date instead of creation date for the mask - $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->date); + $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date); return $numFinal; } diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 7f74ce095c0..37b8adab22e 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -121,7 +121,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders return 0; } - $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc->code_fournisseur,$object->date_commande); + $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande); return $numFinal; } From cf3190a4ef6bdca7286d6f465bf3575396860d39 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 18:56:57 +0100 Subject: [PATCH 108/120] Bad error management --- htdocs/projet/card.php | 40 +++++++++------------------ htdocs/projet/class/project.class.php | 2 +- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 541d9271ade..cd19f25a97c 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -38,6 +38,7 @@ $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); $backtopage=GETPOST('backtopage','alpha'); +$cancel=GETPOST('cancel','alpha'); if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $action != "update" && ! $_POST["cancel"])) accessforbidden(); @@ -51,13 +52,10 @@ $object = new Project($db); $extrafields = new ExtraFields($db); if ($id > 0 || ! empty($ref)) { - $ret = $object->fetch($id,$ref); + $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); $id=$object->id; - } else { - setEventMessage($object->error, 'errors'); - $action=''; } } @@ -83,9 +81,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Cancel - if (GETPOST("cancel") && ! empty($backtopage)) + if ($cancel) { if (GETPOST("comefromclone")==1) { @@ -101,26 +98,15 @@ if (empty($reshook)) setEventMessage($langs->trans("CantRemoveProject"), 'errors'); } } - header("Location: ".$backtopage); - exit; + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + + $action = ''; } - - //if cancel and come from clone then delete the cloned project - if (GETPOST("cancel") && (GETPOST("comefromclone")==1)) - { - $result=$object->delete($user); - if ($result > 0) - { - header("Location: index.php"); - exit; - } - else - { - dol_syslog($object->error,LOG_DEBUG); - setEventMessage($langs->trans("CantRemoveProject"), 'errors'); - } - } - + if ($action == 'add' && $user->rights->projet->creer) { $error=0; @@ -134,7 +120,7 @@ if (empty($reshook)) setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors'); $error++; } - + if (! $error) { $error=0; @@ -156,7 +142,7 @@ if (empty($reshook)) if ($ret < 0) $error++; $result = $object->create($user); - if ($result > 0) + if (! $error && $result > 0) { // Add myself as project leader $result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal'); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 1d5daf2110a..7d5cece4707 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -299,7 +299,7 @@ class Project extends CommonObject if (empty($id) && empty($ref)) return -1; $sql = "SELECT rowid, ref, title, description, public, datec, budget_amount,"; - $sql.= " tms, dateo, datee, fk_soc, fk_user_creat, fk_statut, note_private, note_public,model_pdf"; + $sql.= " tms, dateo, datee, fk_soc, fk_user_creat, fk_statut, note_private, note_public, model_pdf"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; if (! empty($id)) { From 20d56244403b13574679d49486c2b63f976da3cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 20:34:41 +0100 Subject: [PATCH 109/120] Closed #2414 --- htdocs/webservices/server_contact.php | 96 ++++++++++++--------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index ec652e80074..066c9f38b6c 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -114,8 +114,7 @@ $contact_fields = array( 'user_id' => array('name'=>'user_id','type'=>'xsd:string'), 'user_login' => array('name'=>'user_login','type'=>'xsd:string'), 'civility_id' => array('name'=>'civility_id','type'=>'xsd:string'), - 'poste' => array('name'=>'poste','type'=>'xsd:string'), - 'statut' => array('name'=>'statut','type'=>'xsd:string') + 'poste' => array('name'=>'poste','type'=>'xsd:string') //... ); //Retreive all extrafield for contact @@ -286,7 +285,7 @@ function getContact($authentication,$id,$ref_ext) 'country_code' => $contact->country_code, 'country' => $contact->country, 'socid' => $contact->socid, - 'status' => $contact->status, + 'status' => $contact->statut, 'phone_pro' => $contact->phone_pro, 'fax' => $contact->fax, 'phone_perso' => $contact->phone_perso, @@ -304,8 +303,7 @@ function getContact($authentication,$id,$ref_ext) 'user_id' => $contact->user_id, 'user_login' => $contact->user_login, 'civility_id' => $contact->civility_id, - 'poste' => $contact->poste, - 'statut' => $contact->statut + 'poste' => $contact->poste ); //Retreive all extrafield for thirdsparty @@ -353,7 +351,7 @@ function getContact($authentication,$id,$ref_ext) * Create Contact * * @param array $authentication Array of authentication information - * @param Contact $contact $contact + * @param Contact $contact $contact * @return array Array result */ function createContact($authentication,$contact) @@ -398,7 +396,7 @@ function createContact($authentication,$contact) $newobject->country_code=$contact['country_code']; $newobject->country=$contact['country']; $newobject->socid=$contact['socid']; - $newobject->status=$contact['status']; + $newobject->statut=$contact['status']; $newobject->phone_pro=$contact['phone_pro']; $newobject->fax=$contact['fax']; $newobject->phone_perso=$contact['phone_perso']; @@ -416,7 +414,6 @@ function createContact($authentication,$contact) $newobject->user_id=$contact['user_id']; $newobject->user_login=$contact['user_login']; $newobject->poste=$contact['poste']; - $newobject->statut=$contact['statut']; //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels @@ -493,7 +490,7 @@ function getContactsForThirdParty($authentication,$idthirdparty) { $linesinvoice=array(); - $sql = "SELECT c.rowid, c.fk_soc, c.civility as civility_id, c.lastname, c.firstname, c.statut,"; + $sql = "SELECT c.rowid, c.fk_soc, c.civility as civility_id, c.lastname, c.firstname, c.statut as status,"; $sql.= " c.address, c.zip, c.town,"; $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement,"; @@ -511,7 +508,6 @@ function getContactsForThirdParty($authentication,$idthirdparty) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; $sql.= " WHERE c.fk_soc=$idthirdparty"; - $resql=$db->query($sql); if ($resql) { @@ -525,58 +521,50 @@ function getContactsForThirdParty($authentication,$idthirdparty) $contact=new Contact($db); $contact->fetch($obj->rowid); - // Now define invoice $linescontact[]=array( - 'id' => $contact->id, - 'ref' => $contact->ref, - 'civility_id' => $contact->civility_id?$contact->civility_id:'', - 'lastname' => $contact->lastname?$contact->lastname:'', - 'firstname' => $contact->firstname?$contact->firstname:'', - 'address' => $contact->address?$contact->address:'', - 'zip' => $contact->zip?$contact->zip:'', - 'town' => $contact->town?$contact->town:'', + 'id' => $contact->id, + 'ref' => $contact->ref, + 'civility_id' => $contact->civility_id?$contact->civility_id:'', + 'lastname' => $contact->lastname?$contact->lastname:'', + 'firstname' => $contact->firstname?$contact->firstname:'', + 'address' => $contact->address?$contact->address:'', + 'zip' => $contact->zip?$contact->zip:'', + 'town' => $contact->town?$contact->town:'', - 'state_id' => $contact->state_id?$contact->state_id:'', - 'state_code' => $contact->state_code?$contact->state_code:'', - 'state' => $contact->state?$contact->state:'', - - 'country_id' => $contact->country_id?$contact->country_id:'', - 'country_code' => $contact->country_code?$contact->country_code:'', - 'country' => $contact->country?$contact->country:'', - - 'socid' => $contact->socid?$contact->socid:'', - 'socname' => $contact->socname?$contact->socname:'', - 'poste' => $contact->poste?$contact->poste:'', - - - - 'phone_pro' => $contact->phone_pro?$contact->phone_pro:'', - 'fax' => $contact->fax?$contact->fax:'', - 'phone_perso' => $contact->phone_perso?$contact->phone_perso:'', - 'phone_mobile' => $contact->phone_mobile?$contact->phone_mobile:'', - - 'email' => $contact->email?$contact->email:'', - 'jabberid' => $contact->jabberid?$contact->jabberid:'', - 'priv' => $contact->priv?$contact->priv:'', - 'mail' => $contact->mail?$contact->mail:'', - - 'birthday' => $contact->birthday?$contact->birthday:'', - 'default_lang' => $contact->default_lang?$contact->default_lang:'', - 'note' => $contact->note?$contact->note:'', - 'no_email' => $contact->no_email?$contact->no_email:'', - 'ref_facturation' => $contact->ref_facturation?$contact->ref_facturation:'', - 'ref_contrat' => $contact->ref_contrat?$contact->ref_contrat:'', - 'ref_commande' => $contact->ref_commande?$contact->ref_commande:'', - 'ref_propal' => $contact->ref_propal?$contact->ref_propal:'', - 'user_id' => $contact->user_id?$contact->user_id:'', - 'user_login' => $contact->user_login?$contact->user_login:'', - 'statut' => $contact->statut?$contact->statut:'' + 'state_id' => $contact->state_id?$contact->state_id:'', + 'state_code' => $contact->state_code?$contact->state_code:'', + 'state' => $contact->state?$contact->state:'', + 'country_id' => $contact->country_id?$contact->country_id:'', + 'country_code' => $contact->country_code?$contact->country_code:'', + 'country' => $contact->country?$contact->country:'', + 'socid' => $contact->socid?$contact->socid:'', + 'socname' => $contact->socname?$contact->socname:'', + 'poste' => $contact->poste?$contact->poste:'', + 'phone_pro' => $contact->phone_pro?$contact->phone_pro:'', + 'fax' => $contact->fax?$contact->fax:'', + 'phone_perso' => $contact->phone_perso?$contact->phone_perso:'', + 'phone_mobile' => $contact->phone_mobile?$contact->phone_mobile:'', + 'email' => $contact->email?$contact->email:'', + 'jabberid' => $contact->jabberid?$contact->jabberid:'', + 'priv' => $contact->priv?$contact->priv:'', + 'mail' => $contact->mail?$contact->mail:'', + 'birthday' => $contact->birthday?$contact->birthday:'', + 'default_lang' => $contact->default_lang?$contact->default_lang:'', + 'note' => $contact->note?$contact->note:'', + 'no_email' => $contact->no_email?$contact->no_email:'', + 'ref_facturation' => $contact->ref_facturation?$contact->ref_facturation:'', + 'ref_contrat' => $contact->ref_contrat?$contact->ref_contrat:'', + 'ref_commande' => $contact->ref_commande?$contact->ref_commande:'', + 'ref_propal' => $contact->ref_propal?$contact->ref_propal:'', + 'user_id' => $contact->user_id?$contact->user_id:'', + 'user_login' => $contact->user_login?$contact->user_login:'', + 'status' => $contact->statut?$contact->statut:'' ); $i++; From f570cd6b429c6f4724067f907e76e0e23e1604d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 20:35:08 +0100 Subject: [PATCH 110/120] Forgot to commit tables --- .../mysql/tables/llx_askpricesupplier.sql | 55 +++++++++++++++++++ .../llx_askpricesupplier_extrafields.sql | 23 ++++++++ .../mysql/tables/llx_askpricesupplierdet.sql | 48 ++++++++++++++++ .../llx_askpricesupplierdet_extrafields.sql | 24 ++++++++ 4 files changed, 150 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_askpricesupplier.sql create mode 100644 htdocs/install/mysql/tables/llx_askpricesupplier_extrafields.sql create mode 100644 htdocs/install/mysql/tables/llx_askpricesupplierdet.sql create mode 100644 htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql diff --git a/htdocs/install/mysql/tables/llx_askpricesupplier.sql b/htdocs/install/mysql/tables/llx_askpricesupplier.sql new file mode 100644 index 00000000000..ff62595bd0b --- /dev/null +++ b/htdocs/install/mysql/tables/llx_askpricesupplier.sql @@ -0,0 +1,55 @@ +-- ======================================================================== +-- Copyright (C) 2015 Laurent Destailleur +-- +-- 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 3 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, see . +-- ======================================================================== + +CREATE TABLE llx_askpricesupplier ( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + ref varchar(30) NOT NULL, + entity integer NOT NULL DEFAULT '1', + ref_ext varchar(255) DEFAULT NULL, + ref_int varchar(255) DEFAULT NULL, + fk_soc integer DEFAULT NULL, + fk_projet integer DEFAULT NULL, + tms timestamp, + datec datetime DEFAULT NULL, + date_valid datetime DEFAULT NULL, + date_cloture datetime DEFAULT NULL, + fk_user_author integer DEFAULT NULL, + fk_user_modif integer DEFAULT NULL, + fk_user_valid integer DEFAULT NULL, + fk_user_cloture integer DEFAULT NULL, + fk_statut smallint NOT NULL DEFAULT '0', + price double DEFAULT '0', + remise_percent double DEFAULT '0', + remise_absolue double DEFAULT '0', + remise double DEFAULT '0', + total_ht double(24,8) DEFAULT 0, + tva double(24,8) DEFAULT 0, + localtax1 double(24,8) DEFAULT 0, + localtax2 double(24,8) DEFAULT 0, + total double(24,8) DEFAULT 0, + fk_account integer DEFAULT NULL, + fk_currency varchar(3) DEFAULT NULL, + fk_cond_reglement integer DEFAULT NULL, + fk_mode_reglement integer DEFAULT NULL, + note_private text, + note_public text, + model_pdf varchar(255) DEFAULT NULL, + date_livraison date DEFAULT NULL, + fk_shipping_method integer DEFAULT NULL, + import_key varchar(14) DEFAULT NULL, + extraparams varchar(255) DEFAULT NULL +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_askpricesupplier_extrafields.sql b/htdocs/install/mysql/tables/llx_askpricesupplier_extrafields.sql new file mode 100644 index 00000000000..4552b4d0079 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_askpricesupplier_extrafields.sql @@ -0,0 +1,23 @@ +-- ======================================================================== +-- Copyright (C) 2015 Laurent Destailleur +-- +-- 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 3 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, see . +-- ======================================================================== + +CREATE TABLE llx_askpricesupplier_extrafields ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) DEFAULT NULL +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_askpricesupplierdet.sql b/htdocs/install/mysql/tables/llx_askpricesupplierdet.sql new file mode 100644 index 00000000000..5755fdcb83f --- /dev/null +++ b/htdocs/install/mysql/tables/llx_askpricesupplierdet.sql @@ -0,0 +1,48 @@ +-- ======================================================================== +-- Copyright (C) 2015 Laurent Destailleur +-- +-- 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 3 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, see . +-- ======================================================================== + +CREATE TABLE llx_askpricesupplierdet ( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + fk_askpricesupplier integer NOT NULL, + fk_parent_line integer DEFAULT NULL, + fk_product integer DEFAULT NULL, + label varchar(255) DEFAULT NULL, + description text, + fk_remise_except integer DEFAULT NULL, + tva_tx double(6,3) DEFAULT 0, + localtax1_tx double(6,3) DEFAULT 0, + localtax1_type varchar(10) DEFAULT NULL, + localtax2_tx double(6,3) DEFAULT 0, + localtax2_type varchar(10) DEFAULT NULL, + qty double DEFAULT NULL, + remise_percent double DEFAULT '0', + remise double DEFAULT '0', + price double DEFAULT NULL, + subprice double(24,8) DEFAULT 0, + total_ht double(24,8) DEFAULT 0, + total_tva double(24,8) DEFAULT 0, + total_localtax1 double(24,8) DEFAULT 0, + total_localtax2 double(24,8) DEFAULT 0, + total_ttc double(24,8) DEFAULT 0, + product_type integer DEFAULT 0, + info_bits integer DEFAULT 0, + buy_price_ht double(24,8) DEFAULT 0, + fk_product_fournisseur_price integer DEFAULT NULL, + special_code integer DEFAULT 0, + rang integer DEFAULT 0, + ref_fourn varchar(30) DEFAULT NULL +) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql b/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql new file mode 100644 index 00000000000..6ecbcf83d2c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql @@ -0,0 +1,24 @@ +-- ======================================================================== +-- Copyright (C) 2015 Laurent Destailleur +-- +-- 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 3 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, see . +-- ======================================================================== + +CREATE TABLE llx_askpricesupplierdet_extrafields ( + rowid integer AUTO_INCREMENT PRIMAR KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) DEFAULT NULL +) ENGINE=innodb; + From 56e77382f3a1b4087f69c5713bca94a1df2baa1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 20:43:54 +0100 Subject: [PATCH 111/120] Merge --- dev/fixdosfiles.sh | 1 + htdocs/includes/tcpdi/fpdf_tpl.php | 920 ++++++++++++++--------------- 2 files changed, 461 insertions(+), 460 deletions(-) diff --git a/dev/fixdosfiles.sh b/dev/fixdosfiles.sh index 30d47e7b0c4..5efd4b58543 100755 --- a/dev/fixdosfiles.sh +++ b/dev/fixdosfiles.sh @@ -10,6 +10,7 @@ # Syntax if [ "x$1" != "xlist" -a "x$1" != "xfix" ] then + echo "This script clean files with CR+LF into files with LF only. All source files are included, also files into includes." echo "Usage: fixdosfiles.sh [list|fix]" fi diff --git a/htdocs/includes/tcpdi/fpdf_tpl.php b/htdocs/includes/tcpdi/fpdf_tpl.php index 86e38b71641..8482ba336ed 100644 --- a/htdocs/includes/tcpdi/fpdf_tpl.php +++ b/htdocs/includes/tcpdi/fpdf_tpl.php @@ -1,460 +1,460 @@ -Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); - return; - } - - if ($this->page <= 0) - $this->error("You have to add a page to fpdf first!"); - - if ($x == null) - $x = 0; - if ($y == null) - $y = 0; - if ($w == null) - $w = $this->w; - if ($h == null) - $h = $this->h; - - // Save settings - $this->tpl++; - $tpl =& $this->tpls[$this->tpl]; - $tpl = array( - 'o_x' => $this->x, - 'o_y' => $this->y, - 'o_AutoPageBreak' => $this->AutoPageBreak, - 'o_bMargin' => $this->bMargin, - 'o_tMargin' => $this->tMargin, - 'o_lMargin' => $this->lMargin, - 'o_rMargin' => $this->rMargin, - 'o_h' => $this->h, - 'o_w' => $this->w, - 'o_FontFamily' => $this->FontFamily, - 'o_FontStyle' => $this->FontStyle, - 'o_FontSizePt' => $this->FontSizePt, - 'o_FontSize' => $this->FontSize, - 'buffer' => '', - 'x' => $x, - 'y' => $y, - 'w' => $w, - 'h' => $h - ); - - $this->SetAutoPageBreak(false); - - // Define own high and width to calculate possitions correct - $this->h = $h; - $this->w = $w; - - $this->_intpl = true; - $this->SetXY($x + $this->lMargin, $y + $this->tMargin); - $this->SetRightMargin($this->w - $w + $this->rMargin); - - if ($this->CurrentFont) { - $fontkey = $this->FontFamily . $this->FontStyle; - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - - $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); - } - - return $this->tpl; - } - - /** - * End Template - * - * This method ends a template and reset initiated variables on beginTemplate. - * - * @return mixed If a template is opened, the ID is returned. If not a false is returned. - */ - function endTemplate() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); - } - - if ($this->_intpl) { - $this->_intpl = false; - $tpl =& $this->tpls[$this->tpl]; - $this->SetXY($tpl['o_x'], $tpl['o_y']); - $this->tMargin = $tpl['o_tMargin']; - $this->lMargin = $tpl['o_lMargin']; - $this->rMargin = $tpl['o_rMargin']; - $this->h = $tpl['o_h']; - $this->w = $tpl['o_w']; - $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); - - $this->FontFamily = $tpl['o_FontFamily']; - $this->FontStyle = $tpl['o_FontStyle']; - $this->FontSizePt = $tpl['o_FontSizePt']; - $this->FontSize = $tpl['o_FontSize']; - - $fontkey = $this->FontFamily . $this->FontStyle; - if ($fontkey) - $this->CurrentFont =& $this->fonts[$fontkey]; - - return $this->tpl; - } else { - return false; - } - } - - /** - * Use a Template in current Page or other Template - * - * You can use a template in a page or in another template. - * You can give the used template a new size like you use the Image()-method. - * All parameters are optional. The width or height is calculated automaticaly - * if one is given. If no parameter is given the origin size as defined in - * beginTemplate() is used. - * The calculated or used width and height are returned as an array. - * - * @param int $tplidx A valid template-Id - * @param int $_x The x-position - * @param int $_y The y-position - * @param int $_w The new width of the template - * @param int $_h The new height of the template - * @retrun array The height and width of the template - */ - function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { - if ($this->page <= 0) - $this->error('You have to add a page first!'); - - if (!isset($this->tpls[$tplidx])) - $this->error('Template does not exist!'); - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; - } - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_x == null) - $_x = 0; - if ($_y == null) - $_y = 0; - - $_x += $tpl['x']; - $_y += $tpl['y']; - - $wh = $this->getTemplateSize($tplidx, $_w, $_h); - $_w = $wh['w']; - $_h = $wh['h']; - - $tData = array( - 'x' => $this->x, - 'y' => $this->y, - 'w' => $_w, - 'h' => $_h, - 'scaleX' => ($_w / $w), - 'scaleY' => ($_h / $h), - 'tx' => $_x, - 'ty' => ($this->h - $_y - $_h), - 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) - ); - - $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate - $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); - - $this->lastUsedTemplateData = $tData; - - return array('w' => $_w, 'h' => $_h); - } - - /** - * Get The calculated Size of a Template - * - * If one size is given, this method calculates the other one. - * - * @param int $tplidx A valid template-Id - * @param int $_w The width of the template - * @param int $_h The height of the template - * @return array The height and width of the template - */ - function getTemplateSize($tplidx, $_w = 0, $_h = 0) { - if (!isset($this->tpls[$tplidx])) - return false; - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_w == 0 and $_h == 0) { - $_w = $w; - $_h = $h; - } - - if($_w == 0) - $_w = $_h * $w / $h; - if($_h == 0) - $_h = $_w * $h / $w; - - return array("w" => $_w, "h" => $_h); - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - public function SetFont($family, $style = '', $size = 0) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); - } - - parent::SetFont($family, $style, $size); - - $fontkey = $this->FontFamily . $this->FontStyle; - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } else { - $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - function Image( - $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, - $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, - $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() - ) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Image'), $args); - } - - $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; - } else { - $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; - } - - return $ret; - } - - /** - * See FPDF-Documentation ;-) - * - * AddPage is not available when you're "in" a template. - */ - function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); - } - - if ($this->_intpl) - $this->Error('Adding pages in templates isn\'t possible!'); - - parent::AddPage($orientation, $format); - } - - /** - * Preserve adding Links in Templates ...won't work - */ - function Link($x, $y, $w, $h, $link, $spaces = 0) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Link'), $args); - } - - if ($this->_intpl) - $this->Error('Using links in templates aren\'t possible!'); - - parent::Link($x, $y, $w, $h, $link); - } - - function AddLink() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); - } - - if ($this->_intpl) - $this->Error('Adding links in templates aren\'t possible!'); - return parent::AddLink(); - } - - function SetLink($link, $y = 0, $page = -1) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); - } - - if ($this->_intpl) - $this->Error('Setting links in templates aren\'t possible!'); - parent::SetLink($link, $y, $page); - } - - /** - * Private Method that writes the form xobjects - */ - function _putformxobjects() { - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; - reset($this->tpls); - foreach($this->tpls AS $tplidx => $tpl) { - - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; - $this->_newobj(); - $this->tpls[$tplidx]['n'] = $this->n; - $this->_out('<<'.$filter.'/Type /XObject'); - $this->_out('/Subtype /Form'); - $this->_out('/FormType 1'); - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', - // llx - $tpl['x'] * $this->k, - // lly - -$tpl['y'] * $this->k, - // urx - ($tpl['w'] + $tpl['x']) * $this->k, - // ury - ($tpl['h'] - $tpl['y']) * $this->k - )); - - if ($tpl['x'] != 0 || $tpl['y'] != 0) { - $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', - -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 - )); - } - - $this->_out('/Resources '); - - $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { - $this->_out('/Font <<'); - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); - $this->_out('>>'); - } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) - { - $this->_out('/XObject <<'); - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { - foreach($this->_res['tpl'][$tplidx]['images'] as $image) - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); - } - if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); - } - $this->_out('>>'); - } - $this->_out('>>'); - - $this->_out('/Length ' . strlen($p) . ' >>'); - $this->_putstream($p); - $this->_out('endobj'); - } - } - - /** - * Overwritten to add _putformxobjects() after _putimages() - * - */ - function _putimages() { - parent::_putimages(); - $this->_putformxobjects(); - } - - function _putxobjectdict() { - parent::_putxobjectdict(); - - if (count($this->tpls)) { - foreach($this->tpls as $tplidx => $tpl) { - $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); - } - } - } - - /** - * Private Method - */ - function _out($s) { - if ($this->state == 2 && $this->_intpl) { - $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; - } else { - parent::_out($s); - } - } -} +Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); + return; + } + + if ($this->page <= 0) + $this->error("You have to add a page to fpdf first!"); + + if ($x == null) + $x = 0; + if ($y == null) + $y = 0; + if ($w == null) + $w = $this->w; + if ($h == null) + $h = $this->h; + + // Save settings + $this->tpl++; + $tpl =& $this->tpls[$this->tpl]; + $tpl = array( + 'o_x' => $this->x, + 'o_y' => $this->y, + 'o_AutoPageBreak' => $this->AutoPageBreak, + 'o_bMargin' => $this->bMargin, + 'o_tMargin' => $this->tMargin, + 'o_lMargin' => $this->lMargin, + 'o_rMargin' => $this->rMargin, + 'o_h' => $this->h, + 'o_w' => $this->w, + 'o_FontFamily' => $this->FontFamily, + 'o_FontStyle' => $this->FontStyle, + 'o_FontSizePt' => $this->FontSizePt, + 'o_FontSize' => $this->FontSize, + 'buffer' => '', + 'x' => $x, + 'y' => $y, + 'w' => $w, + 'h' => $h + ); + + $this->SetAutoPageBreak(false); + + // Define own high and width to calculate possitions correct + $this->h = $h; + $this->w = $w; + + $this->_intpl = true; + $this->SetXY($x + $this->lMargin, $y + $this->tMargin); + $this->SetRightMargin($this->w - $w + $this->rMargin); + + if ($this->CurrentFont) { + $fontkey = $this->FontFamily . $this->FontStyle; + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + + $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); + } + + return $this->tpl; + } + + /** + * End Template + * + * This method ends a template and reset initiated variables on beginTemplate. + * + * @return mixed If a template is opened, the ID is returned. If not a false is returned. + */ + function endTemplate() { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); + } + + if ($this->_intpl) { + $this->_intpl = false; + $tpl =& $this->tpls[$this->tpl]; + $this->SetXY($tpl['o_x'], $tpl['o_y']); + $this->tMargin = $tpl['o_tMargin']; + $this->lMargin = $tpl['o_lMargin']; + $this->rMargin = $tpl['o_rMargin']; + $this->h = $tpl['o_h']; + $this->w = $tpl['o_w']; + $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); + + $this->FontFamily = $tpl['o_FontFamily']; + $this->FontStyle = $tpl['o_FontStyle']; + $this->FontSizePt = $tpl['o_FontSizePt']; + $this->FontSize = $tpl['o_FontSize']; + + $fontkey = $this->FontFamily . $this->FontStyle; + if ($fontkey) + $this->CurrentFont =& $this->fonts[$fontkey]; + + return $this->tpl; + } else { + return false; + } + } + + /** + * Use a Template in current Page or other Template + * + * You can use a template in a page or in another template. + * You can give the used template a new size like you use the Image()-method. + * All parameters are optional. The width or height is calculated automaticaly + * if one is given. If no parameter is given the origin size as defined in + * beginTemplate() is used. + * The calculated or used width and height are returned as an array. + * + * @param int $tplidx A valid template-Id + * @param int $_x The x-position + * @param int $_y The y-position + * @param int $_w The new width of the template + * @param int $_h The new height of the template + * @retrun array The height and width of the template + */ + function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { + if ($this->page <= 0) + $this->error('You have to add a page first!'); + + if (!isset($this->tpls[$tplidx])) + $this->error('Template does not exist!'); + + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; + } + + $tpl =& $this->tpls[$tplidx]; + $w = $tpl['w']; + $h = $tpl['h']; + + if ($_x == null) + $_x = 0; + if ($_y == null) + $_y = 0; + + $_x += $tpl['x']; + $_y += $tpl['y']; + + $wh = $this->getTemplateSize($tplidx, $_w, $_h); + $_w = $wh['w']; + $_h = $wh['h']; + + $tData = array( + 'x' => $this->x, + 'y' => $this->y, + 'w' => $_w, + 'h' => $_h, + 'scaleX' => ($_w / $w), + 'scaleY' => ($_h / $h), + 'tx' => $_x, + 'ty' => ($this->h - $_y - $_h), + 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) + ); + + $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate + $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); + + $this->lastUsedTemplateData = $tData; + + return array('w' => $_w, 'h' => $_h); + } + + /** + * Get The calculated Size of a Template + * + * If one size is given, this method calculates the other one. + * + * @param int $tplidx A valid template-Id + * @param int $_w The width of the template + * @param int $_h The height of the template + * @return array The height and width of the template + */ + function getTemplateSize($tplidx, $_w = 0, $_h = 0) { + if (!isset($this->tpls[$tplidx])) + return false; + + $tpl =& $this->tpls[$tplidx]; + $w = $tpl['w']; + $h = $tpl['h']; + + if ($_w == 0 and $_h == 0) { + $_w = $w; + $_h = $h; + } + + if($_w == 0) + $_w = $_h * $w / $h; + if($_h == 0) + $_h = $_w * $h / $w; + + return array("w" => $_w, "h" => $_h); + } + + /** + * See FPDF/TCPDF-Documentation ;-) + */ + public function SetFont($family, $style = '', $size = 0) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); + } + + parent::SetFont($family, $style, $size); + + $fontkey = $this->FontFamily . $this->FontStyle; + + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + } else { + $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + } + } + + /** + * See FPDF/TCPDF-Documentation ;-) + */ + function Image( + $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, + $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, + $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() + ) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::Image'), $args); + } + + $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; + } else { + $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; + } + + return $ret; + } + + /** + * See FPDF-Documentation ;-) + * + * AddPage is not available when you're "in" a template. + */ + function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); + } + + if ($this->_intpl) + $this->Error('Adding pages in templates isn\'t possible!'); + + parent::AddPage($orientation, $format); + } + + /** + * Preserve adding Links in Templates ...won't work + */ + function Link($x, $y, $w, $h, $link, $spaces = 0) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::Link'), $args); + } + + if ($this->_intpl) + $this->Error('Using links in templates aren\'t possible!'); + + parent::Link($x, $y, $w, $h, $link); + } + + function AddLink() { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); + } + + if ($this->_intpl) + $this->Error('Adding links in templates aren\'t possible!'); + return parent::AddLink(); + } + + function SetLink($link, $y = 0, $page = -1) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); + } + + if ($this->_intpl) + $this->Error('Setting links in templates aren\'t possible!'); + parent::SetLink($link, $y, $page); + } + + /** + * Private Method that writes the form xobjects + */ + function _putformxobjects() { + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + reset($this->tpls); + foreach($this->tpls AS $tplidx => $tpl) { + + $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; + $this->_newobj(); + $this->tpls[$tplidx]['n'] = $this->n; + $this->_out('<<'.$filter.'/Type /XObject'); + $this->_out('/Subtype /Form'); + $this->_out('/FormType 1'); + $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', + // llx + $tpl['x'] * $this->k, + // lly + -$tpl['y'] * $this->k, + // urx + ($tpl['w'] + $tpl['x']) * $this->k, + // ury + ($tpl['h'] - $tpl['y']) * $this->k + )); + + if ($tpl['x'] != 0 || $tpl['y'] != 0) { + $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', + -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 + )); + } + + $this->_out('/Resources '); + + $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { + $this->_out('/Font <<'); + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); + $this->_out('>>'); + } + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || + isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) + { + $this->_out('/XObject <<'); + if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { + foreach($this->_res['tpl'][$tplidx]['images'] as $image) + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); + } + if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); + } + $this->_out('>>'); + } + $this->_out('>>'); + + $this->_out('/Length ' . strlen($p) . ' >>'); + $this->_putstream($p); + $this->_out('endobj'); + } + } + + /** + * Overwritten to add _putformxobjects() after _putimages() + * + */ + function _putimages() { + parent::_putimages(); + $this->_putformxobjects(); + } + + function _putxobjectdict() { + parent::_putxobjectdict(); + + if (count($this->tpls)) { + foreach($this->tpls as $tplidx => $tpl) { + $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); + } + } + } + + /** + * Private Method + */ + function _out($s) { + if ($this->state == 2 && $this->_intpl) { + $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; + } else { + parent::_out($s); + } + } +} From 7a9de0fecab5ee881873d343c4b79bb5067f3eaf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 20:45:33 +0100 Subject: [PATCH 112/120] CRLF --- htdocs/includes/tcpdi/fpdf_tpl.php | 920 ++++++++++++++--------------- 1 file changed, 460 insertions(+), 460 deletions(-) diff --git a/htdocs/includes/tcpdi/fpdf_tpl.php b/htdocs/includes/tcpdi/fpdf_tpl.php index 86e38b71641..8482ba336ed 100644 --- a/htdocs/includes/tcpdi/fpdf_tpl.php +++ b/htdocs/includes/tcpdi/fpdf_tpl.php @@ -1,460 +1,460 @@ -Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); - return; - } - - if ($this->page <= 0) - $this->error("You have to add a page to fpdf first!"); - - if ($x == null) - $x = 0; - if ($y == null) - $y = 0; - if ($w == null) - $w = $this->w; - if ($h == null) - $h = $this->h; - - // Save settings - $this->tpl++; - $tpl =& $this->tpls[$this->tpl]; - $tpl = array( - 'o_x' => $this->x, - 'o_y' => $this->y, - 'o_AutoPageBreak' => $this->AutoPageBreak, - 'o_bMargin' => $this->bMargin, - 'o_tMargin' => $this->tMargin, - 'o_lMargin' => $this->lMargin, - 'o_rMargin' => $this->rMargin, - 'o_h' => $this->h, - 'o_w' => $this->w, - 'o_FontFamily' => $this->FontFamily, - 'o_FontStyle' => $this->FontStyle, - 'o_FontSizePt' => $this->FontSizePt, - 'o_FontSize' => $this->FontSize, - 'buffer' => '', - 'x' => $x, - 'y' => $y, - 'w' => $w, - 'h' => $h - ); - - $this->SetAutoPageBreak(false); - - // Define own high and width to calculate possitions correct - $this->h = $h; - $this->w = $w; - - $this->_intpl = true; - $this->SetXY($x + $this->lMargin, $y + $this->tMargin); - $this->SetRightMargin($this->w - $w + $this->rMargin); - - if ($this->CurrentFont) { - $fontkey = $this->FontFamily . $this->FontStyle; - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - - $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); - } - - return $this->tpl; - } - - /** - * End Template - * - * This method ends a template and reset initiated variables on beginTemplate. - * - * @return mixed If a template is opened, the ID is returned. If not a false is returned. - */ - function endTemplate() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); - } - - if ($this->_intpl) { - $this->_intpl = false; - $tpl =& $this->tpls[$this->tpl]; - $this->SetXY($tpl['o_x'], $tpl['o_y']); - $this->tMargin = $tpl['o_tMargin']; - $this->lMargin = $tpl['o_lMargin']; - $this->rMargin = $tpl['o_rMargin']; - $this->h = $tpl['o_h']; - $this->w = $tpl['o_w']; - $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); - - $this->FontFamily = $tpl['o_FontFamily']; - $this->FontStyle = $tpl['o_FontStyle']; - $this->FontSizePt = $tpl['o_FontSizePt']; - $this->FontSize = $tpl['o_FontSize']; - - $fontkey = $this->FontFamily . $this->FontStyle; - if ($fontkey) - $this->CurrentFont =& $this->fonts[$fontkey]; - - return $this->tpl; - } else { - return false; - } - } - - /** - * Use a Template in current Page or other Template - * - * You can use a template in a page or in another template. - * You can give the used template a new size like you use the Image()-method. - * All parameters are optional. The width or height is calculated automaticaly - * if one is given. If no parameter is given the origin size as defined in - * beginTemplate() is used. - * The calculated or used width and height are returned as an array. - * - * @param int $tplidx A valid template-Id - * @param int $_x The x-position - * @param int $_y The y-position - * @param int $_w The new width of the template - * @param int $_h The new height of the template - * @retrun array The height and width of the template - */ - function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { - if ($this->page <= 0) - $this->error('You have to add a page first!'); - - if (!isset($this->tpls[$tplidx])) - $this->error('Template does not exist!'); - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; - } - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_x == null) - $_x = 0; - if ($_y == null) - $_y = 0; - - $_x += $tpl['x']; - $_y += $tpl['y']; - - $wh = $this->getTemplateSize($tplidx, $_w, $_h); - $_w = $wh['w']; - $_h = $wh['h']; - - $tData = array( - 'x' => $this->x, - 'y' => $this->y, - 'w' => $_w, - 'h' => $_h, - 'scaleX' => ($_w / $w), - 'scaleY' => ($_h / $h), - 'tx' => $_x, - 'ty' => ($this->h - $_y - $_h), - 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) - ); - - $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate - $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); - - $this->lastUsedTemplateData = $tData; - - return array('w' => $_w, 'h' => $_h); - } - - /** - * Get The calculated Size of a Template - * - * If one size is given, this method calculates the other one. - * - * @param int $tplidx A valid template-Id - * @param int $_w The width of the template - * @param int $_h The height of the template - * @return array The height and width of the template - */ - function getTemplateSize($tplidx, $_w = 0, $_h = 0) { - if (!isset($this->tpls[$tplidx])) - return false; - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_w == 0 and $_h == 0) { - $_w = $w; - $_h = $h; - } - - if($_w == 0) - $_w = $_h * $w / $h; - if($_h == 0) - $_h = $_w * $h / $w; - - return array("w" => $_w, "h" => $_h); - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - public function SetFont($family, $style = '', $size = 0) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); - } - - parent::SetFont($family, $style, $size); - - $fontkey = $this->FontFamily . $this->FontStyle; - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } else { - $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - function Image( - $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, - $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, - $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() - ) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Image'), $args); - } - - $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; - } else { - $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; - } - - return $ret; - } - - /** - * See FPDF-Documentation ;-) - * - * AddPage is not available when you're "in" a template. - */ - function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); - } - - if ($this->_intpl) - $this->Error('Adding pages in templates isn\'t possible!'); - - parent::AddPage($orientation, $format); - } - - /** - * Preserve adding Links in Templates ...won't work - */ - function Link($x, $y, $w, $h, $link, $spaces = 0) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Link'), $args); - } - - if ($this->_intpl) - $this->Error('Using links in templates aren\'t possible!'); - - parent::Link($x, $y, $w, $h, $link); - } - - function AddLink() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); - } - - if ($this->_intpl) - $this->Error('Adding links in templates aren\'t possible!'); - return parent::AddLink(); - } - - function SetLink($link, $y = 0, $page = -1) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); - } - - if ($this->_intpl) - $this->Error('Setting links in templates aren\'t possible!'); - parent::SetLink($link, $y, $page); - } - - /** - * Private Method that writes the form xobjects - */ - function _putformxobjects() { - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; - reset($this->tpls); - foreach($this->tpls AS $tplidx => $tpl) { - - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; - $this->_newobj(); - $this->tpls[$tplidx]['n'] = $this->n; - $this->_out('<<'.$filter.'/Type /XObject'); - $this->_out('/Subtype /Form'); - $this->_out('/FormType 1'); - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', - // llx - $tpl['x'] * $this->k, - // lly - -$tpl['y'] * $this->k, - // urx - ($tpl['w'] + $tpl['x']) * $this->k, - // ury - ($tpl['h'] - $tpl['y']) * $this->k - )); - - if ($tpl['x'] != 0 || $tpl['y'] != 0) { - $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', - -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 - )); - } - - $this->_out('/Resources '); - - $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { - $this->_out('/Font <<'); - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); - $this->_out('>>'); - } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) - { - $this->_out('/XObject <<'); - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { - foreach($this->_res['tpl'][$tplidx]['images'] as $image) - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); - } - if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); - } - $this->_out('>>'); - } - $this->_out('>>'); - - $this->_out('/Length ' . strlen($p) . ' >>'); - $this->_putstream($p); - $this->_out('endobj'); - } - } - - /** - * Overwritten to add _putformxobjects() after _putimages() - * - */ - function _putimages() { - parent::_putimages(); - $this->_putformxobjects(); - } - - function _putxobjectdict() { - parent::_putxobjectdict(); - - if (count($this->tpls)) { - foreach($this->tpls as $tplidx => $tpl) { - $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); - } - } - } - - /** - * Private Method - */ - function _out($s) { - if ($this->state == 2 && $this->_intpl) { - $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; - } else { - parent::_out($s); - } - } -} +Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); + return; + } + + if ($this->page <= 0) + $this->error("You have to add a page to fpdf first!"); + + if ($x == null) + $x = 0; + if ($y == null) + $y = 0; + if ($w == null) + $w = $this->w; + if ($h == null) + $h = $this->h; + + // Save settings + $this->tpl++; + $tpl =& $this->tpls[$this->tpl]; + $tpl = array( + 'o_x' => $this->x, + 'o_y' => $this->y, + 'o_AutoPageBreak' => $this->AutoPageBreak, + 'o_bMargin' => $this->bMargin, + 'o_tMargin' => $this->tMargin, + 'o_lMargin' => $this->lMargin, + 'o_rMargin' => $this->rMargin, + 'o_h' => $this->h, + 'o_w' => $this->w, + 'o_FontFamily' => $this->FontFamily, + 'o_FontStyle' => $this->FontStyle, + 'o_FontSizePt' => $this->FontSizePt, + 'o_FontSize' => $this->FontSize, + 'buffer' => '', + 'x' => $x, + 'y' => $y, + 'w' => $w, + 'h' => $h + ); + + $this->SetAutoPageBreak(false); + + // Define own high and width to calculate possitions correct + $this->h = $h; + $this->w = $w; + + $this->_intpl = true; + $this->SetXY($x + $this->lMargin, $y + $this->tMargin); + $this->SetRightMargin($this->w - $w + $this->rMargin); + + if ($this->CurrentFont) { + $fontkey = $this->FontFamily . $this->FontStyle; + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + + $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); + } + + return $this->tpl; + } + + /** + * End Template + * + * This method ends a template and reset initiated variables on beginTemplate. + * + * @return mixed If a template is opened, the ID is returned. If not a false is returned. + */ + function endTemplate() { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); + } + + if ($this->_intpl) { + $this->_intpl = false; + $tpl =& $this->tpls[$this->tpl]; + $this->SetXY($tpl['o_x'], $tpl['o_y']); + $this->tMargin = $tpl['o_tMargin']; + $this->lMargin = $tpl['o_lMargin']; + $this->rMargin = $tpl['o_rMargin']; + $this->h = $tpl['o_h']; + $this->w = $tpl['o_w']; + $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); + + $this->FontFamily = $tpl['o_FontFamily']; + $this->FontStyle = $tpl['o_FontStyle']; + $this->FontSizePt = $tpl['o_FontSizePt']; + $this->FontSize = $tpl['o_FontSize']; + + $fontkey = $this->FontFamily . $this->FontStyle; + if ($fontkey) + $this->CurrentFont =& $this->fonts[$fontkey]; + + return $this->tpl; + } else { + return false; + } + } + + /** + * Use a Template in current Page or other Template + * + * You can use a template in a page or in another template. + * You can give the used template a new size like you use the Image()-method. + * All parameters are optional. The width or height is calculated automaticaly + * if one is given. If no parameter is given the origin size as defined in + * beginTemplate() is used. + * The calculated or used width and height are returned as an array. + * + * @param int $tplidx A valid template-Id + * @param int $_x The x-position + * @param int $_y The y-position + * @param int $_w The new width of the template + * @param int $_h The new height of the template + * @retrun array The height and width of the template + */ + function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { + if ($this->page <= 0) + $this->error('You have to add a page first!'); + + if (!isset($this->tpls[$tplidx])) + $this->error('Template does not exist!'); + + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; + } + + $tpl =& $this->tpls[$tplidx]; + $w = $tpl['w']; + $h = $tpl['h']; + + if ($_x == null) + $_x = 0; + if ($_y == null) + $_y = 0; + + $_x += $tpl['x']; + $_y += $tpl['y']; + + $wh = $this->getTemplateSize($tplidx, $_w, $_h); + $_w = $wh['w']; + $_h = $wh['h']; + + $tData = array( + 'x' => $this->x, + 'y' => $this->y, + 'w' => $_w, + 'h' => $_h, + 'scaleX' => ($_w / $w), + 'scaleY' => ($_h / $h), + 'tx' => $_x, + 'ty' => ($this->h - $_y - $_h), + 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) + ); + + $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate + $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); + + $this->lastUsedTemplateData = $tData; + + return array('w' => $_w, 'h' => $_h); + } + + /** + * Get The calculated Size of a Template + * + * If one size is given, this method calculates the other one. + * + * @param int $tplidx A valid template-Id + * @param int $_w The width of the template + * @param int $_h The height of the template + * @return array The height and width of the template + */ + function getTemplateSize($tplidx, $_w = 0, $_h = 0) { + if (!isset($this->tpls[$tplidx])) + return false; + + $tpl =& $this->tpls[$tplidx]; + $w = $tpl['w']; + $h = $tpl['h']; + + if ($_w == 0 and $_h == 0) { + $_w = $w; + $_h = $h; + } + + if($_w == 0) + $_w = $_h * $w / $h; + if($_h == 0) + $_h = $_w * $h / $w; + + return array("w" => $_w, "h" => $_h); + } + + /** + * See FPDF/TCPDF-Documentation ;-) + */ + public function SetFont($family, $style = '', $size = 0) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); + } + + parent::SetFont($family, $style, $size); + + $fontkey = $this->FontFamily . $this->FontStyle; + + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + } else { + $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + } + } + + /** + * See FPDF/TCPDF-Documentation ;-) + */ + function Image( + $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, + $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, + $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() + ) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::Image'), $args); + } + + $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; + } else { + $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; + } + + return $ret; + } + + /** + * See FPDF-Documentation ;-) + * + * AddPage is not available when you're "in" a template. + */ + function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); + } + + if ($this->_intpl) + $this->Error('Adding pages in templates isn\'t possible!'); + + parent::AddPage($orientation, $format); + } + + /** + * Preserve adding Links in Templates ...won't work + */ + function Link($x, $y, $w, $h, $link, $spaces = 0) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::Link'), $args); + } + + if ($this->_intpl) + $this->Error('Using links in templates aren\'t possible!'); + + parent::Link($x, $y, $w, $h, $link); + } + + function AddLink() { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); + } + + if ($this->_intpl) + $this->Error('Adding links in templates aren\'t possible!'); + return parent::AddLink(); + } + + function SetLink($link, $y = 0, $page = -1) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); + } + + if ($this->_intpl) + $this->Error('Setting links in templates aren\'t possible!'); + parent::SetLink($link, $y, $page); + } + + /** + * Private Method that writes the form xobjects + */ + function _putformxobjects() { + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + reset($this->tpls); + foreach($this->tpls AS $tplidx => $tpl) { + + $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; + $this->_newobj(); + $this->tpls[$tplidx]['n'] = $this->n; + $this->_out('<<'.$filter.'/Type /XObject'); + $this->_out('/Subtype /Form'); + $this->_out('/FormType 1'); + $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', + // llx + $tpl['x'] * $this->k, + // lly + -$tpl['y'] * $this->k, + // urx + ($tpl['w'] + $tpl['x']) * $this->k, + // ury + ($tpl['h'] - $tpl['y']) * $this->k + )); + + if ($tpl['x'] != 0 || $tpl['y'] != 0) { + $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', + -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 + )); + } + + $this->_out('/Resources '); + + $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { + $this->_out('/Font <<'); + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); + $this->_out('>>'); + } + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || + isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) + { + $this->_out('/XObject <<'); + if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { + foreach($this->_res['tpl'][$tplidx]['images'] as $image) + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); + } + if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); + } + $this->_out('>>'); + } + $this->_out('>>'); + + $this->_out('/Length ' . strlen($p) . ' >>'); + $this->_putstream($p); + $this->_out('endobj'); + } + } + + /** + * Overwritten to add _putformxobjects() after _putimages() + * + */ + function _putimages() { + parent::_putimages(); + $this->_putformxobjects(); + } + + function _putxobjectdict() { + parent::_putxobjectdict(); + + if (count($this->tpls)) { + foreach($this->tpls as $tplidx => $tpl) { + $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); + } + } + } + + /** + * Private Method + */ + function _out($s) { + if ($this->state == 2 && $this->_intpl) { + $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; + } else { + parent::_out($s); + } + } +} From 8e29dcdb79866858a9970d3d9bbd33c270ead8bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 21:59:03 +0100 Subject: [PATCH 113/120] Some fix after merging bank account number form --- htdocs/compta/bank/card.php | 60 +++++++++++----------- htdocs/compta/bank/class/account.class.php | 28 +++++----- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 0b4307f8a98..c84e7f47482 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $langs->load("banks"); +$langs->load("bills"); $langs->load("categories"); $langs->load("companies"); $langs->load("compta"); @@ -70,7 +71,7 @@ if ($_POST["action"] == 'add') $account->clos = $_POST["clos"]; $account->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; $account->url = $_POST["url"]; - + $account->bank = trim($_POST["bank"]); $account->code_banque = trim($_POST["code_banque"]); $account->code_guichet = trim($_POST["code_guichet"]); @@ -94,8 +95,8 @@ if ($_POST["action"] == 'add') $account->state_id = $_POST["account_state_id"]; $account->country_id = $_POST["account_country_id"]; - $account->min_allowed = $_POST["account_min_allowed"]; - $account->min_desired = $_POST["account_min_desired"]; + $account->min_allowed = GETPOST("account_min_allowed",'int'); + $account->min_desired = GETPOST("account_min_desired",'int'); $account->comment = trim($_POST["account_comment"]); if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number)) @@ -169,8 +170,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) $account->state_id = $_POST["account_state_id"]; $account->country_id = $_POST["account_country_id"]; - $account->min_allowed = $_POST["account_min_allowed"]; - $account->min_desired = $_POST["account_min_desired"]; + $account->min_allowed = GETPOST("account_min_allowed",'int'); + $account->min_desired = GETPOST("account_min_desired",'int'); $account->comment = trim($_POST["account_comment"]); if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number)) @@ -251,9 +252,6 @@ if ($action == 'create') document.formsoc.action.value="create"; document.formsoc.submit(); }); - })'."\n"; - - print 'jQuery(document).ready(function () { jQuery("#selectaccount_country_id").change(function() { document.formsoc.action.value="create"; document.formsoc.submit(); @@ -275,7 +273,7 @@ if ($action == 'create') // Label print '
'.$langs->trans("LabelBankCashAccount").'
'.$langs->trans("AccountType").'
'.$langs->trans("BankAccountCountry").''; + // Country $selectedcode=''; if (isset($_POST["account_country_id"])) { $selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$account->country_code; } else if (empty($selectedcode)) $selectedcode=$mysoc->country_code; + $account->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + + print '
'.$langs->trans("BankAccountCountry").''; print $form->select_country($selectedcode,'account_country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment',$account->comment,'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70); + $doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$account->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,4,70); $doleditor->Create(); print '
'.$langs->trans("InitialBankBalance").'solde)).'">
solde)).'">
'.$langs->trans("Date").''; @@ -445,10 +445,10 @@ if ($action == 'create') if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; // IBAN - print '
'.$langs->trans($ibankey).'
'.$langs->trans($ibankey).'
'.$langs->trans($bickey).'
'.$langs->trans($bickey).'
'.$langs->trans("BankAccountDomiciliation").''; @@ -468,25 +468,25 @@ if ($action == 'create') print '
'; print '
'; } - + print ''; // Accountancy code if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) { print ''; - print ''; + print ''; } else { print ''; - print ''; + print ''; } // Accountancy journal if (! empty($conf->accounting->enabled)) { print ''; - print ''; + print ''; } print '
'.$langs->trans("AccountancyCode").'
account_number).'">
'.$langs->trans("AccountancyCode").'
account_number).'">
'.$langs->trans("AccountancyJournal").'
accountancy_journal).'">
'; @@ -599,7 +599,7 @@ else print "
'.$langs->trans("Comment").''.$account->comment.'
'.dol_htmlentitiesbr($account->comment).'
'; print '
'; - + if ($account->type == 0 || $account->type == 1) { print ''; - + print ''; print ''; @@ -783,7 +783,7 @@ else document.formsoc.submit(); }); })'."\n"; - + print 'jQuery(document).ready(function () { jQuery("#selectaccount_country_id").change(function() { document.formsoc.action.value="edit"; @@ -834,11 +834,13 @@ else // Country $account->country_id=$account->country_id?$account->country_id:$mysoc->country_id; - print ''; - print ''; + print ''; @@ -881,7 +883,7 @@ else print ''; @@ -898,7 +900,7 @@ else if ($_POST["type"] == 0 || $_POST["type"] == 1) { print '
'.$langs->trans("BankName").''.$account->bank.'
'.$langs->trans("Country").''; $selectedcode=$account->country_code; if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"]; else if (empty($selectedcode)) $selectedcode=$mysoc->country_code; + $account->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + + print '
'.$langs->trans("Country").''; print $form->select_country($selectedcode,'account_country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment',(isset($_POST["account_comment"])?$_POST["account_comment"]:$account->comment),'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70); + $doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$account->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,4,70); $doleditor->Create(); print '
'; - + // If bank account print ''; print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 98ef24e177d..cfbda320fb7 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -468,7 +468,7 @@ class Account extends CommonObject $this->error=$this->db->lasterror(); return -3; } - + // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('bankdao')); $parameters=array('id'=>$this->id); @@ -513,8 +513,6 @@ class Account extends CommonObject global $langs,$conf, $hookmanager; // Clean parameters - if (! $this->min_allowed) $this->min_allowed=0; - if (! $this->min_desired) $this->min_desired=0; $this->state_id = ($this->state_id?$this->state_id:$this->state_id); $this->country_id = ($this->country_id?$this->country_id:$this->country_id); @@ -544,7 +542,7 @@ class Account extends CommonObject $sql.= ",url = ".($this->url?"'".$this->url."'":"null"); $sql.= ",account_number = '".$this->account_number."'"; $sql.= ",accountancy_journal = '".$this->accountancy_journal."'"; - + $sql.= ",bank = '".$this->db->escape($this->bank)."'"; $sql.= ",code_banque='".$this->code_banque."'"; $sql.= ",code_guichet='".$this->code_guichet."'"; @@ -558,8 +556,8 @@ class Account extends CommonObject $sql.= ",currency_code = '".$this->currency_code."'"; - $sql.= ",min_allowed = '".price2num($this->min_allowed)."'"; - $sql.= ",min_desired = '".price2num($this->min_desired)."'"; + $sql.= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null"); + $sql.= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null"); $sql.= ",comment = '".$this->db->escape($this->comment)."'"; $sql.= ",state_id = ".($this->state_id>0?"'".$this->state_id."'":"null"); @@ -572,7 +570,7 @@ class Account extends CommonObject $result = $this->db->query($sql); if ($result) { - + // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('bankdao')); $parameters=array('id'=>$this->id); @@ -589,8 +587,8 @@ class Account extends CommonObject } } else if ($reshook < 0) return -1; - - + + return 1; } else @@ -736,15 +734,15 @@ class Account extends CommonObject $this->min_allowed = $obj->min_allowed; $this->min_desired = $obj->min_desired; $this->comment = $obj->comment; - + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $extrafields=new ExtraFields($this->db); $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); $this->fetch_optionals($this->id,$extralabels); - - + + return 1; } else @@ -776,7 +774,7 @@ class Account extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - + // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { @@ -787,7 +785,7 @@ class Account extends CommonObject dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } - + return 1; } else { @@ -1076,7 +1074,7 @@ class Account extends CommonObject * * @return int 0=No bank code need + Account number is enough * 1=Need 2 fields for bank code: Bank, Desk (France, Spain, ...) + Account number and key - * 2=Neek 1 field for bank code: Bank only (Sort code for Great Britain, BSB for Australia) + Account number + * 2=Need 1 field for bank code: Bank only (Sort code for Great Britain, BSB for Australia) + Account number */ function useDetailedBBAN() { From 5c36db06f60483772b7568b0c0182225d7728dce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 23:04:37 +0100 Subject: [PATCH 114/120] Add missing files --- htdocs/install/mysql/data/llx_c_incoterms.sql | 41 +++++++++++++++++++ .../mysql/tables/llx_c_incoterms.key.sql | 19 +++++++++ .../install/mysql/tables/llx_c_incoterms.sql | 25 +++++++++++ 3 files changed, 85 insertions(+) create mode 100644 htdocs/install/mysql/data/llx_c_incoterms.sql create mode 100644 htdocs/install/mysql/tables/llx_c_incoterms.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_incoterms.sql diff --git a/htdocs/install/mysql/data/llx_c_incoterms.sql b/htdocs/install/mysql/data/llx_c_incoterms.sql new file mode 100644 index 00000000000..ad9b09f09fc --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_incoterms.sql @@ -0,0 +1,41 @@ +-- Copyright (C) 2001-2004 Rodolphe Quiedeville +-- Copyright (C) 2003 Jean-Louis Bergamo +-- Copyright (C) 2004-2009 Laurent Destailleur +-- Copyright (C) 2004 Benoit Mortier +-- Copyright (C) 2004 Guillaume Delecourt +-- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2007 Patrick Raguin +-- +-- 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 3 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, see . +-- +-- + +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + + +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('EXW', 'Ex Works, au départ non chargé, non dédouané sortie d''usine (uniquement adapté aux flux domestiques, nationaux)', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FCA', 'Free Carrier, marchandises dédouanées et chargées dans le pays de départ, chez le vendeur ou chez le commissionnaire de transport de l''acheteur', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FAS', 'Free Alongside Ship, sur le quai du port de départ', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('FOB', 'Free On Board, chargé sur le bateau, les frais de chargement dans celui-ci étant fonction du liner term indiqué par la compagnie maritime (à la charge du vendeur)', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CFR', 'Cost and Freight, chargé dans le bateau, livraison au port de départ, frais payés jusqu''au port d''arrivée, sans assurance pour le transport, non déchargé du navire à destination (les frais de déchargement sont inclus ou non au port d''arrivée)', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CIF', 'Cost, Insurance and Freight, chargé sur le bateau, frais jusqu''au port d''arrivée, avec l''assurance marchandise transportée souscrite par le vendeur pour le compte de l''acheteur', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CPT', 'Carriage Paid To, livraison au premier transporteur, frais jusqu''au déchargement du mode de transport, sans assurance pour le transport', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('CIP', 'Carriage and Insurance Paid to, idem CPT, avec assurance marchandise transportée souscrite par le vendeur pour le compte de l''acheteur', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DAT', 'Delivered At Terminal, marchandises (déchargées) livrées sur quai, dans un terminal maritime, fluvial, aérien, routier ou ferroviaire désigné (dédouanement import, et post-acheminement payés par l''acheteur)', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DAP', 'Delivered At Place, marchandises (non déchargées) mises à disposition de l''acheteur dans le pays d''importation au lieu précisé dans le contrat (déchargement, dédouanement import payé par l''acheteur)', 1); +INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DDP', 'Delivered Duty Paid, marchandises (non déchargées) livrées à destination finale, dédouanement import et taxes à la charge du vendeur ; l''acheteur prend en charge uniquement le déchargement (si exclusion des taxes type TVA, le préciser clairement)', 1); + diff --git a/htdocs/install/mysql/tables/llx_c_incoterms.key.sql b/htdocs/install/mysql/tables/llx_c_incoterms.key.sql new file mode 100644 index 00000000000..65614a90c4d --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_incoterms.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2009 Laurent Destailleur +-- +-- 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 3 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, see . +-- +-- ======================================================================== + +ALTER TABLE llx_c_incoterms ADD UNIQUE INDEX uk_c_incoterms (code); diff --git a/htdocs/install/mysql/tables/llx_c_incoterms.sql b/htdocs/install/mysql/tables/llx_c_incoterms.sql new file mode 100644 index 00000000000..c960f0fab2f --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_incoterms.sql @@ -0,0 +1,25 @@ +-- ======================================================================== +-- Copyright (C) 2015 Laurent Destailleur +-- +-- 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 3 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, see . +-- +-- ======================================================================== + +CREATE TABLE llx_c_incoterms ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(3) NOT NULL, + libelle varchar(255) NOT NULL, + active tinyint DEFAULT 1 NOT NULL +) ENGINE=innodb; + From 39a7271f910b8de71003b8eee910069fd06f012d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 10:57:17 +0100 Subject: [PATCH 115/120] Fix bad merge --- htdocs/includes/tcpdi/fpdf_tpl.php | 271 ++--------------------------- 1 file changed, 10 insertions(+), 261 deletions(-) diff --git a/htdocs/includes/tcpdi/fpdf_tpl.php b/htdocs/includes/tcpdi/fpdf_tpl.php index 0c60a6ed6f3..be03a39b5d3 100644 --- a/htdocs/includes/tcpdi/fpdf_tpl.php +++ b/htdocs/includes/tcpdi/fpdf_tpl.php @@ -29,21 +29,13 @@ class FPDF_TPL extends FPDF { * @var int */ var $tpl = 0; -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * "In Template"-Flag * @var boolean */ var $_intpl = false; -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Nameprefix of Templates used in Resources-Dictonary * @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an / @@ -55,22 +47,14 @@ class FPDF_TPL extends FPDF { * @var array */ var $_res = array(); -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Last used Template data * * @var array */ var $lastUsedTemplateData = array(); -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Start a Template * @@ -90,19 +74,11 @@ class FPDF_TPL extends FPDF { * @return int The ID of new created Template */ function beginTemplate($x = null, $y = null, $w = null, $h = null) { -<<<<<<< HEAD if (is_subclass_of($this, 'TCPDF')) { $this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); return; } - -======= - if (is_subclass_of($this, 'TCPDF')) { - $this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); - return; - } ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($this->page <= 0) $this->error("You have to add a page to fpdf first!"); @@ -140,11 +116,7 @@ class FPDF_TPL extends FPDF { ); $this->SetAutoPageBreak(false); -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 // Define own high and width to calculate possitions correct $this->h = $h; $this->w = $w; @@ -155,25 +127,14 @@ class FPDF_TPL extends FPDF { if ($this->CurrentFont) { $fontkey = $this->FontFamily . $this->FontStyle; -<<<<<<< HEAD $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - + $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); } - - return $this->tpl; - } - -======= - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - - $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); - } return $this->tpl; } ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * End Template * @@ -182,23 +143,13 @@ class FPDF_TPL extends FPDF { * @return mixed If a template is opened, the ID is returned. If not a false is returned. */ function endTemplate() { -<<<<<<< HEAD if (is_subclass_of($this, 'TCPDF')) { $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); } - - if ($this->_intpl) { - $this->_intpl = false; -======= - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); - } if ($this->_intpl) { $this->_intpl = false; ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 $tpl =& $this->tpls[$this->tpl]; $this->SetXY($tpl['o_x'], $tpl['o_y']); $this->tMargin = $tpl['o_tMargin']; @@ -207,39 +158,22 @@ class FPDF_TPL extends FPDF { $this->h = $tpl['o_h']; $this->w = $tpl['o_w']; $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); -<<<<<<< HEAD - + $this->FontFamily = $tpl['o_FontFamily']; $this->FontStyle = $tpl['o_FontStyle']; $this->FontSizePt = $tpl['o_FontSizePt']; $this->FontSize = $tpl['o_FontSize']; - + $fontkey = $this->FontFamily . $this->FontStyle; if ($fontkey) $this->CurrentFont =& $this->fonts[$fontkey]; - -======= - $this->FontFamily = $tpl['o_FontFamily']; - $this->FontStyle = $tpl['o_FontStyle']; - $this->FontSizePt = $tpl['o_FontSizePt']; - $this->FontSize = $tpl['o_FontSize']; - - $fontkey = $this->FontFamily . $this->FontStyle; - if ($fontkey) - $this->CurrentFont =& $this->fonts[$fontkey]; - ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 return $this->tpl; } else { return false; } } -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Use a Template in current Page or other Template * @@ -259,22 +193,7 @@ class FPDF_TPL extends FPDF { */ function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { if ($this->page <= 0) -<<<<<<< HEAD $this->error('You have to add a page first!'); - - if (!isset($this->tpls[$tplidx])) - $this->error('Template does not exist!'); - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; - } - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - -======= - $this->error('You have to add a page first!'); if (!isset($this->tpls[$tplidx])) $this->error('Template does not exist!'); @@ -287,21 +206,10 @@ class FPDF_TPL extends FPDF { $w = $tpl['w']; $h = $tpl['h']; ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($_x == null) $_x = 0; if ($_y == null) $_y = 0; -<<<<<<< HEAD - - $_x += $tpl['x']; - $_y += $tpl['y']; - - $wh = $this->getTemplateSize($tplidx, $_w, $_h); - $_w = $wh['w']; - $_h = $wh['h']; - -======= $_x += $tpl['x']; $_y += $tpl['y']; @@ -310,7 +218,6 @@ class FPDF_TPL extends FPDF { $_w = $wh['w']; $_h = $wh['h']; ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 $tData = array( 'x' => $this->x, 'y' => $this->y, @@ -322,17 +229,6 @@ class FPDF_TPL extends FPDF { 'ty' => ($this->h - $_y - $_h), 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) ); -<<<<<<< HEAD - - $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate - $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); - - $this->lastUsedTemplateData = $tData; - - return array('w' => $_w, 'h' => $_h); - } - -======= $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); @@ -342,7 +238,6 @@ class FPDF_TPL extends FPDF { return array('w' => $_w, 'h' => $_h); } ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Get The calculated Size of a Template * @@ -360,75 +255,44 @@ class FPDF_TPL extends FPDF { $tpl =& $this->tpls[$tplidx]; $w = $tpl['w']; $h = $tpl['h']; -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($_w == 0 and $_h == 0) { $_w = $w; $_h = $h; } -<<<<<<< HEAD if($_w == 0) $_w = $_h * $w / $h; if($_h == 0) $_h = $_w * $h / $w; - - return array("w" => $_w, "h" => $_h); - } - -======= - if($_w == 0) - $_w = $_h * $w / $h; - if($_h == 0) - $_h = $_w * $h / $w; return array("w" => $_w, "h" => $_h); } ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * See FPDF/TCPDF-Documentation ;-) */ public function SetFont($family, $style = '', $size = 0) { if (is_subclass_of($this, 'TCPDF')) { -<<<<<<< HEAD $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); } - - parent::SetFont($family, $style, $size); - - $fontkey = $this->FontFamily . $this->FontStyle; - -======= - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); - } parent::SetFont($family, $style, $size); $fontkey = $this->FontFamily . $this->FontStyle; ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($this->_intpl) { $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; } else { $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; } } -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * See FPDF/TCPDF-Documentation ;-) */ function Image( -<<<<<<< HEAD $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() @@ -437,60 +301,31 @@ class FPDF_TPL extends FPDF { $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::Image'), $args); } - -======= - $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, - $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, - $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() - ) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Image'), $args); - } ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); if ($this->_intpl) { $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; } else { $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; } -<<<<<<< HEAD - - return $ret; - } - -======= return $ret; } ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * See FPDF-Documentation ;-) * * AddPage is not available when you're "in" a template. */ function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { -<<<<<<< HEAD if (is_subclass_of($this, 'TCPDF')) { $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); } - - if ($this->_intpl) - $this->Error('Adding pages in templates isn\'t possible!'); - -======= - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); - } if ($this->_intpl) $this->Error('Adding pages in templates isn\'t possible!'); ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 parent::AddPage($orientation, $format); } @@ -499,77 +334,43 @@ class FPDF_TPL extends FPDF { */ function Link($x, $y, $w, $h, $link, $spaces = 0) { if (is_subclass_of($this, 'TCPDF')) { -<<<<<<< HEAD $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::Link'), $args); } - + if ($this->_intpl) $this->Error('Using links in templates aren\'t possible!'); - + parent::Link($x, $y, $w, $h, $link); } - + function AddLink() { if (is_subclass_of($this, 'TCPDF')) { $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); } - -======= - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Link'), $args); - } - if ($this->_intpl) - $this->Error('Using links in templates aren\'t possible!'); - - parent::Link($x, $y, $w, $h, $link); - } - - function AddLink() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); - } - ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($this->_intpl) $this->Error('Adding links in templates aren\'t possible!'); return parent::AddLink(); } -<<<<<<< HEAD - + function SetLink($link, $y = 0, $page = -1) { if (is_subclass_of($this, 'TCPDF')) { $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); } - -======= - function SetLink($link, $y = 0, $page = -1) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); - } - ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($this->_intpl) $this->Error('Setting links in templates aren\'t possible!'); parent::SetLink($link, $y, $page); } -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Private Method that writes the form xobjects */ function _putformxobjects() { $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; -<<<<<<< HEAD reset($this->tpls); foreach($this->tpls AS $tplidx => $tpl) { @@ -577,15 +378,6 @@ class FPDF_TPL extends FPDF { $this->_newobj(); $this->tpls[$tplidx]['n'] = $this->n; $this->_out('<<'.$filter.'/Type /XObject'); -======= - reset($this->tpls); - foreach($this->tpls AS $tplidx => $tpl) { - - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; - $this->_newobj(); - $this->tpls[$tplidx]['n'] = $this->n; - $this->_out('<<'.$filter.'/Type /XObject'); ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 $this->_out('/Subtype /Form'); $this->_out('/FormType 1'); $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', @@ -598,18 +390,13 @@ class FPDF_TPL extends FPDF { // ury ($tpl['h'] - $tpl['y']) * $this->k )); -<<<<<<< HEAD - -======= ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($tpl['x'] != 0 || $tpl['y'] != 0) { $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 )); } -<<<<<<< HEAD - + $this->_out('/Resources '); $this->_out('<_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); $this->_out('>>'); } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { $this->_out('/XObject <<'); if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { foreach($this->_res['tpl'][$tplidx]['images'] as $image) $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); -======= - - $this->_out('/Resources '); - - $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { - $this->_out('/Font <<'); - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); - $this->_out('>>'); - } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) - { - $this->_out('/XObject <<'); - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { - foreach($this->_res['tpl'][$tplidx]['images'] as $image) - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 } if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); } $this->_out('>>'); -<<<<<<< HEAD } $this->_out('>>'); - + $this->_out('/Length ' . strlen($p) . ' >>'); $this->_putstream($p); $this->_out('endobj'); } } - -======= - } - $this->_out('>>'); - $this->_out('/Length ' . strlen($p) . ' >>'); - $this->_putstream($p); - $this->_out('endobj'); - } - } - ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Overwritten to add _putformxobjects() after _putimages() * @@ -680,17 +436,10 @@ class FPDF_TPL extends FPDF { parent::_putimages(); $this->_putformxobjects(); } -<<<<<<< HEAD - - function _putxobjectdict() { - parent::_putxobjectdict(); - -======= function _putxobjectdict() { parent::_putxobjectdict(); ->>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if (count($this->tpls)) { foreach($this->tpls as $tplidx => $tpl) { $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); From c36f92396b03890be7367a1398c48dc06ccda990 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 11:13:44 +0100 Subject: [PATCH 116/120] Add navigation into the new timesheet week page. Fix bad merge --- htdocs/core/lib/project.lib.php | 37 ++++++++++++----------- htdocs/langs/en_US/projects.lang | 3 +- htdocs/main.inc.php | 4 +-- htdocs/projet/activity/perday.php | 50 +++++++++++++++++++++++++++++-- 4 files changed, 69 insertions(+), 25 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index eb7617b5c7e..e4015812e62 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -234,10 +234,10 @@ function project_admin_prepare_head() /** * Show task lines with a particular parent * - * @param string $inc Counter that count number of lines legitimate to show (for return) - * @param int $parent Id of parent task to start - * @param array $lines Array of all tasks - * @param int $level Level of task + * @param string $inc Line number (start to 0, then increased by recursive call) + * @param string $parent Id of parent project to show (0 to show all) + * @param Task[] $lines Array of lines + * @param int $level Level (start to 0, then increased/decrease by recursive call) * @param string $var Color * @param int $showproject Show project columns * @param int $taskrole Array of roles of user for each tasks @@ -482,12 +482,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t /** * Output a task line into a pertime intput mode * - * @param string $inc ? - * @param string $parent ? - * @param Task[] $lines ? - * @param int $level ? - * @param string $projectsrole ? - * @param string $tasksrole ? + * @param string $inc Line number (start to 0, then increased by recursive call) + * @param string $parent Id of parent project to show (0 to show all) + * @param Task[] $lines Array of lines + * @param int $level Level (start to 0, then increased/decrease by recursive call) + * @param string $projectsrole Array of roles user has on project + * @param string $tasksrole Array of roles user has on task * @param string $mine Show only task lines I am assigned to * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @return $inc @@ -628,12 +628,12 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$ /** * Output a task line into a perday intput mode * - * @param string $inc ? - * @param string $parent ? - * @param Task[] $lines ? - * @param int $level ? - * @param string $projectsrole ? - * @param string $tasksrole ? + * @param string $inc Line number (start to 0, then increased by recursive call) + * @param string $parent Id of parent project to show (0 to show all) + * @param Task[] $lines Array of lines + * @param int $level Level (start to 0, then increased/decrease by recursive call) + * @param string $projectsrole Array of roles user has on project + * @param string $tasksrole Array of roles user has on task * @param string $mine Show only task lines I am assigned to * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @return $inc @@ -750,7 +750,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t { $dayWorkLoad = 0; $tableCell ='
'.$langs->trans("BankName").''; - $tableCell.='+'; + $tableCell.='+'; $tableCell.=''; @@ -927,7 +927,8 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta print "
"; - if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { + if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) + { //Add the year filter input print ''; print ''; diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index dc25c1f33b7..936e86ad692 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -136,4 +136,5 @@ ProjectMustBeValidatedFirst=Project must be validated first ProjectDraft=Draft projects FirstAddRessourceToAllocateTime=Associate a ressource to allocate time InputPerTime=Input per time -InputPerDay=Input per day \ No newline at end of file +InputPerDay=Input per day +TimeAlreadyRecorded=Time spent already recorded for this task/day and user %s \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4818b2d38f1..36e246c42f2 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1376,9 +1376,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a // Wrapper to show tooltips print "\n".''; } diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index f7b37ca1ca0..692267d6965 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -50,6 +50,11 @@ $result = restrictedArea($user, 'projet', $projectid); $now=dol_now(); +$year=GETPOST("year","int")?GETPOST("year","int"):date("Y"); +$month=GETPOST("month","int")?GETPOST("month","int"):date("m"); +$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); +$day=GETPOST("day","int")?GETPOST("day","int"):date("d"); + /* * Actions @@ -138,6 +143,40 @@ print "\n"; dol_fiche_end(); */ + +$startdayarray=dol_get_first_day_week($day, $month, $year); + +$prev = $startdayarray; +$prev_year = $prev['prev_year']; +$prev_month = $prev['prev_month']; +$prev_day = $prev['prev_day']; +$first_day = $prev['first_day']; +$first_month= $prev['first_month']; +$first_year = $prev['first_year']; +$week = $prev['week']; + +$day = (int) $day; +$next = dol_get_next_week($first_day, $week, $first_month, $first_year); +$next_year = $next['year']; +$next_month = $next['month']; +$next_day = $next['day']; + +// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) +$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); +$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); + +$tmpday = $first_day; + +// Show navigation bar +$nav ="".img_previous($langs->trans("Previous"))."\n"; +$nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week; +$nav.=" \n"; +$nav.="".img_next($langs->trans("Next"))."\n"; +$nav.="   (".$langs->trans("Today").")"; +$picto='calendarweek'; +print '
'.$nav.'
'; + + print '
'; print ''; print ''; @@ -147,8 +186,6 @@ print ''; print ''; //print ''; -$tmp=dol_getdate($now); -$startdayarray=dol_get_first_day_week($tmp['mday'], $tmp['mon'], $tmp['year']); $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); for($i=0;$i<7;$i++) @@ -192,7 +229,14 @@ print '
'; print ''; print '
'; -print ''; +print ''."\n\n"; + + +print ''; llxFooter(); From dc15eee533b85c5856d9508ad6ffb7f13c348198 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 11:21:58 +0100 Subject: [PATCH 117/120] Fix: missing dependcy on project to check before deleting --- htdocs/societe/class/societe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 510e184e521..a18aedfcc1b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani @@ -42,7 +42,7 @@ class Societe extends CommonObject public $element='societe'; public $table_element = 'societe'; public $fk_element='fk_soc'; - protected $childtables=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur"); // To test if we can delete object + protected $childtables=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur","projet"); // To test if we can delete object /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe From 9c12c325dbf60a450c6b23b8f57424f3999a2b57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 11:46:03 +0100 Subject: [PATCH 118/120] Fix regression into enable/disable external calendars --- htdocs/comm/action/index.php | 9 ++++----- htdocs/comm/action/peruser.php | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 1565bf79cac..f2e945cf83d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -363,17 +363,16 @@ if (! empty($conf->use_javascript_ajax)) { foreach ($showextcals as $val) { - $htmlname = dol_string_nospecial($val['name']); - $htmlname = dol_string_nospecial($htmlname,'_',array("\.","#")); + $htmlname = md5($val['name']); $s.='' . "\n"; - $s.='
' . $val ['name'] . '  
'; + $s.='
' . $val ['name'] . '  
'; } } $s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 599bc32ceba..0f281a91af4 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -305,16 +305,16 @@ if ($conf->use_javascript_ajax) { foreach ($showextcals as $val) { - $htmlname = dol_string_nospecial($val['name']); + $htmlname = md5($val['name']); $s.='' . "\n"; - $s.='
' . $val ['name'] . '  
'; + $s.='
' . $val ['name'] . '  
'; } } } From 8b5dd4910f22ea37718fe7bedd9b390e554a40ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 13:02:37 +0100 Subject: [PATCH 119/120] Fix bad update of denormalized field --- htdocs/projet/class/task.class.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index a9ecdd7bbc6..4c3e3995b03 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -586,7 +586,7 @@ class Task extends CommonObject if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut = ".$filteronprojstatus; $sql.= " ORDER BY p.ref, t.rang, t.dateo"; - //print $sql; + //print $sql;exit; dol_syslog(get_class($this)."::getTasksArray", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -759,6 +759,8 @@ class Task extends CommonObject { global $conf,$langs; + dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); + $ret = 0; // Check parameters @@ -790,8 +792,8 @@ class Task extends CommonObject $sql.= ", ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null"); $sql.= ")"; - dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if ($this->db->query($sql) ) + $resql=$this->db->query($sql); + if ($resql) { $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); $ret = $tasktime_id; @@ -800,21 +802,22 @@ class Task extends CommonObject { // Call trigger $result=$this->call_trigger('TASK_TIMESPENT_CREATE',$user); - if ($result < 0) { $this->db->rollback(); $ret=-1; } + if ($result < 0) { $ret=-1; } // End call triggers } } else { $this->error=$this->db->lasterror(); - $this->db->rollback(); $ret = -1; } if ($ret >= 0) { + // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective + '".price2num($this->timespent_duration)."'"; + //$sql.= " SET duration_effective = (".$this->db->ifsql('duration_effective IS NULL', 0, 'duration_effective').") + ".price2num($this->timespent_duration); + $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; if (isset($this->progress)) $sql.= ", progress = " . $this->progress; // Do not overwrite value if not provided $sql.= " WHERE rowid = ".$this->id; @@ -822,7 +825,6 @@ class Task extends CommonObject if (! $this->db->query($sql) ) { $this->error=$this->db->lasterror(); - $this->db->rollback(); $ret = -2; } @@ -834,12 +836,18 @@ class Task extends CommonObject if (! $this->db->query($sql) ) { $this->error=$this->db->lasterror(); - $this->db->rollback(); $ret = -2; } } - if ($ret >=0) $this->db->commit(); + if ($ret >=0) + { + $this->db->commit(); + } + else + { + $this->db->rollback(); + } return $ret; } From d7ab3f112c163f6cf17c1dc6e9e697e710a0ea5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 13:48:57 +0100 Subject: [PATCH 120/120] NEW: Show difference between timespent by everybody and time spent by user making timesheet into timesheet pages. NEW: Can enter start hours of task when creating timesheet --- htdocs/core/lib/project.lib.php | 66 +++++++++++++------ .../install/mysql/migration/3.7.0-3.8.0.sql | 4 ++ .../mysql/tables/llx_projet_task_time.sql | 5 +- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/projects.lang | 2 + htdocs/projet/activity/perday.php | 14 ++-- htdocs/projet/activity/pertime.php | 48 ++++++++++---- htdocs/projet/class/task.class.php | 13 +++- htdocs/projet/tasks/time.php | 41 +++++++++--- 9 files changed, 140 insertions(+), 54 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e4015812e62..e028c3cbbd8 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -177,15 +177,21 @@ function project_timesheet_prepare_head($mode) $h = 0; - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:''); - $head[$h][1] = $langs->trans("InputPerDay"); - $head[$h][2] = 'inputperday'; - $h++; + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERDAY)) + { + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:''); + $head[$h][1] = $langs->trans("InputPerDay"); + $head[$h][2] = 'inputperday'; + $h++; + } - $head[$h][0] = DOL_URL_ROOT."/projet/activity/pertime.php".($mode?'?mode='.$mode:''); - $head[$h][1] = $langs->trans("InputPerTime"); - $head[$h][2] = 'inputpertime'; - $h++; + if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) + { + $head[$h][0] = DOL_URL_ROOT."/projet/activity/pertime.php".($mode?'?mode='.$mode:''); + $head[$h][1] = $langs->trans("InputPerTime"); + $head[$h][2] = 'inputpertime'; + $h++; + } complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet'); @@ -524,20 +530,22 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$ // If we want all or we have a role on task, we show it if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) { - print "
\n"; - - // Project - print "\n"; + + // Project + print ""; // Ref print ''; @@ -564,8 +572,9 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$ print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); print ''; - // Time spent + // Time spent by everybody print '\n"; + // Time spent by user + print '\n"; + $disabledproject=1;$disabledtask=1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); @@ -592,11 +608,13 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$ } // Form to add new time - print ''; @@ -713,9 +731,9 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); print ''; - // Time spent - /* + // Time spent by everybody print '\n"; - */ + + // Time spent by user + print '\n"; $disabledproject=1;$disabledtask=1; //print "x".$lines[$i]->fk_project; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 4f3c802a9da..3233022d3f9 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -19,6 +19,10 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +UPDATE llx_projet_task_time SET task_datehour = task_date where task_datehour IS NULL; +ALTER TABLE llx_projet_task_time ADD COLUMN task_date_withhour integer DEFAULT 0 after task_datehour; + + ALTER TABLE llx_commande_fournisseur MODIFY COLUMN date_livraison datetime; -- Add id commandefourndet in llx_commande_fournisseur_dispatch to correct /fourn/commande/dispatch.php display when several times same product in supplier order diff --git a/htdocs/install/mysql/tables/llx_projet_task_time.sql b/htdocs/install/mysql/tables/llx_projet_task_time.sql index d5d89812b4a..d58b35146a7 100644 --- a/htdocs/install/mysql/tables/llx_projet_task_time.sql +++ b/htdocs/install/mysql/tables/llx_projet_task_time.sql @@ -20,8 +20,9 @@ create table llx_projet_task_time ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_task integer NOT NULL, - task_date date, -- only the day - task_datehour datetime, -- day + hour + task_date date, -- only the day + task_datehour datetime, -- day + hour + task_date_withhour integer DEFAULT 0; -- 0 by default, 1 if date was entered with start hour task_duration double, fk_user integer, thm double(24,8), diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ba7353b015d..be893d52569 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -220,6 +220,7 @@ Cards=Cards Card=Card Now=Now Date=Date +DateAndHour=Date and hour DateStart=Date start DateEnd=Date end DateCreation=Creation date diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 936e86ad692..53e7140be08 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -31,6 +31,8 @@ NoProject=No project defined or owned NbOpenTasks=Nb of opened tasks NbOfProjects=Nb of projects TimeSpent=Time spent +TimeSpentByYou=Time spent by you +TimeSpentByUser=Time spent by user TimesSpent=Time spent RefTask=Ref. task LabelTask=Label task diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 692267d6965..9ca8f95ac45 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -83,8 +83,10 @@ $taskstatic = new Task($db); $title=$langs->trans("TimeSpent"); if ($mine) $title=$langs->trans("MyTimeSpent"); +$usertoprocess=$user; + //$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) { @@ -94,8 +96,8 @@ if ($id) $onlyopened=1; // or -1 $tasksarray=$taskstatic->getTasksArray(0,0,($project->id?$project->id:$projectsListId),$socid,0,'',$onlyopened); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. -$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($user,0,($project->id?$project->id:$projectsListId),0); -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$user,($project->id?$project->id:$projectsListId),0); +$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess,0,($project->id?$project->id:$projectsListId),0); +$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$usertoprocess,($project->id?$project->id:$projectsListId),0); //var_dump($tasksarray); //var_dump($projectsrole); //var_dump($taskrole); @@ -184,7 +186,9 @@ print ''; print ''; print ''; print ''; -//print ''; +print ''; +if ($usertoprocess->id == $user->id) print ''; +else print ''; $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); @@ -204,7 +208,7 @@ if (count($tasksarray) > 0) projectLinesPerDay($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask); print ' - + diff --git a/htdocs/projet/activity/pertime.php b/htdocs/projet/activity/pertime.php index 9d277251772..9f2dc3e99ca 100644 --- a/htdocs/projet/activity/pertime.php +++ b/htdocs/projet/activity/pertime.php @@ -62,8 +62,8 @@ if ($action == 'addtime' && $user->rights->projet->creer) { if (intval($time) > 0) { - // Hours or minutes - if (preg_match("/([0-9]+)(hour|min)/",$key,$matches)) + // Hours or minutes of duration + if (preg_match("/([0-9]+)duration(hour|min)/",$key,$matches)) { $id = $matches[1]; if ($id > 0) @@ -86,15 +86,33 @@ if ($action == 'addtime' && $user->rights->projet->creer) $task->progress = GETPOST($key . 'progress', 'int'); $task->timespent_duration = $val; $task->timespent_fk_user = $user->id; - $task->timespent_date = dol_mktime(12,0,0,$_POST["{$key}month"],$_POST["{$key}day"],$_POST["{$key}year"]); - $task->addTimeSpent($user); + if (GETPOST($key."hour") != '' && GETPOST($key."hour") >= 0) // If hour was entered + { + $task->timespent_date = dol_mktime(GETPOST($key."hour"),GETPOST($key."min"),0,GETPOST($key."month"),GETPOST($key."day"),GETPOST($key."year")); + $task->timespent_withhour = 1; + } + else + { + $task->timespent_date = dol_mktime(12,0,0,GETPOST($key."month"),GETPOST($key."day"),GETPOST($key."year")); + } + + $result=$task->addTimeSpent($user); + if ($result < 0) + { + setEventMessages($task->error, $task->errors, 'errors'); + $error++; + break; + } } - setEventMessage($langs->trans("RecordSaved")); + if (! $error) + { + setEventMessage($langs->trans("RecordSaved")); - // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$projectid.($mode?'&mode='.$mode:'')); - exit; + // Redirect to avoid submit twice on back + header('Location: '.$_SERVER["PHP_SELF"].($projectid?'?id='.$projectid:'?').($mode?'&mode='.$mode:'')); + exit; + } } else { @@ -116,8 +134,9 @@ $taskstatic = new Task($db); $title=$langs->trans("TimeSpent"); if ($mine) $title=$langs->trans("MyTimeSpent"); -//$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project +$usertoprocess = $user; + +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) { @@ -127,8 +146,8 @@ if ($id) $onlyopened=1; // or -1 $tasksarray=$taskstatic->getTasksArray(0,0,($project->id?$project->id:$projectsListId),$socid,0,'',$onlyopened); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. -$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($user,0,($project->id?$project->id:$projectsListId),0); -$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$user,($project->id?$project->id:$projectsListId),0); +$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess,0,($project->id?$project->id:$projectsListId),0); +$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$usertoprocess,($project->id?$project->id:$projectsListId),0); //var_dump($tasksarray); //var_dump($projectsrole); //var_dump($taskrole); @@ -184,7 +203,10 @@ print ''; print ''; print ''; print ''; -print ''; +if ($usertoprocess->id == $user->id) print ''; +else print ''; +print ''; +print ''; print "\n"; // By default, we can edit only tasks we are assigned to diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 4c3e3995b03..f9e07ab6e9d 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -61,6 +61,7 @@ class Task extends CommonObject var $timespent_old_duration; var $timespent_date; var $timespent_datehour; // More accurate start date (same than timespent_date but includes hours, minutes and seconds) + var $timespent_withhour; // 1 = we entered also start hours for timesheet line var $timespent_fk_user; var $timespent_note; @@ -780,6 +781,7 @@ class Task extends CommonObject $sql.= "fk_task"; $sql.= ", task_date"; $sql.= ", task_datehour"; + $sql.= ", task_date_withhour"; $sql.= ", task_duration"; $sql.= ", fk_user"; $sql.= ", note"; @@ -787,6 +789,7 @@ class Task extends CommonObject $sql.= $this->id; $sql.= ", '".$this->db->idate($this->timespent_date)."'"; $sql.= ", '".$this->db->idate($this->timespent_datehour)."'"; + $sql.= ", ".(empty($this->timespent_withhour)?0:1); $sql.= ", ".$this->timespent_duration; $sql.= ", ".$this->timespent_fk_user; $sql.= ", ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null"); @@ -816,7 +819,6 @@ class Task extends CommonObject { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - //$sql.= " SET duration_effective = (".$this->db->ifsql('duration_effective IS NULL', 0, 'duration_effective').") + ".price2num($this->timespent_duration); $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; if (isset($this->progress)) $sql.= ", progress = " . $this->progress; // Do not overwrite value if not provided $sql.= " WHERE rowid = ".$this->id; @@ -906,6 +908,8 @@ class Task extends CommonObject $sql.= " t.rowid,"; $sql.= " t.fk_task,"; $sql.= " t.task_date,"; + $sql.= " t.task_datehour,"; + $sql.= " t.task_date_withhour,"; $sql.= " t.task_duration,"; $sql.= " t.fk_user,"; $sql.= " t.note"; @@ -922,7 +926,9 @@ class Task extends CommonObject $this->timespent_id = $obj->rowid; $this->id = $obj->fk_task; - $this->timespent_date = $obj->task_date; + $this->timespent_date = $this->db->jdate($obj->task_date); + $this->timespent_datehour = $this->db->jdate($obj->task_datehour); + $this->timespent_withhour = $obj->task_date_withhour; $this->timespent_duration = $obj->task_duration; $this->timespent_fk_user = $obj->fk_user; $this->timespent_note = $obj->note; @@ -961,6 +967,7 @@ class Task extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; $sql.= " task_date = '".$this->db->idate($this->timespent_date)."',"; $sql.= " task_datehour = '".$this->db->idate($this->timespent_datehour)."',"; + $sql.= " task_date_withhour = ".(empty($this->timespent_withhour)?0:1); $sql.= " task_duration = ".$this->timespent_duration.","; $sql.= " fk_user = ".$this->timespent_fk_user.","; $sql.= " note = ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null"); @@ -995,7 +1002,7 @@ class Task extends CommonObject $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective + '".$newDuration."'"; + $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 9951902ec5b..20ef1714164 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -87,7 +87,15 @@ if ($action == 'addtimespent' && $user->rights->projet->creer) $object->progress = GETPOST('progress', 'int'); $object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds $object->timespent_duration+= $_POST["timespent_durationmin"]*60; // We store duration in seconds - $object->timespent_date = dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); + if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered + { + $object->timespent_date = dol_mktime(GETPOST("timehour"),GETPOST("timemin"),0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); + $object->timespent_withhour = 1; + } + else + { + $object->timespent_date = dol_mktime(12,0,0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); + } $object->timespent_fk_user = $_POST["userid"]; $result=$object->addTimeSpent($user); if ($result >= 0) @@ -126,7 +134,15 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->cree $object->timespent_old_duration = $_POST["old_duration"]; $object->timespent_duration = $_POST["new_durationhour"]*60*60; // We store duration in seconds $object->timespent_duration+= $_POST["new_durationmin"]*60; // We store duration in seconds - $object->timespent_date = dol_mktime(12,0,0,$_POST["timelinemonth"],$_POST["timelineday"],$_POST["timelineyear"]); + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered + { + $object->timespent_date = dol_mktime(GETPOST("timelinehour"),GETPOST("timelinemin"),0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear")); + $object->timespent_withhour = 1; + } + else + { + $object->timespent_date = dol_mktime(12,0,0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear")); + } $object->timespent_fk_user = $_POST["userid_line"]; $result=$object->updateTimeSpent($user); @@ -341,7 +357,7 @@ if ($id > 0 || ! empty($ref)) /* - * Add time spent + * Form to add time spent */ if ($user->rights->projet->creer) { @@ -367,8 +383,9 @@ if ($id > 0 || ! empty($ref)) // Date print ''; // Contributor @@ -410,13 +427,13 @@ if ($id > 0 || ! empty($ref)) /* * List of time spent */ - $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; + $sql = "SELECT t.rowid, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note"; $sql.= ", u.lastname, u.firstname"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_task =".$object->id; $sql .= " AND t.fk_user = u.rowid"; - $sql .= " ORDER BY t.task_date DESC"; + $sql .= " ORDER BY t.task_date DESC, t.task_datehour DESC, t.rowid DESC"; $var=true; $resql = $db->query($sql); @@ -459,15 +476,18 @@ if ($id > 0 || ! empty($ref)) $var=!$var; print ""; + $date1=$db->jdate($task_time->task_date); + $date2=$db->jdate($task_time->task_datehour); + // Date - print ''; @@ -480,6 +500,7 @@ if ($id > 0 || ! empty($ref)) $contactsoftask[]=$task_time->fk_user; } if (count($contactsoftask)>0) { + print img_object('','user','class="hideonsmartphone"'); print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask); }else { print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime');
'.$langs->trans("Project").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").'
"; $projectstatic->id=$lines[$i]->fk_project; $projectstatic->ref=$lines[$i]->projectref; $projectstatic->public=$lines[$i]->public; $projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]; + + $taskstatic->id=$lines[$i]->id; + + print "
"; print $projectstatic->getNomUrl(1); print "'; - $taskstatic->id=$lines[$i]->id; $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); print $taskstatic->getNomUrl(1); print ''; + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user if ($lines[$i]->duration) { print ''; @@ -575,6 +584,13 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$ else print '--:--'; print "'; + $tmptimespent=$taskstatic->getSummaryOfTimeSpent(); + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); + else print '--:--'; + print "'; + print ''; $s=''; - $s.=$form->select_date('',$lines[$i]->id,0,0,2,"addtime",1,0,1,$disabledtask); - $s.='   '; - $s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text',0,1); + $s.=$form->select_date('',$lines[$i]->id,1,1,2,"addtime",1,0,1,$disabledtask); + print $s; + print ''; + //$s.='   '; + $s=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1); $s.=' '; print $s; print ''; + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user if ($lines[$i]->duration) { print ''; @@ -724,7 +742,13 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t } else print '--:--'; print "'; + $tmptimespent=$taskstatic->getSummaryOfTimeSpent(); + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); + else print '--:--'; + print "'.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").'
'.$langs->trans("Total").''.$langs->trans("Total").'
 
 
 
'.$langs->trans("LabelTask").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("NewTimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("DateAndHour").''.$langs->trans("Duration").'
'; - $newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); - print $form->select_date($newdate,'time','','','',"timespent_date"); + //$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); + $newdate=''; + print $form->select_date($newdate,'time',1,1,2,"timespent_date"); print '
'; + print ''; if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) { - print $form->select_date($db->jdate($task_time->task_date),'timeline','','','',"timespent_date"); + print $form->select_date($db->jdate($date2?$date2:$date1),'timeline',1,1,2,"timespent_date"); } else { - print dol_print_date($db->jdate($task_time->task_date),'day'); + print dol_print_date($date2?$date2:$date1,($task_time->task_date_withhour?'dayhour':'day')); } print '