From 60be0193b07d11348f01d45eb23aa0ab64494c44 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 26 Jan 2015 17:21:35 +0100 Subject: [PATCH 001/133] [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/133] [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/133] =?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/133] [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/133] [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/133] =?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/133] =?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/133] [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/133] [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/133] [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/133] [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/133] =?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/133] =?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/133] [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/133] [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/133] [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/133] =?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/133] =?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/133] =?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/133] [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/133] [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/133] =?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/133] [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/133] [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/133] [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/133] =?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/133] [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/133] =?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/133] [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/133] [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/133] 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/133] 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/133] [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/133] =?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/133] =?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/133] =?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 094/133] 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 095/133] 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 096/133] 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 097/133] 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 098/133] 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 099/133] 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 100/133] 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 101/133] 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 102/133] 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 103/133] 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 703a6c1b5489546469643abb5ce022c78651db11 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Thu, 5 Mar 2015 00:38:54 +0100 Subject: [PATCH 104/133] Update modFacture.class.php add fk_bank on bill export, this fields is needed to link with external accounting --- htdocs/core/modules/modFacture.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 86762fbb87c..7b070ae6340 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -235,10 +235,10 @@ class modFacture extends DolibarrModules $this->export_label[$r]='CustomersInvoicesAndPayments'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r]='bill'; $this->export_permission[$r]=array(array("facture","facture","export")); - $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber'); - //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number'); - $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number'); - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user'); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','p.fk_bank'=>'IdTransaction'); + //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number','p.fk_bank'=>'Number'); + $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number','p.fk_bank'=>'Number'); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment','p.fk_bank'=>'payment','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user'); $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them // Add extra fields $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture'"; From 39a7271f910b8de71003b8eee910069fd06f012d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 10:57:17 +0100 Subject: [PATCH 105/133] 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 106/133] 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 107/133] 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 108/133] 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 109/133] 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 110/133] 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'); From 22045603b744134fa4c75066b97ff1adca623d37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 13:51:29 +0100 Subject: [PATCH 111/133] Fix bad update of denormalized field --- htdocs/projet/class/task.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 017e2b782ec..b01a9644cb1 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -807,7 +807,7 @@ class Task extends CommonObject if ($ret >= 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = 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; @@ -980,7 +980,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); From 97f36825df1c626c642d7edc05730e521d7a4f6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 21:47:50 +0100 Subject: [PATCH 112/133] Work on new timesheet page --- htdocs/core/lib/project.lib.php | 16 ++++--- htdocs/projet/activity/perday.php | 69 ++++++++++++++++-------------- htdocs/projet/class/task.class.php | 13 +++++- 3 files changed, 58 insertions(+), 40 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e028c3cbbd8..f744508d9bf 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -555,10 +555,12 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$ for ($k = 0 ; $k < $level ; $k++) print "   "; $taskstatic->id=$lines[$i]->id; $taskstatic->ref=$lines[$i]->label; + $taskstatic->date_start=$lines[$i]->date_start; + $taskstatic->date_end=$lines[$i]->date_end; print $taskstatic->getNomUrl(0); - print "
"; - for ($k = 0 ; $k < $level ; $k++) print "   "; - print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); + //print "
"; + //for ($k = 0 ; $k < $level ; $k++) print "   "; + //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; // Planned Workload @@ -714,10 +716,12 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t for ($k = 0 ; $k < $level ; $k++) print "   "; $taskstatic->id=$lines[$i]->id; $taskstatic->ref=$lines[$i]->label; + $taskstatic->date_start=$lines[$i]->date_start; + $taskstatic->date_end=$lines[$i]->date_end; print $taskstatic->getNomUrl(0); - print "
"; - for ($k = 0 ; $k < $level ; $k++) print "   "; - print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); + //print "
"; + //for ($k = 0 ; $k < $level ; $k++) print "   "; + //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; // Planned Workload diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9ca8f95ac45..abec2e8cf7c 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -108,10 +108,45 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); -print '
'; +$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 ''; print ''; print ''; print ''; +print ''; +print ''; +print ''; $head=project_timesheet_prepare_head($mode); dol_fiche_head($head, 'inputperday', '', 0, 'task'); @@ -146,36 +181,6 @@ print "\n"; */ -$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.'
'; @@ -230,7 +235,7 @@ print ''; -print ''; +print ''; print ''; print ''."\n\n"; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index f9e07ab6e9d..c322e0be3cc 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -506,9 +506,18 @@ class Task extends CommonObject global $langs; $result=''; - $label=$langs->trans("ShowTask").': '.$this->ref.($this->label?' - '.$this->label:''); + $label = '' . $langs->trans("ShowTask") . ''; + if (! empty($this->ref)) + $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; + if (! empty($this->title)) + $label .= '
' . $langs->trans('LabelTask') . ': ' . $this->label; + if ($this->date_start || $this->date_end) + { + $label .= "
".get_date_range($this->date_start,$this->date_end,'',$langs,0); + } + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; - $lien = ''; + $lien = ' 46f56dc7dfff82250816df2bd2db313c 67798229e915f5841274ee70487feec4 -8d61cfa815ca3bb981582bcc7db0a6bd +e9fb1ad286fe67ee78fa8ce60a7be71c d41d8cd98f00b204e9800998ecf8427e @@ -19,7 +19,7 @@ 91885edae345ea489237442ebe3c8304 -706b9f915c400211b1c85c6ca6c11060 +6734d43389eded6e6ec04df0d0ac6a0c 4f72962320b42bab18deef783febd12b 6fe0eb8de0e5c45c09845bb8242fcb1c dacb01d46e370bb3bcc9574cd082f464 @@ -95,18 +95,18 @@ 68f0a32904f0ff877cb2c2820b38dc9b -083d2c1c63007a5a3487ec43bdd926d1 +00b0eb68f7ef07e9d614ae942f84e9a8 08194ccdf2c8801e9ce4acd3fc6a8829 -66a88729f0af41a466b40b1430f229f7 +422a9396b9040de1212afd253cc738aa 772b9a692d9998d6e7d8fd6e28ccb042 1f2562ebcb87267a49e9c8ec11f92d90 1e47fc4e62453875065109ef46259108 e8f85ee5f1ce535b1a6933f18ed09ba0 e047fd0ab0886550203c49269e7ad1ca 5f6244d1e0c7f706ccaed8c71240fc35 -4f7695bf300da817cbee7feffaa21508 +0b882db2159085006ffd37c772f7d8bf 10b05107d83798c17e2de027dfa923e6 fb72e6073af1b2f0763f9edfb4394d6c 942423fa65f36d20685e565e76434771 @@ -135,6 +135,7 @@ 90662aecd9eb51bf87b91f76d452381e 35b24d3c1592ad0e60c99c81a94be6b9 773f9a324037de24ba20edfa4f69099d +b791736af07760c81845b8fa160c6e39 858f4d351d6a865bccffef7fa262d99b 42b9d3d703feb637b4babe11190adb52 7f6bef974f62fb589b0c2d193750d714 @@ -142,7 +143,7 @@ 1ea47e3f2a830596d139ec65f559a508 2067170df6bc861d12d11a277986747a c1be7df4483ccc0e3b2ee08f977d911b -5f00bbdd645ef9bbf53ea25feeeac3f3 +15c0b5e011ee5e983f3f5c96db67d760 4489937620fe0ce4998a18b327a79cfa b447c8a39fa7d8217dfa5519af90e911 967aa7e79415181dfb2963777a90720d @@ -154,15 +155,15 @@ 41afb11aefb73a16398bd906a0201864 ef51c84433eab6197f43d0559f22fd4b -01cacadfbda4293ab21e779e06146085 +b2ee036efc506d6afd50dd7ac7ccc811 e79892f863bfba42a2658e43a2e8546b 978cfbff83d963db5c848161fc3ab286 69a64091740dccdfd8bd2f61df53fba3 dcce80148d3ea055836f7f38ab71f0c1 89a36b8dd5d33e53b92b491bc3edddfe 8b3806e68b169d4cd2c1320a5ab6fe8f -5abcc5736ddd1748f943313023e76de6 -937159f009bc845bd67dda6fc8c86b77 +3d6c42d646e2503f6a71b3618358f697 +46395deac9909d4a668bba6b94ee4c8a a08eb617d4122bc3972c2c04da32cb70 bf729609f42e090aed2a970401930e6d 2a6afbab650385179de02fe9205455d7 @@ -174,8 +175,8 @@ 2cf90126aba2b06f593f838a592ed66a 69be8c3d12533054535cbebb7d7efd07 0c89a620fdc2487c3cf242fa34acbfd6 -77a59143907052032b136e6883a0e1c2 -381ef356a676703edf225c3a56071002 +b3d4f333045789b87703c3c385194b0a +a5605b39b6125fc36ea7a6b083e30578 19e39ed2f2ac92ccec072d8d3d741104 0b3730d08a8d573f9195b07f58ccf09f 448ed84f8c692dae865030fdadfabb3e @@ -183,10 +184,10 @@ edcd9c936456f8945c9e05797b68a0c3 6ff462498bec936a81e4762d3fdbf31f 849d81f9f23ca9b07ea52367b4a666f5 -e549c764f41502093e349cd471306f3c +9af36af76afed9fe2efe0337be9ddf71 80f1b4396367b316403e0a81ae68c9ac cbafb5e0cfab93c9964b37d5c90b049c -f075b322db82ca5a1082e18033cea0f6 +c535a4a7b059b3963f5a5ddff9056faf a1ce81dd3436a5f87396dbc8213500d7 7b09d4f614806db46728a2fcf577f388 5343a79284c9127377a8827395d5b204 @@ -199,11 +200,11 @@ 0987559b12f37ae2490c1a5f5dd83076 32769f39902632408013c5860b088804 b3bf4266b0325db6ed8d9cd310cd2ef6 -a377699a88d8e920c8860ebb24aeacf2 -e62424215546778bde995edfa9692ca0 +4acbc9a5abb1a5d5afb9eaac8e18d34d +7e14eae5d5e6edcad2751240257a81f4 4bdf86d2111c1a361549dbb6523edb65 -105fea1b3cecab53fca1d10fde1a8823 -2887d01ae3349dff6c04d5902a5d6e5e +bc0db72496553e902eec64ef13a66b08 +8d97de9a3fac4e667f273bb41f920d93 6a605a7186f129ee54393898a6d9f4b0 5813003639fb8751dc574567dbf90989 114d8997f2920c105be850fc6ca8cdc1 @@ -253,7 +254,7 @@ 22cb27adf9a761ca0cb76e0e54b71890 3d9cc4ec66df38298e16365e009dfe66 26c66f78f5db62e9af07cb11280afc24 -368d57ca80f31c58192581ec7ca7f649 +9bba5c89e5dd034e4d6ddd1b19a8abd7 5c25310c78417e37fd75c8769e3c172f @@ -5349,64 +5350,108 @@ 3a316818411b5a80ef878dc5c8483950 -f4d6dda9a7e9a13fae9a0b5666a1af85 -26adcdd9610a48fcda8eddfd22fab072 -27f0f0c023d8775a7d970a0550caa3ef +3c06688411baa451d053f64eeccb1834 +bcb93bbeb8cf2831e49ff5541d277a1f +d306e9ad7b8b67464493c3281417afdc 6bb88a8a3d69511d1bf9e7af12ab5f47 -443543014f50021a6aab6e3dc45ed587 -a8231d248b1a221019ad16fdd605a9fd +2652ce7b4dcf00a1b07d8b1debedf867 +a1775d6ba3d8b76629dcdc2c1006048b +a874a391c41c223a007297af0fc82d71 0f6007361d5e4c8f34a2e83d402567b1 -b49ce165ab6bb7d90fd020bb3958ff1f -8ee3baf3211d960fc39e28c4e2a793c8 +a75033315ee90464410b47cc27ce9ff0 +bc1d75d2d4988d2ad9cac651bc44b8b3 +36cc4107f0d39d89b8031042c4159468 +8fd8e9a11cca513a4da0f25ff1a24149 +5af577705b43ce01285f2721a4850ac4 +2937220203e5a52762f5c9a4527e1988 +baadbf936466cfc106ae73e5f15dba89 +4fd59032d7c3a59fd45028bafa245721 191b3c2e856e750c06c0ba7987f902fb eb85dc872664c0769e9fab1b7540b4d5 -cc2cb448f60c5ecf61f6879aec325801 -d4836ebb5fa4e49eb36ba797c9f117e2 +17dfe118f580bc2a08e21e8104ef68eb +ad485022027867116de0bf6c25b1854a +5aeb1084e3a6ae5ef7ecc2bfc7a15592 +8702f5d6fbad08bf74378506ef376f83 +7596c070ac1bc839022e0a7aba2156ef +bcc98729a04598aecb86c451b91433ea +368af9ad30db4935e51b2109b9d4e9ca e0a7f23376f50de631db93814aff2e35 7ad3c70ef87d3657f918d3ee3649f31f -b2664e1ae97756c12114cb3371848ba2 +52b7639c5c4e35f33bb3c69cbfa0588d +a2a228f499608ddddeb2ba54834a5b7f c940b153fb6c5b3498efa181881b5b6c -fcc615d2a469180dd6a29ee6c04e866f -5a3660e46c91205c9203901c6b47cf8e +f9f9da534cce6a9124cc6b919329944b +287cb7bb6e6966708534cb9ed48d48ac +4775a411c20fe8fb13e9fb3a46629dc3 +9b2ce8f93949146d63dfef4d4784ad4c +18638db567f8b6fd7b1c6641ebf2c958 +463334491415afc3e56661e87196b4f8 +016527b52b6af2d6784fffeb23a2349b 2a315fa2593161154c319788f0ef2127 -544195d15ad41278307f99c79129ed72 -f163ef4cda9bb39f8abfcfcf2b683e0d +8b75ae7921f26b4f4b11d18ed921248e +7db990cc030127f1b64a4d3492f8f3e2 +afdcd64e0d7d78942401354d7f5f180d +51f6fe162641de3714866950d5eff4e8 +0a9d5e42c711a284436fa6f267e8ab85 +2c5e8a67d1a805aae9842bbad59a873f c22fdc8941f2956e0930b20105870468 +1f2386bedbebd633223278c1fd25109a +e0d060c7f70126e74c443b72ae560791 +20e28c8b386ddbb38ead777f717d7c44 96c6b586a6afb6d72dc8b93b30f844d5 -768d12956504372d4dcffea0f0bc2865 -39b329017c9d46eeb7f89f11e8540c96 -a01d7dccbd0a43d02a87035b60b5ca8c -8745faaac931fd3990eaad40b663a00d -82f254a1bc551aee1583bd6461b62cfe +351ce642d2008500c8780cce574acdb2 +fc1cb0e9030ce6b891319ce46dd8c434 +95bf00532c504c237041c4e3f04936a1 +bdf5ae55ea4d553beb785266dd0f9ffa +2894170c52a47ac02bf094bf047f1984 +fa8aa7a5c2077676637614809bc0ea0c +b8f1f393d7a247fdfe7668acf776e9d2 +35b71c6a8e678cdaa9d484ebab42c2ca +8f55434707b160cf1a8331d27e37e7e4 +4711cc4662b9136a881497c27b596135 +950310a6c12362b084a68b0cfa7f3373 +6ac17b4d7485fe73dd2d754ce2a0e2d9 +96fe7b1e5cd48c7332cf17b789f7af66 +02aac38356af65808e08e21f1ddd225d +bccc18d3b8c2b941ef7ef6602aab6c69 +de96058dc4fedbe4ccca03f9966ff743 3daad3713df02c15beebd09ceecacacd -0583253d3e49f14e3b6306fa788a6f66 -d0a111306e668d146a52e2299597888e -a722bf1cb509c0218c9b0d41386fdbbe +b8b582e30d3f3bd8867221dcc3dbf365 +75c68bb955477a99fc98600f5e1f40a3 +bf1c8fcdd3706774086cd133a6e04d45 +eee692f442eaec2b8291419a2017e50b +f9389202889738a0935be0d96f3aa609 +9b187fb3a908fb75b7b2a8573a4d13c4 c458a95a74915bb3e01102060bf3d27c -66a08a1e2a2405c7ad5affeca0f81b2f -4674617014723f062743145bd2952df7 +78fdf805f1cea6cd01912192821ec734 +34b9ef2cadf050ad58f391a7990c6975 +c0f60dd955a2bd3e6bace66eb362c9a5 +a5f3fbbef1831fe0bcd060edb6e5010b +c49883919b7912057b1ffad674a9c7c2 +99d8349acae8fcd95094364adf24dae2 +72b2fd6a41260897ef758436603d33a2 cacdbe68a428ae36151a3d1152b2b77b -1aa821a18b07bc7cba92552a372b8f9d -42f2f6e2122319a302b2769011897b2a -205fd4b7bc978688de8420087c161bcb +86c5b7ba9581a58bf6e465aea7d52e46 +3c4338d70de8c99a86b3ee15924172a1 +fb794db6e06fa3cf7479fc889894caf3 -0d24de61581243b069fb508efbc78a67 -561027d7adbd2358225866cba60568d2 +3abe66ba8da6b6bf9cf1c6b0e907d51d +9a29da1e201fb23de4f499adbb9f6a71 edd56d70cac390ef63feeef7e9d71b3f -75837274a0d67e19ee975aaef9e283ee +5f4ae32bd59400b8f788ac644b693ed2 8f83bbc144d70505672f82679546c72d -5c546b7f37191a754b6743a640c6a0cd +809d819fe86dc60509c0b39997fc0d4f 17bfd10e3232de9145f5b74a6ef6afac -bd2d14a110664154fc509e3d3f9421dd +67b77209f88a051d1a7dd39e6584212b b162a10416c2cba0be1ba5d979e19145 @@ -5756,8 +5801,13 @@ 93d0209adac1b1a2b4e3cf2173cf995a 20e95e9c16378e6ac4df49011220f904 + +778ee87bf2f490b2737b2575d6a8367d +36e0aff3d3354e60d6470d44c07d1760 +c6f393b8430b95f521554b427d675a68 + -4ad543978a9d6664dccfe0e58b428c5f +d2a5b87e5832c708a67b8718e6cb89bd 6bff9cf68d35e1f83c670731e270c91c f6b62af680035531c943bb9fe3f416a1 725a7d1d35aaa7deb29d8d7b68d5a7f9 @@ -5802,7 +5852,7 @@ 758456bd92e4f81e1fdff423d4f914ab -f80e903b3aef314dc7e173ba95324c56 +fc8213a4a5a98ee458ddacc6bdd363c4 edc900f68ee6af819ace6dc30b968d80 @@ -5814,7 +5864,7 @@ 69caa949b7e0f3137c6ce7482f38e0f8 -c234c6e7b71d97e977d881538fab1d5e +a040ae2fc7273f1761c0b6294465db86 a0fa0788291ee95ccb306b8aded3fce3 @@ -5837,7 +5887,7 @@ ac2861b424e2b7e30a532f37b33d6889 97bfaff0b5c453d074f05fef1fc4c3df 35433c33dbc3525adc99ba89816d3733 -45b742c58510d055adee01e93aa33ff3 +4aad58f34304117925aeb72dde0e16ec d41d8cd98f00b204e9800998ecf8427e @@ -5931,32 +5981,34 @@ af876c926d49c59376d8b6d642ce9f66 -b30fb8f9811c1fa4d96fb35456366a8d +2ba22b10ce887c66563fb062cab1d79c 5fa21d6616fd146640d8cb59d52fd6d2 -0425a56b168d7f707d31028ad6122c26 +62e1ab1273d5a8dba9003cf14e678f94 9f9e7fb20c0cfc32dd7879ea99bcb3a0 -fedfac2139ca74edbddaba770b52995e +9b6ecbb4d4ec11fe513ec2a724749201 d41d8cd98f00b204e9800998ecf8427e 5c09b3d75fcba736c3353468236e5338 688c47e56752db341e110657c4f6f4de -d6d72917df770c5f42763d5bafd71857 +6f0972a6d7681bb65406b323efa8c202 0a81d81144952f49baecb31cfc610fee -453d482e2c6217d080e4ba4ac382aff7 +85a44971ad662216ae35ee13cc448517 +3cfe3654b3fc16954d91d3968fe71e24 d41d8cd98f00b204e9800998ecf8427e -46ff31a1787666ae78665dcea6351800 +e4a89a0342afbc8771e9178a78677517 +0e38e1224840ed30469ccfc96cae5407 2e7c67c1f808b58e33a5d256c282f02f d41d8cd98f00b204e9800998ecf8427e -33d557efbd941e679c386377e63d949b +17cd44fc331db26f8a7eb438b6f83cd3 e122c4a3c7fd8e1814f52d447e2d1a87 @@ -5965,8 +6017,8 @@ 0ea32bda75dc7855fd061f23d129c35c -de6be0f3faeef94e762c4e1ea1def02d -f38b902b5ce63c83e6dc6ffe2f9cf0bb +c5afccdb1da5846e310db9f174201302 +ad942ced24fef3b0b541041a3ce20205 25b3ce6e2f12f227c4a1ac8db9fab357 @@ -5986,6 +6038,24 @@ d25255649d1fb417a7e7041ed86dc8c9 23a9fe711137f3cb4f06dd011d38c23b + +d41d8cd98f00b204e9800998ecf8427e +93f6a40587eabe04d03bd3e910a780c3 + + +9b2c6de73503cceb102e875a364f6626 +6c5d484bdf6d9ef4529adc17eb829766 +65e54e9e6458c353a92eeaafdb0d0022 + + +d41d8cd98f00b204e9800998ecf8427e +cff8400cdba7775f87330b11ec9a4a65 + + +8a6845f5a3f6180df651c1be45e24878 +bebba22e7a5fdb20a52dfcf1b64772a1 +477b247136b3b54b251d5257ed61ee19 + d41d8cd98f00b204e9800998ecf8427e 0ac7cc84f48f255d71c0be34442038c1 @@ -6000,7 +6070,7 @@ d41d8cd98f00b204e9800998ecf8427e 7d845e5c3c1ac2c7b1c49de0d7e1c7e9 -8d01e83c7ea6584ed8244fe84628bd7b +241877437e8750febbd662602dd0efcd abefa8f7d035ae87eb5b45b0c43843be @@ -6014,16 +6084,16 @@ a7a90ee73e8f7f25267dc0ed66b3d8aa -a7f47e13476c054174040b29f993c271 +c541711e1f2070a1cc8528e9991d7fed -3cf2e98145b2f736130d75ebce1998f2 +fb4334120f1d5c30e64da6c12d2c777f d41d8cd98f00b204e9800998ecf8427e 1d09e4bcc7c8b15b8870ee521b50f1f6 f94fa580d25989d4f7a0729699c794f4 -dcd7588470066bf274c070ea79bf0b3c +bdb60ef8622cea7e270534ffb78c9714 d41d8cd98f00b204e9800998ecf8427e @@ -6037,7 +6107,7 @@ d41d8cd98f00b204e9800998ecf8427e -c5b4ae74b2b2e938d18d6f91ae094157 +4cc2f72a3e23dd082248e7e1582b9cb1 502547de717912a19aca06ddd223995c 4c457d8c88e79b1bab6c830a9162e718 2395be35cede1fb715ef9a4e497300a0 @@ -6075,12 +6145,12 @@ d41d8cd98f00b204e9800998ecf8427e -8c73a6f5b6e511bc183fcf2b5c1f8783 +ff07e29c887a25d0261857b7bc9e1deb d41d8cd98f00b204e9800998ecf8427e 63a86b61d1158210eedd7055b3bfd935 -d9f10175f29b8f142255f95be2d07965 +dd4877a4d2778561d4ccdbdba4b8b76d 648275f02e4c1be714897110a9aae56c @@ -6097,9 +6167,9 @@ 2a452e950585fb39d94e41a414471df5 -4703a36c950de669ee918e763e014fe1 +4dfd0119f671aa86ba1405c9814b08b0 977109b651acad563d27a9f05efa820a -f0bd1599b002694c6ec351d6606921f4 +3fa0561c00883f627c54f080237ca03d d41d8cd98f00b204e9800998ecf8427e @@ -6112,9 +6182,9 @@ d41d8cd98f00b204e9800998ecf8427e 3e8b72640f3dd0117bde24b366b7a8f5 6a1a6da93f9c2d77d68c8edb90139899 -3285c87826c9621ebf4352cf2a3ee2a0 -8a1c4f997f37fb274bc58c905649c0e0 -2211e75d50ae16f94e147f2f05a85d91 +6f6227ce98c203851dcddd1f027a86d5 +4ae815a0b31e0c4b8b900b7da88ab8c1 +1806b43471d2254c540ce3ab52353877 d6e07b8cab924d1b1b4e7b467aad3e67 80c65c798aad65e52c21289ba4fc8db2 @@ -6152,29 +6222,29 @@ 926bd78111e0f27f638bb0705f92439b -8e16469fd236e9975f6a14a9e59c147c +7a998e3b11f1086c7953293442f3530a 37d695c0d624c79d4d5fa14dd131876e -040fcead42553050d648d53d01d642b6 +01ec301f4005d3565727c01ea5b63eb5 58e190fe5c72ba2cd4db99fd17aac7ac -212fcab202e934b30e6fcc7c5128ed3d -6a692cc606a48741b08fef765bdaec4c +a0668dc98834af718fd96f310c7f6003 +56db30e1de65b6fb81931cd4469be39b d41d8cd98f00b204e9800998ecf8427e 3d18b6afcda65c40d3e5b1565e0ae3f1 -0cde765c7d578d103c71dfc4197438c8 +091c302f41e52a36598a19df1860971f 4bac12077505462bd962adb666852966 -3ce4735205d14eef357f1fc90d655ece +22a2ab52185732bcafd64fbd4a68eea8 cc7d7a963ee9ef58ede0680241f53de1 ebb2e597917e22900853dfa300de88da d41d8cd98f00b204e9800998ecf8427e -5b69636b3ce9773a65a8750f65d31ee9 +2c6f884e37b89f861f19faba99009ecb 32df7d91f327cfdcd67d831f6e7535eb @@ -6297,10 +6367,11 @@ 1fce4641b42b1c6680093428f2ccada5 -f4306fe54c33047d10182d177f39b89f +255c511cf57d5c863564fd3ec0bae654 d41d8cd98f00b204e9800998ecf8427e 957b9030b18c319e7c1529a4ffc72b85 6b6851714ab5e4f9491c2500a26c8ceb +29dbab62db9356e1b3574520bf3fa8b6 6dee88d0cf667f9b940d2696690f6744 @@ -6314,24 +6385,27 @@ 5ef3117292cb272cb72190d67bda189d -25d6c35728da1df381db408e61137d98 +9e42ef4e51c3d0795c44215d8264acc4 ff890ffae74d79a90ade34016ffd241d 1e1d68cabdaa8e946ad786f083a114a1 080945adaf8304688ce778f8acc821fe a2546e7613e0c76e1c26692507f66836 8cc4b11d20b0e01eb7e7b7401c2f12c8 -190087a51700f34c1b861261d838a6cf +10740fb22bfc2ac1b339e9d784cb9c23 6cea8bdd89a385b695dda1279e3021fa -e48ba3cc3d7d8641f31fb4d1e1cce67a -fbe31176a2ece8671e34270b56ed9224 -cf7fe720eedb6cef5c6cb67feb5a31ea +c41cd25f077b172e0acff8f4e6830847 +ae990e59fea5de5b4483ff48d541723f +bd68e17f01cde910409d40075ec640bf 4aeaafb21fcc66d532de0612676423e5 b7c3b27785924f5b023754855bbe3177 -526b1578733967a53e9c7ea0d3687334 +537bb9602db6a018f9e12b2286bd26e6 9e2d3bb695cfcdfebe705c171aa299ec -d7f98378b22bf02d1e96caa8c354a518 +02e18a866ed73982a37672572da83321 60d139c55b1533b31a8fcd4150ac35ed -d02f3b80bd620e44b248b763a745c555 +cd235b4afb8a95d5975434d7526fd7d3 + + +a4a1f69d36f0c22e9eb2767ea3f0adbd d41d8cd98f00b204e9800998ecf8427e @@ -6341,11 +6415,11 @@ 6534c21938d98c00bad6449081c65979 42a382d9a7146ddbf4c31c3aa55d6623 7a69303716cb7dff3ae011d2202de8f8 -8c209ae5445bf45531c133034a243439 +9b9fe5839d3b4cdf2bd5bd8faae1206b b4987de205c69745a11bb3ca910cf99f -b9ef591e526bb7585e2e9e7224d9ce66 +61d3ec9976c54d1a116baee6582b4d8c 3beda9cd6565bab822fd85e21efcf733 @@ -6378,21 +6452,21 @@ 6648383dfcecce0fa8010ee26e19c029 10d80a81dab8b4b36bc477b7d06b2c89 d41d8cd98f00b204e9800998ecf8427e -bd966e5b800b4d63bc3884eb6c4dc944 +4c2e051a6a49ecd0ff1f82fe3c63118c f0e5ef9a4d74a8c802f1b67415f319a1 d67feaff91ea41dbdb614dce38ba542f 6a42f85c4852916c71548c179234aeef 0db78f95e23062feab46593d28704532 639d7ee6567e210b36ecae473c5ce5fd -14dcc1c1453ec2180a3bdc0cc53fc18d +f772672fe0aeee71dd5c6bfd8d14808e 2de8820df5ad2c53044c62ff4ad718b9 454ff3948173d81e3f0c7ac1b77fc91a 98b51504f52bc57c9d900d0fc1bdb4ab -84fca517a57320901e6f4d09aee570e5 -47fdbddb0716950e3754211aa67c8c43 +620414a7322b7ecf17e2644a9a3f80cb +9a92997f7f8d84b6ef1685765babe1e5 f01a62497c9a085386bdc7c1defae763 ea8f7edcca4e35f95a3f2b7eed940d90 -66809106d19298be518b4f947dc0f323 +7f6a63a8afc26cee7c61918fd7559f77 a14866ebe77e5755d7b9772210696e42 b28954162df69981caec0998d15b77cc 447cb865dedd025c82a0402a41d2253e @@ -6400,29 +6474,30 @@ 7b53b4073832d6097d69bdf50ccf5ba2 1b0a44d142ae00530558bf5a6562492d 6cbfa567b0f4153bbc7f74adfe6bb4d2 -b6f90f0325529e3a39ebe651d0f910e7 +efa61e935b3bddded6bf488f1c27109f 88379d7c5cf4379d141f0e277fc2d499 3c36fca38f15327101e2cc37493e60fa c3d1e1b3f31c8bc2c6ac7582205a85ab 2c4b8a901ebd2581714ea5b7db8ffd1b daff44759e4f9c193a667ed427ba5444 -29b823646e763c2e7a64098be3ba5130 +dd505607a04547e95b76e3821ae75568 +666a30d3eb073d969dae5b1f73fa7d2e f4d35924864fb87b787ab9a9925fb091 2cf0c82aa4ed8fa0e22c393b7f5ecee4 2cb5c8f2cf03c6df6d3b70394b454d1e c65c84d23e2a8ad950ca58a1a2ca90db 73aae48b832026e3d24c305f58743806 e7df06c253dee16873fac26b32670722 -d4ce19166b58327ea8fe72de57a8dd85 +0bb1fb4ad3250cc312d571055323db79 507d7fd927984729187a4891f616f37c ed773b5b64093d6017aecdf1ca79fef5 4b15299e9a1c837d8e32aafe9abb00d7 b418b86d6c9003364c5a060946082ccb 16f583734d76081ef1a4b44d1e0657a6 -4dd69e598e667405299c866a9277af26 -e07da2dad2151513bd8dcbfe29d43e3c +dcff719e866b3af9fd9555b5a5867d64 +e72a74aa70d48feb14c3a5fde6089fcc a239faf6b54526481abaffe15d1f594d -4b9010ae3ecbf6e792d3bfb687ea2ab7 +e28bd469ef1c049843bc41dbe0f84d66 fe33e132e503f32398fb9809fe51da85 4b85147a9ebfcb923038a17487822286 e639d0ea5fc52734d43abbba8262dbb0 @@ -6436,7 +6511,7 @@ d41d8cd98f00b204e9800998ecf8427e 80f54c48fa46d0aaa977e404035aadf5 febda7bf2f326668d1f627ea9f2230b1 -4e6602a9b00bab8fd936f4800a1014ec +4f695f9327d6b2361640731a09e99a33 fe8c6f4acebea37d34b626a537db0e29 90ffdb58422df4e942a1a90cf5225c11 f1a8c3f9d6af74c305810725f125691f @@ -6460,8 +6535,8 @@ 38da2f7fcc1f2fe80b87db53e8767282 51e003dd68580f4f37558726f8452b53 748938e5e5aadef1aef9a8b79362b1bc -e4a93615651fab4af7d9288cdcecc86e -6d73868eae09dc15710f4c71ea25d7a0 +0de6fae1b00ab6cd538ffeef40f045be +00de18319f0abfb4c50f76b60f3fa2e7 6b58f5c0cad8d233b94b0874a41e4c7d 9596a02e5898fe117ac4d2f080a1b3bf afee7ccb55d1420cc8e36da4657825d1 @@ -6469,7 +6544,7 @@ d2b5ecf5e328a75e984f342ec80a60e2 07e043e1c42a0fe90d2226eaacb013e2 4cd01a2e1b1d02f7bfaff7792fb45da9 -f12d4e2a7b8866e08c4635b6776c1b02 +81a2f4c5a6b5946b088aabf7f5e9404e ce24eb153015acfdeca2e5559cc41583 a969dd13ed2ab6f921564ecd22121515 c2ced639d9b476d69e952e110169346b @@ -6477,22 +6552,23 @@ 3e30f76aaabd46ad9759658b706af3f8 4d7e3a9cca8144dca5f184f23e63953a 60c540c4dfb653ef65e67a628645f590 -abb811eb8d79dbeb78f5e67711905618 -1653a3d486b7113e331b01813407091a +3c3312f639641a1e2f7d5eab79209b7f +604bdd7909398dc5d136d47f9fc4bf39 98ca2d412c720690b46b8bf566cf4fb5 a9d45ffd6281800146fcfb2e3ab90ab6 66b21a3ea2de0ae271e470c339c40d07 9bfcd5451fd684e35ed69b3912791a6c b416db3eacff1ad448692d14aadff327 -b37a46d1de1e9b957b33881225da36dd +c8f2877e5e9d05fde24a7c7059c145ed b0bd3479b483ba56d613a91242e0efdb 0bbc469b628cbc940ebdd59f2e218b6c e1ed3c24b7fa01be0254d5e6393237e5 0e5a8ff24a2f4bb98d5c6c732e57619a 811dbf5341b537fccdf98ff790cda72c d868ca6c92ed42be6d193a71b5ae5a7d -11709bdc16ba921e8fe3774a1c7aba5f +d3361d904c96677405ad3081d4bbfc4f 503104f81619bf8296bdd1893079765f +595325924223d40b0ea97c9df4ebfde4 aa7ebaddf8d815b3dfd1b3281f26de84 59519c8b2bd240bdfc50476ea344cf8a f68235c447fde10de92e0732d17258bd @@ -6502,7 +6578,7 @@ 3cfbb9ef9c493bf739d501114cbe798c 0d3a43a7afc190f34f52855f28a34e4f 48f9b2c134655de1b0f5f7d50f01b765 -b3c941e7ae9574a1330c98ce07aade9f +03f439fdc6137b29736006bd4bee8ec5 70c6fc7d08f3c562322c9f53273f1393 @@ -6547,7 +6623,7 @@ 8c78f30a301fd7c5092ed59d95f2f688 -db4b88a7cb7f2e983e9349a0564aa877 +841ebb62c8967f82132d6c19e372bdff f8bfc1daca01458dceb9aebc7ffb5ddf @@ -6578,10 +6654,12 @@ 79a20f938fb5d3f145447ae44db05477 f2a1930d9be82084b365ccc8819d8484 d41d8cd98f00b204e9800998ecf8427e +5468ba4d16d0e057cf45f0984a79ac2e 1de24508893015db0757ec63e74a8086 2ae8b7de36d0e4c3630977569bf93bd6 -7af81ecb2106b1ca78c310332a02c604 +050cbe3b9406a05a76f6a8d1c2fed6e6 2b19c3592fbed5e4bd96730f87af438c +69bb08052b60d7d59cbe0e6ff0e45089 de943e7a2b8a603c3ebc34507309a46d @@ -6603,7 +6681,7 @@ d41d8cd98f00b204e9800998ecf8427e 4553664f3a8bd058468c8fe3a6622db9 -86a595136563ba16d9b4fbb1cb97415c +7ffccecde85645232cd150f4ceb54f8d f0e4f84ac2849eef8c8da252f2a875fd fdc9f14617e70aba304986ff7e32811e @@ -6692,7 +6770,7 @@ 347df504c0b23da0ae91c9b5a344c1a2 d41d8cd98f00b204e9800998ecf8427e 9b301131818ad7072d10624d9fce65b8 -215929b6545fc8cfacbb7386e4cbedca +fd0799a717f127a9c48bcb11d33a4d72 d41d8cd98f00b204e9800998ecf8427e @@ -6717,7 +6795,7 @@ 80af429597316aca3852de474a686ff4 -391c970a033d0593a16fb904119818d7 +5a89df7d532fb5730ba5fa40e3fb4037 d41d8cd98f00b204e9800998ecf8427e @@ -6728,12 +6806,12 @@ 35063f32bb86ee8cd1460cc9b50460ba cc44ae6151419f24f801a399a8da8e9a -577a5a6dd151bcd7cf6d8fcbd70677e8 +1a4b02d31eef47e71fb394b5688cd663 d41d8cd98f00b204e9800998ecf8427e 6b8b8ce50599e40cb74603a883f5d49b -b6e05cae93872a350f3ca2352f15f6ea +2cce9a1d8bf4c822dda113e210bc4f6b d41d8cd98f00b204e9800998ecf8427e @@ -6764,11 +6842,11 @@ d41d8cd98f00b204e9800998ecf8427e -70b0380559e50123f150a6f30a4d6699 +be907e7e9b0ac5a24a34af01ec1c21a6 d41d8cd98f00b204e9800998ecf8427e -04876764536d2c0ff37e0f1c9035c639 +a64def4ba4a8a55272108f79d0667e39 3621a212806836a2b3ca23f601c1b670 b3f46a3f7cc553bcda255db88fd2309a @@ -6777,6 +6855,19 @@ 6bb3fb472a3ff31f31945a68bb806cde 29977b078710f6ebe992f5b534b7d897 e1efd5d8bc348da70c325a08fc8c37a8 + + +d175d0af5c450eb501bca361a275c309 +d41d8cd98f00b204e9800998ecf8427e +13e7a0e137341f5a38764ea645b425f8 + + +d41d8cd98f00b204e9800998ecf8427e +e4239be8b90a077f8afc116e683151c9 +751806f248816fea7429cc7c4132539b +ebf0a4412227a0b61ae52df0105d46fe + + 610022638254b2075ec4bba535c5fe37 @@ -6819,10 +6910,10 @@ d41d8cd98f00b204e9800998ecf8427e -6a04d0a55d694688b7a8e43c72f63891 +9f8ec55a2df1f58b2ebd299fae8a1c6d -5ba605e1b76e515803012ab67abe2e4a +bcc3831429d49ff3a32c645c64be2e0e 0276bf6040d05e80ab5f6c6910f6ddfc @@ -6837,10 +6928,10 @@ bea23817aaf13e638fc0e6d274b0a63f d41d8cd98f00b204e9800998ecf8427e 2f133b07231a558b4551cfe813b6dd92 -c304ed5cba54aec736b4550b472a1337 +ccba00148532ae0e30f6f1d082817c10 -36473125e09319a9870285bf7302b83e +83bd77075a70f4b3a661fb57a0f0212f d41d8cd98f00b204e9800998ecf8427e db3734d67e45bf4a5140fbb38effa947 @@ -6861,28 +6952,28 @@ d41d8cd98f00b204e9800998ecf8427e -bd77bec5b425c9fbc1a4830a3ccccaa6 +6be749cfe859aafce02b030d57362ad7 -60d1a2024e5d8c9d6cdc0c295a243652 +898b153724a1748b8ea360e0b94aba77 d41d8cd98f00b204e9800998ecf8427e d07b23771a6639fd5f6216da796ff343 -290e1eed5e28283e741bea66c30ec042 +b1328a661909e538f58d43197eac2a40 5cba7b9316b591829c756097ae0485cb d41d8cd98f00b204e9800998ecf8427e 1f669f066fd46b6c9ca05177e177ed23 -bef21989e641a45d0f362fcb97281341 +3c270b13f4a5b576799d30edf1b7061c 00b8f993b58e8278a8115fb82ba7db57 32cfbcb58d6ae71455e0c58f951f2849 -bbdf49461b8f7bfda4446af93641d362 +69db05aac79ae05729e3797abcc2f1d1 710958b3055ce271a53ebd4e6325eee4 @@ -6893,13 +6984,13 @@ d41d8cd98f00b204e9800998ecf8427e 4dfcdf4d3cb3af826834c1fbb852f513 -9ee40eca1f3111186855090e11978198 +08bd77ccf4ecfd2cccf23e9925909375 d787be1614e93a5b0dff651c2d1962b8 d41d8cd98f00b204e9800998ecf8427e fc2cd8f1b832bcd093d8f65cf48d6be1 -94d4a670a65a20356db9e332884b5b3e +eea69eebcbf32860db846f30a803b9e5 05afeb97327056d436d21d891b041057 @@ -6937,6 +7028,7 @@ e1e875671e566acb90ca03d16b7e63ed be1a34c1c77c5431dfcee9caaabcfd88 f71705be8958fd18f828eb64eb254202 +3be7925340a260d3ffccc912ede415b5 36602e78494c46c4704cc578d4fb90cd d0889baa672fc0c803bf11ba7f57f6b1 @@ -6956,7 +7048,7 @@ 1a47a847fe417086b3f0b8d467d35d1b b69b43bab30c28687680635f91a53017 311aab84570c363ed4ff7e5069f5d949 -fa7542a63fa8d175b25c6db3d460d8a2 +3f0df7430bd8ed69801318a62221f4b6 6ce7b2cb223fead83bb4294741e580e2 @@ -7001,8 +7093,8 @@ 6a4676f26cc4774608c53cd47ae76efa -5cdd42491af381a414bea885fb5c234a -8df084360e41bb5dcce4719ba16c4804 +3273ff24d482f29e015604a5a5190712 +6b13618c39c1ae78d6be5a9580a25daf a90e349b1dfda275772af8b109e8be6f @@ -7024,7 +7116,7 @@ d41d8cd98f00b204e9800998ecf8427e 86b05756ec73691d2b88e25bbce1e86a b123826d90b2ffa257bd9880c090a6ac -f454a5cbdd36bfd22d6240b85e503e3d +30a766af9cb25ef9be5c36d4823109f3 59d8e23aebde2396d3440271828f4e20 @@ -7068,7 +7160,7 @@ 1921a40ef2e203a9c7e33e33d8481630 -84c13b91d89d2ca2851e10c25a0cd166 +3bd4ca8f6d546fed7f45d59930fab106 3afe82801f5cd602354186397efe9210 @@ -7080,14 +7172,14 @@ 7d040a1858a6f1e8b3d8e7fc68b1b008 -2d1bc07a8c28954534f37204c02c33f5 +4515ffcb074f47a2d9a4af2766b074cb a267dd6d9a787dbaa95ee81e9812a81a d41d8cd98f00b204e9800998ecf8427e 90bc49dfe52d6be339781906352ddbdb b3586b44a75323dbf02f85aea44e25db -e4d79c5376e95d08abe328aefaee064f +d5cde2d518971a3d6bd1e682b7c42092 1699071ff4bb09210ac267d430c05352 @@ -7095,6 +7187,42 @@ 202fffca61e528efe134dd32a3a44c64 9db7bfe5fec55a085d9f0dec8717479c + +83e824012a7c92746e71afc022ecb636 + + +18df2d1590e825952abeb40304a9597a + + +596d7781222e476b027a59499fa2d92a +ffae59f2cf83f882b269e06e420602c3 +7dd46b8a806a7567c0a88a13fa4f905b + + +9b9b0157749548ed0fa38782aca9b1e1 +296f4be076bb584ea5779e3059648a53 + + +1b2ed3db48be32e106a6dd6351f324be +b1688c8a3bd5948865884f0eaf3a0251 + + +99bd91055f47d5a74f9c395d74fbab6c + + +74d1739c0d14cabc655cde37e2fb25a8 + + +81d6b2b51a9b495e2512ab0952fb3afa + + +3542838ab2e1d4ec2cdd98db328a247d +3645cf8b754a2925eb02025881aa3ffb + + +fd8e048c8923d556fd7ae7c5234ad474 +b9dce9a8342b0e0d203581e86770d28d + d9cb53a9d7329a35ccba6560d05ca39c @@ -7118,8 +7246,8 @@ 3b3a6cb8fed3de208bc9a97209fed209 -c4b52ea2075814429b8a00a486f74baf -3229eae002e5525f9b545644256aede8 +a42209411960f30b6b6e5e38bc560af4 +7855abdb54739fae3eb0ae1d5a18ecb2 583594a72118966d0ce436acbf5ab344 @@ -7132,10 +7260,10 @@ 1aaa761fff1db6880a873b2f7aba4769 -73b7987dbc53760d356ad398d8f31a6b +96ee353361cdd805d62109efa227f63d ffcd5053589c705062adeade31ce92f6 68dc3ea2cd9c6508a925df50fa011221 -95444b95d6bfbb4cc05bddb1fd2d430b +694616680b479a5a29cc4bcf08d2b0a9 deac83a4c0eda829eedb0f9136a1fae5 @@ -7204,9 +7332,8 @@ bda3f6f14b6ef2f298a116a9e5e4de47 d41d8cd98f00b204e9800998ecf8427e -14cf870bc89190b003d4b67d08399a82 9b4cf41fd9e3065e1849aff895a0999d -b9866ad3e2a12514c3062cf74a711f6e +b34de60c5a1ca8b6e1e0d1c614022e80 3b29a33fb5f50c27d39d0645b1d1d96b @@ -7221,50 +7348,51 @@ d41d8cd98f00b204e9800998ecf8427e -87a15a164f064663c4d567a67b877a14 +282d8a4bd07329456966b4a7a359ddc5 d41d8cd98f00b204e9800998ecf8427e -51b4e94e74766a82470e5ff6c5753cea +c0b5fb2dce5b0a621a8653d6db38785c 3d863d079d9ebd0a4d6450acbed047f3 -68ef70376e6452b0db41d188de3e7309 +2ff2dde238be1c2c76ff373412a78e9e d41d8cd98f00b204e9800998ecf8427e -583e353c57d884970f1753605d7ab749 +ec17764560eab22337e40b09dab7fa84 bc584ec274c28d5fd6bc06909523cb8d -447dafbb6d90617a37c7f8e9038d2d45 -5d709c9a142b17a1cd1439197ac62ff2 +db597412bbafac95b4df7c52007804d3 +0950ed07fcf3abc1d21340fcc9d51be9 +138f3da6669669416a9600e7bcf485ec -e01dc79eab31ca899f8bd155d989482e -9946885ee4e9044e9a3fab8e6bf4f0c1 -8574e2c0ea7292d815892d241b029a73 +bdabc11685cbe7bcd760143cc3431e3f +4b52f2ecd9144b4fc8cf9484c23157af +b0599b42b4a17c1d140801a1b2dbfcc1 0529ddc77e8c681c33c47b9b7687e810 faa2eda13c5607ace72e34e9c0966a0c b704dae630c7215138b1f90caf77b450 -285e61a9ffd5231adede10df1871ab5d -714867efd7c071524ee3b0b4667a3ddd -9477e6a93b94cf81c26b5cbcd7f7fd67 +5da52c371983bff1e44d50c00565aa5c +dc5cd8b4ba8b06cf2c836d35f5117a5a +4fb1cb61faf463c209fddd1bb0b3ff81 d41d8cd98f00b204e9800998ecf8427e -d2d4f3c4b03e226a2ae751d35adc84c7 -f60aa8f7e04400f4af3bab2ea21f3383 +b03a23d99ff8934ba5a850184a0b0d0c +c86ea16e4f10b94df31701289c00b4ab -9ad62e69014ff23f232dcc43859b6018 -c741e135218d1dbfbcc03a6a4e0271a9 -1960bfd361ca2e7b2582c1633c35b0a3 +0896aa5a8e5444e0bb03ae80c097e82d +dd5996e0d69cf32275d6870b55b56bfa +c7e4e70e698600098ac2c42e411db419 07fe07a999542e322404d77a30264169 -18296a04b5d36082d8afca4e449f1ee6 -87f5b2af13b175d47eca8a33bcc68005 +86aac7d09e8e3ac69c3279b861b80968 +93cad33fd939e06b959b63c019777d91 43cc87a6b84afe612af178e9c0945279 @@ -7321,7 +7449,7 @@ d41d8cd98f00b204e9800998ecf8427e 7bd2acd718a001933d1b9723411d4371 6288df74fb85f7c954c18bf614aafcd3 -845e63a81a5b8edfa079c2fec094d6e1 +aed3cd0e313e75338a46d0dc30bb718c 55cc97fa2026cc42b4771d975b45fedb @@ -7345,7 +7473,7 @@ d41d8cd98f00b204e9800998ecf8427e cbf93873197cf6bdd0e36cd66d2a87c8 -86da383df93404580615782f4265bcb8 +009c4b4f2f9ed03cb27e8a74b3839136 2758f3882de560e1d11d208959c0627e @@ -7364,27 +7492,26 @@ ab88360e0141e3ddb3c8be3ee745008b -099c61f85742fec38c0e6fedff80d7eb -f15cbc07a79882808b31c59831725260 -2f76a335578ef4412e9b3b4a222ccb08 +f81a579ee5ec1adcd1a1de6fce3cb5c8 +5aad4002fc93b2b92d994edbbf95c50b 6fe5e34cc37004b4342377afa27fe78e 65306d3a5faf1ede100f0b433e707aa9 d41d8cd98f00b204e9800998ecf8427e -5baae840658acdb066b3294b07d6ed63 -e2e322bda8e0a19f571796b5ca46a266 +d6814238960c3d3ae89a8748af2cd846 +1dc3d6a1dd909a8a58fe8eca47ead5ac 87ab6c05827eaa2db8236ca2c0262ead -04e84d93b6851156225d86b33bc68056 +1d878883bffeb35ff573a04d207a7938 748fa3c47dca5861db4a736455d0f981 -762d623e34cb8c1d8b575801543027c8 -e99a525c7011b5cc748b27040716cfd1 +b3cf8bd9552d63ecc9746ca05452bf2f +674268c96f941fc5a6cd52da5fb0fd43 abcdf41603da0d617bee025c713adb41 c7c981cbe885fadb6853ac3250aab799 b9a967a29731ccf78b3693d680e3790a -848ba012f7bb08ead96269cac742157a +4a04cfbfb8d5f124746c3e2cd8007186 ccf2ea9b4262741181a0cff7c620146c @@ -7409,7 +7536,7 @@ 76e6aec3a1262b7b199fd88ae651d049 -1d00dfe3dd378ed263a943b10148ffb6 +a3148c5d3f8b6a38cf976cc250985d9f 479aca46b8b848649e96c290319deff5 @@ -7432,9 +7559,9 @@ 4c3fefbce8919598e7f04618a3e54ea2 -03f893c7c0667770a66ed0fd11f1a710 +a63bc90ab57ab5555e882b8db7130b63 d41d8cd98f00b204e9800998ecf8427e -0d39677613072296fbda7f35c0ed9d70 +60a4cd8e106aecadb8d082876de57a25 d60fa512ab394825284751728195161c @@ -7444,10 +7571,10 @@ cf7beba0674c611eca3eb40103a9d56d -c61793fa62504e540c4c08fc387776f1 +be4909eb830f52517bb34572822210b6 d41d8cd98f00b204e9800998ecf8427e cf3df8807edf32bdf31d3d0d148cba77 -d93f9826f6e8ef4bc66e8a92ae30020e +1f61fc5521e5a125d27fce95bd4ae5dc 6d0f156645b7ce84c269ff3adb915803 @@ -7469,7 +7596,7 @@ 831e6575098342dfa342551494097a24 -062c91c56e9a1aacf0045ba9ef2d295c +c425f95f5b0e994be961e09520cde9b3 d6d047f9389cde6f11b9175ffda432ac @@ -7509,7 +7636,7 @@ af528677086b2c26806ac47af95d9d9d -fa82bbcd66e5d31ac2f43c52caaa4acc +43b599b8900f31fcd51d013ccac558b2 d41d8cd98f00b204e9800998ecf8427e @@ -7542,7 +7669,7 @@ fde1dac27ff95323136138883a8cb086 -020e671dfeaf92176c35766720c2b8ec +64e3aebc902234add5ddbc3714b778fc d41d8cd98f00b204e9800998ecf8427e @@ -7559,9 +7686,9 @@ b3c7a210b2be2599c7fe2af126eeb062 994337d7c14c76b4537aa2e748b48729 b77816831ef40cf1b79779e1ada51d8e -1b526413dd24dc7b5d6910cf07f3aa1a -319b65909579d3ec171265423a48e35e -d6a0e0fc84f08a62d144e63ccd0f798d +5446b7733bcb58774c487c717831a8f4 +dd0fa2140f5450e0f05d6555af374289 +ca4c5271c26dc0bd0f7537f2d4fe8d75 fe62c00b682dd677dbca4764d5f0fe97 @@ -7576,8 +7703,8 @@ 21055e6d625cd5dc3e805ededd1f350a -bcc15386db16f0050d01b4d80fe68dbd -d77e4af5d17f15fdfd920ec8fda7fc45 +aec47b386df0e0df628a1e31f109e998 +0f079eeaf763fe056f582fd3d821b216 95559609c47c88b112952073fb77410e b79674bb1410c34f6428a0e392318740 ee9a71add932db04def7fb3a6d8af20f @@ -7597,10 +7724,10 @@ ea1a3bd45013d291cafdce135ebbd13c -c78c359e1ac036fa9a991e635efbfac5 +5b0073ef255ade9c14c4d56a735c5684 221d0b581479c434f039e58da4718a8d a6f5b10b14e766e788351b506b6f6024 -48ac89c72e2794fbcbb1078e0fe7d9ba +f94ccfe8360d382460cf8aca0492b9a0 9423e6de63cf281df2bcda0892da0a88 c8506bcf84839f36e61a555912e7c31c 2e5082f8e6d7976945c0e8e951d5f261 @@ -7633,7 +7760,7 @@ bef639ba5d15fbe93aa7df26bf6c3a70 -32160cab79f75fc38ed26bb590037169 +70bd9741b82ec97e1e005663b8ee8671 d00dcd6a42cd0d91cbd5639c56a4b6a7 008656d6620cb1ef43935edc30fd2994 @@ -7641,15 +7768,15 @@ 7ab5486f4cec78b1c4d93a1df0d83b51 -8b9453a22ca4ec5cd5f504b0f3338238 +73644c7a9c7312b638a8de811c0f71b8 d41d8cd98f00b204e9800998ecf8427e -0e3fff0ddbce47ecce252c82a6e02fa7 +770001d8b9e70249a27cfc567e770219 f47f735ec8627b7b3e9ce6a5e1643d4c fff5ddf9542281c2d2568153781b4c73 16e1a29a5b79d4a3668b3a71ca3d86df -992dde85a7ee2f81661fd7a54abf7f89 +5aa861a485746b0cce73cee39a4eebc6 78a3befa9a3a9bdb40420e432352250b a42439ac674abe10958f58d747f7cde0 @@ -8029,19 +8156,19 @@ f1f34d8c0f864daa5e8ab56801027430 -b7454525aa100e079c56a92ef4866283 +831fe459f7d3606afc5482fbfbe85278 c3e50ad0d4c93692a2810e136ada70d7 ab274a62d5a3a8ab5f1e745725b83dfc c4e9cd5c18af616969894e4dceb95f97 462f3f2edf24c9118a0a6df7f00765fa -a7f112322d606a3807c6e4eff9bf9b1f +5b2e22d569f45024f23cd0f6c213ea86 90a76b121fb7fe4b51daad580591cc8c ef12ff29adae2685e120e58aa04e23bc bc8b10dd8cc1f841662dfdd87868197c 311cb7d4bf06cb181cfffb6e44ed5826 e1161971bb06488cabe9066c8e827741 -90086ae0090269082c6221cdaff54d9c -4573107d98f6599ed40b01012378fa81 +f7b4e392e8e49b03c37439ecd4210e83 +7528006b9faf6605713f4b2f19f19f17 3222e8667905ffdb07a756fa25a26bd9 c710e46b08ef99b41b5167db96309c81 f28164a5a95f0a8408bfa00f4a40680d @@ -8060,7 +8187,7 @@ 75fb4c310c4f0554d3ac9859d0c5b646 e337dc8e080a86ce2e187cf3a38d0b10 de30767cf0a5d454269ab9986fce13c0 -b84cc0bb32567be3d521af1a1d2b4cce +1c3f72b75a408faa2fd8b60944cc2533 34be9245428cb84ae31c992eb21f33d3 9eea13d3889d78fdbc614dea77011565 6f3b6f771da549d8e22263e795ddecaf @@ -8070,14 +8197,15 @@ fb5913e34a812d5fdf9e25b8ca8c9fb2 3c801db51ff672838b9306c63df460e0 51a8ed92619d4857e0eaddd369a14b38 -a4fcafdd9412d243c46e1b55d7911f2c +3687aa1cf5d5f099a8b746660efe601c 5f5e1f71ef91392a3edee6cdf5e03408 8cc192424d2a8a3a8439cf6c9e9c866d 228b0316d26bdd36e56a9158eea64ef6 59b195fcff4d3877045fee21c364d524 324f3b1c1afefe3296f76db472cbc9f6 -8d2578f24429a8c9863f267bd792fb16 -6ec9a9a11b06059192bcf4a71a34dd22 +4897fa688236216c771946add0f2564c +d01fdb1e6043fb26b049108da5e4df60 +d091b8b83cd5b9dfb948872eb9b9e4dc a171ba167ab22bbfd25e570f28bd8483 f0d89af2ab05f3af36e1a4edec69c7db 1a6980f79392b14b3a7e00db58f915ff @@ -9748,24 +9876,24 @@ be05aa1b12e3b558de747e470b5731c8 -c2f72a6d3ee9b7e45506ead106bc8f86 +65db64d894cf8b776148fc4324d16986 3262db34410c13ae4d777e263d779217 -d11569807aab1e77f9bcd96fe375bde9 +97af3c06de8fcf9955b0d09d7d2c7397 c08f79985fa33fe026ef475f840f87b1 -e61deb16dd6421608631ed5c1f671c6a -f71ca57649aece8045b66345a612e20a -48451fe44b83835898ec108b9d9bf866 +1a6a7ea85a76cb09bc7568856b7f9a28 +4a00c2ddb39f4e28db51f6d0f3283859 +385be3b28799de9f80d0ef46508efbdc 98fec0976eec22385c2b735cb80d7448 b7c27239e68ce6f51296820da50bfffa 60d670dc85d029ed1c3f63693d0d4288 186dbbf4b11a9684557157006bf2a232 -8e42376332e36c72edf33421d3f12bf8 -cb73d7bfbdae912945ec4d98c0d1ec9b +78663365fd9c3f521c456712bf1aaf17 +45ac46e656485f54c2e642c00ece251c cfc96587347a77604730af23372d747f -6b1538d4b9683808221f30ddad0414d8 +398d48fad9f224e2c8a811b7e63cfb5b f5f165bb15c6391fc12ebac3e0a0f3e6 555145f760c70cf34b190b7214e3b5cc -dd62bf79621c56e565feabc0b84574d0 +c4db7841d9ac141c2e07f986344cf10e 7508982db7d5e9e5c7fec3f096de32b0 aa86f6cb23c2ae8294bcbd6f2315e8ed c56f3ea358f24bb4e820768e948b416b @@ -9776,11 +9904,11 @@ 2da0a1995db50d0752d2e509a3bca37f 78f2edd4512d3859d13e1c90618932ff 10c2dcc555137e38039193ccedfc0cd3 -b0d093ebda261c4ac0a6bb982cfa41f0 +f3cb3a7da6c4a8e947856ce9a7529a90 418334153f5b6a5543f6cb5a28f3c82b -bac99d873d638b05891fda9f7c62d562 -021de63f1074cc73a6d83a3e83a5ae55 -c7f8ee7a8d27fb0d86b5386b8cd9a6f7 +c760d45b0959664fe5ef8f18e31cd4ae +d01ee19b9b423b0378dfb48c8a20b021 +914772c1d09c8268418beaafaf36313d 199dcc4ae427c0d0e5fbde6c0d2d2f99 57da58850de2f4591fc18e23473ba8ad 08fc6ae338f02d76f77339c8537012ba @@ -9799,8 +9927,8 @@ 7dcd96797a60b5e466e25990e534f588 1818aababec2539efc6cee74006d4d0c 16202ce23ad23f4f86fcbd0c5d16dea2 -83a5a0b9fdc95c8f1647075e8c63c00a -d95dd0afca51ee1616ffe9550cfc1f93 +2086b1a692e4c3cc5dbe6edbc87976d4 +8dcd21c1d37a27cc9a9f227a2b283388 87eae3bfbea127d8e90970cf3fe8a9a1 @@ -10153,8 +10281,9 @@ 9ff187bdce93767cf2f24dbb5b0a34c5 c04364a46b55ae75b65db731f040dbee 5437aca264069f35e46a3fc46f04c2d9 -438c872ca8fdb808934df640ad361350 +b00df950231dc8222d5a74855b0708b5 9d95d44e6045f242b1ad717ed35f195b +5f1f15ee0a4ecc70e93427b814af9489 cf750bc5baeb59198423a8ba9039fccf b50591f99fa324afaba5e4e1d15829f3 349416524f35254fa72144bc7e08f9a6 @@ -10188,15 +10317,16 @@ 1008cbc1e61ed90dfd79c57cd620c92b 46f6b55d98da9ef1ffec9b1d1a6125bd e4e03fc7d82d2da0126d8445f09f61c2 -7a0cedeb2e3c160aa33e736ebba6059e +03cdf6ba23e31c14abc2bb3a79b7472c fab14e1ece001f18e03308c4abd5d7b6 2bac51be88c59c5ee21511836859e221 0889424a15f7ae4d5147e680d379e3c0 b8357efaf2331cd36af04b80256e3181 5a0de7d0f34fd6f63ae32d20e0a32b9d a1fe9c904ea0bd6d6ea490b977432ffc -d98e38cacdacd9d7c74df773358d6e6f +f424ed5d8ad204b2ccfd39045ab44d3b 3bb797554b6eedd86f67a0c36e9918ec +89b6756ccb0d05b4191b704aafaf5803 9afb68804040e5f7d92d7c308b79f770 d7d2fd96c741b616945e848ade9f9539 7767ff394313f1229871b8ee58c26a99 @@ -10429,7 +10559,7 @@ 52517073ee32fd105af7fccfde018e29 -2fb346f0383dd975a301eca9a423c12a +ca1f6c3cde7a72fc33fa826f580ca872 d41d8cd98f00b204e9800998ecf8427e @@ -10440,17 +10570,17 @@ d41d8cd98f00b204e9800998ecf8427e -1ba9555290fac6190106a623ece3376f -3a9bf22080b7d3c4d3a154affe9d6095 +e4a286e635b8486ef952cd5e7c063272 +daa87eb4e5a5dec7a491a6313f9335c9 bdd80120aa3357c1ac276e8b2ffb81a6 -7cb5f8fa9f76dae5e107abfbc0e35d82 +720ce5f162f6879e42bd51a2e677966c 8326aa93734dd8035a04c12062e68ce4 d41d8cd98f00b204e9800998ecf8427e -a6eb7d29b6a4649096f384711efdf232 +529b00d17c929c47878ebeb1cf313267 099f9b1f56cae48a1b679ed282e3766d @@ -12286,6 +12416,7 @@ 2e0eb0e3d978cfc35b462a199aeded78 9e36c55b53a1b080066d9947a92d2ce3 9e36c55b53a1b080066d9947a92d2ce3 +8f120e35f8b6608fb34e38edf9a2687c a9e38adb81052e1178a2486de8a87c28 7389cc51b77b11b297ccce79048a1c7f 0474bee65715fc6918a92b668178be6c @@ -12350,7 +12481,7 @@ d41d8cd98f00b204e9800998ecf8427e -be5e2576e65fca0640a3e943edb7b4a2 +b7ac1e65cfb2226f71c4c585b87ef36d fd6a54cb5cf80f075d7687ad66dd2cb9 @@ -12368,20 +12499,20 @@ 11689e5722e4204b9d01e5e4483b92ef -cc97395704f8c817d0c92e81b4626429 +ba1182650ae38ce16735a2f783046f85 a20a84fb09238e216ab80d91674426b1 d41d8cd98f00b204e9800998ecf8427e 4b94e9ad89c520b4cc4ab986a1cfb5f8 -348ac1d0cc575dcee2a8bd3fe3da6096 +62867ac6e7f63524ba1bbd195e5504ef 96a92bc03a6ca67f39d363c36031dee7 db802ba04a77501799a7073600802c80 0e4f03114e8298dfc23bb94d0df5d390 5e1aea18f899b4a763a0291dcf1f2b90 -c6798747955c37d2da47a6753d831cf4 +f34e17319f0c0f4b26c44fed42091c3b eed35a94809263558ac663233eaa2f38 @@ -12390,44 +12521,153 @@ d41d8cd98f00b204e9800998ecf8427e -74d19c16439bec3b2eeabde4bb8b6b1d -15faab5d58a32bd40d3f163cfaf951b6 +2174cc25f7e4e713034396fa94be1c93 +8334218ca0707e5c27f28b6897c673e6 a1838ba6f718aeec0172bc6e9d90f4b6 -eb474eb2e1039037169aaacb91443c3e +1d1dd963b8dfb47170403042c4c86431 7770e9e8e3fb4b98bc149059c5bc9633 -7aece8343f1f3c70f617733955c2bce6 +b0fd3b28285996794ea374e10881da03 7b7cde9c324feeed6e94f50e1655ba40 3c77ad60389c5eaaa410ac4a176b3ab6 bdb99f4a1594eaf4923129f21035a88d 966129fc8b4d82883741779cf87ea57a -9c258004b01196601cc918cc09857b0a +a2252f5482460d20d054a1f7d36f4dbe + + +3064b1ab98d9562f84c353c586a36765 +4d843333d740ee7e132b9aba3ca84c79 + + +352318e7e91b1ea9e37097409c9907a4 + + +48e867f61a945a10e84ccc6b297b530d + + +decda684aa41b7e3d4c9cbd82c57bf16 + + +e85c36b02b54ca8575353e41a035ef98 + + +a9edd5331230715886153f1ac2535d10 +a76cbf5801d8a007cdf2b8d82534e922 +a7f9c53e667b559a168e9c669751b9b4 + + +09fd73462e6973de1e5b4d5ea13015f3 + + +c030f0ca220a0377d27db496ed8b5318 + + +4fbee2586602efafa0764319b427939f + + +2acaf08f39c54745ac076d2e907273a8 + + +628ed9cddef9a2221251063053805324 +1fa2e700c74403c7941380638b09d82c +75f02406119800a1604d0b579ef3e61b +4f45d10b5ee1f09cb3fe944a95d6862b +f2a7ed553bd2288e8618c2c270a904df + + +8e3e6864c5fc86e81a2fa2ab2a39c6cf + + +dc14015d4641c2ace184a65f28bbe2a8 + + +eb6922c389258f0bcdee9efd22fb92ce + + +8aa3a2b726bc259ba9d57cb66d1ebeee + + +569784a8bbe92385bb2e32740788ad5c +b31ffb415b0662026fc6b92c0f87953c + + +839af79be6bad3e0880427117aa63e1f + + +ced84ab2bf5bd9391ea24b6bc30e987d + + +1f34e4ab0ec69431bd6661f39e138684 + + +19399c45ec6fb7cd97adf8455d766818 +aee69fb06398d6982ddbd7a4c8462a50 +6802f7660d7b71d1684e3a0ad0472ad8 +5ace6d4ad483742bc7d0679a934ed312 + + +593cc9cb911cbd7433bc198d2e0ea7f5 +93c7eed93f34e0951873519d5c60df2b + + +d6051e8e91e3b9275fb3315c5f10bd4d +e4552f8e8c2cb90661b4d9693e13ba52 + + +a2621ad34bd5b20864c8cf669c3d8a93 +469ce28873bd63023d33e9738b52d92e +b98d1eb79425c7db97a6837942aa64f7 + + +8a6217da856e75f4de79612f74f12e9e + + +660ce536dc1d691a14b4cede3f8c25cc +7abe92af6f134fc8ab7b414ddfa9fdc3 +8a8f3a86b7714c89caddbe4bdc73af8f + + +1bf6a453a4d929acc0c868e4cf6bc083 +144997b030c9e8c99a686d3c8d17ead6 + + +7e9686417f83eab48e7d19d61b6a5f7f + + +060b91056472c88d12426eaddd919c41 +4a313ea27e6c40565d7381b271199751 +a911dbae66b9f63328e9033182ae455a + + +a9d6e5bf4ae47e75eacbee49bce7d945 +15a61b5570ae5be9f79bfd79f6ee6faa +df00595a449a2aa6ebd8e79c8aad37ee 9382e7efb69651b29045f2421d618717 0b959ec99ed9ee63f065c7d40454b9ec -ce4ff827937faf5800380ff9867324b5 +a7387351fcf1eaf404d6f7f41b178ca4 -be24a0530d2ce043c5f6df3e85e309b1 +2c0d16fc13d82dcc90011730fb8c32aa -dc472d539640920357d694745d5c7f9d +c660c836df813f50dfdfe793821cbb94 1ebef0db96238c1bd7372bea81b9761d 4a3747f8978a90ab4ed41be95c2f5695 4f9ad2e49a960637c6f48ee7c228ee0f 0e96616ba6ef78c2874b6c9fb9c10c7a -857ef0aa17df0f205806791dcd65427c -986e2f39e85074de9facf0ea7973f315 +9da09c907dca9a53fd16ba8b261e4f62 +6df215e0c6cc349308be769a25c4ce74 d41d8cd98f00b204e9800998ecf8427e From 1660c1c05bd72a2e9a8187b01ddd1c10e479c2f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 01:30:46 +0100 Subject: [PATCH 114/133] Fix bug introduced with var_dump --- htdocs/core/db/mssql.class.php | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index e2d938da710..3523e21bdf0 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -237,10 +237,10 @@ class DoliDBMssql extends DoliDB $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); - + if ($this->transaction_opened == 0) { - //return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTIONS ON' generate also a mess + //return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTIONS ON' generate also a mess $ret=mssql_query("SET IMPLICIT_TRANSACTIONS OFF;BEGIN TRANSACTION;",$this->db); if ($ret) { @@ -264,7 +264,7 @@ class DoliDBMssql extends DoliDB { $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); - + if ($this->transaction_opened == 1) { //return 1; //There is a mess with auto_commit and 'SET IMPLICIT_TRANSACTION ON' generate also a mess @@ -296,7 +296,7 @@ class DoliDBMssql extends DoliDB { $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); - + if ($this->transaction_opened == 1) { $ret=mssql_query("ROLLBACK TRANSACTION",$this->db); @@ -322,7 +322,7 @@ class DoliDBMssql extends DoliDB function query($query,$usesavepoint=0,$type='auto') { $query = trim($query); - + if (preg_match('/^--/',$query)) return true; // Conversion syntaxe MySql vers MSDE. @@ -331,7 +331,7 @@ class DoliDBMssql extends DoliDB $query = str_ireplace(", tms = tms", "", $query); $query=preg_replace("/([. ,\t(])(percent|file|public)([. ,=\t)])/","$1[$2]$3",$query); - + if ($type=="auto" || $type='dml') { $query=preg_replace('/AUTO_INCREMENT/i','IDENTITY',$query); @@ -339,7 +339,7 @@ class DoliDBMssql extends DoliDB $query=preg_replace('/float\((.*)\)/','numeric($1)',$query); $query=preg_replace('/([ \t])unsigned|IF NOT EXISTS[ \t]/i','$1',$query); $query=preg_replace('/([ \t])(MEDIUM|TINY|LONG){0,1}TEXT([ \t,])/i',"$1VARCHAR(MAX)$3",$query); - + $matches=array(); $original_query=''; if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+(?:(UNIQUE)|INDEX)\h+(?:INDEX)?\h*(\w+?)\h*\((.+)\)/is', $query,$matches)) @@ -360,7 +360,7 @@ class DoliDBMssql extends DoliDB if ($query_comp) $query.=" WHERE ".implode(" AND ",$query_comp); } - } + } else { if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+PRIMARY\h+KEY\h+(\w+?)\h*\((.+)\)/is', $query, $matches)) @@ -369,7 +369,7 @@ class DoliDBMssql extends DoliDB $query="ALTER TABLE [".$matches[1]."] ADD CONSTRAINT [".$matches[2]."] PRIMARY KEY CLUSTERED (".$matches[3].")"; } } - + } if ($type=="auto" || $type='ddl') @@ -384,13 +384,13 @@ class DoliDBMssql extends DoliDB // Supprimer l'instruction MySql $query = str_ireplace(" limit ".$number, "", $query); } - + $itemfound = stripos($query, " week("); if ($itemfound !== false) { // Recreer une requete sans instruction Mysql $positionMySql = stripos($query, " week("); $newquery = substr($query, 0, $positionMySql); - + // Recuperer la date passee en parametre $extractvalue = stristr($query, " week("); $extractvalue = substr($extractvalue, 6); @@ -398,7 +398,7 @@ class DoliDBMssql extends DoliDB // Conserver la fin de la requete $endofquery = substr($extractvalue, $positionMySql); $extractvalue = substr($extractvalue, 0, $positionMySql); - + // Remplacer l'instruction MySql en Sql Server // Inserer la date en parametre et le reste de la requete $query = $newquery." DATEPART(week, ".$extractvalue.$endofquery; @@ -407,11 +407,11 @@ class DoliDBMssql extends DoliDB { //var_dump($query); //var_dump($matches); - if (stripos($query,'llx_c_departements') !== false) var_dump($query); + //if (stripos($query,'llx_c_departements') !== false) var_dump($query); $sql='SET IDENTITY_INSERT ['.trim($matches[1]).'] ON;'; @mssql_query($sql, $this->db); $post_query='SET IDENTITY_INSERT ['.trim($matches[1]).'] OFF;'; - + } } //print ""; @@ -427,7 +427,7 @@ class DoliDBMssql extends DoliDB { $ret = mssql_query($query, $this->db); } - + if (!empty($post_query)) { @mssql_query($post_query, $this->db); @@ -732,13 +732,13 @@ class DoliDBMssql extends DoliDB //TODO: Check if we need to force a charset //$sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation; $ret=$this->query($sql); - + $this->select_db($database); $sql="CREATE USER [$owner] FOR LOGIN [$owner]"; mssql_query($sql,$this->db); $sql="ALTER ROLE [db_owner] ADD MEMBER [$owner]"; mssql_query($sql,$this->db); - + $sql="ALTER DATABASE [$database] SET ANSI_NULL_DEFAULT ON;"; @mssql_query($sql,$this->db); $sql="ALTER DATABASE [$database] SET ANSI_NULL ON;"; @@ -976,12 +976,12 @@ class DoliDBMssql extends DoliDB } $sql="SELECT name from sys.databases where name='".$dolibarr_main_db_name."'"; $ressql=$this->query($sql); - if (! $ressql) + if (! $ressql) { dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_WARNING); return -1; - } - else + } + else { if ($num) { @@ -1106,7 +1106,7 @@ class DoliDBMssql extends DoliDB return array(); } - + /** * Escape a field name according to escape's syntax * @@ -1116,18 +1116,18 @@ class DoliDBMssql extends DoliDB function EscapeFieldName($fieldname) { return "[".$fieldname."]"; } - - + + /** * Get information on field - * + * * @param string $table Table name which contains fields * @param mixed $fields String for one field or array of string for multiple field * @return boolean|multitype:object */ function GetFieldInformation($table,$fields) { $sql="SELECT * from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='".$this->escape($table)."' AND COLUMN_NAME"; - if (is_array($fields)) + if (is_array($fields)) { $where=" IN ('".implode("','",$fields)."')"; } @@ -1144,7 +1144,7 @@ class DoliDBMssql extends DoliDB $result[]=$obj; } } - else + else return false; return $result; From 049174b76f02424cbbd7fa985a09ead6a788c2dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 01:53:02 +0100 Subject: [PATCH 115/133] Fix bugs reported by https://scrutinizer-ci.com/g/Dolibarr/dolibarr/ --- htdocs/admin/fichinter.php | 2 +- htdocs/admin/security_file.php | 2 +- htdocs/contrat/document.php | 2 +- htdocs/core/class/commonobject.class.php | 24 ++++++++++++------------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 8965b225cfb..8e06e946dee 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -221,7 +221,7 @@ else if ($action == 'set_FICHINTER_DRAFT_WATERMARK') elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') { $val = GETPOST('FICHINTER_PRINT_PRODUCTS','alpha'); - $res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS",($val == 'on'),'bool',0,'',$conf->entity); + $res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS",($val == 'on' ? 1 : 0),'bool',0,'',$conf->entity); if (! $res > 0) $error++; diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 4c0dd435634..d99db6ed638 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -208,7 +208,7 @@ $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestF // List of document $filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1); -$formfile->list_of_documents($filearray, '', 'admin_temp', ''); +$formfile->list_of_documents($filearray, null, 'admin_temp', ''); llxFooter(); $db->close(); diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 6c520105c36..49466c7fcb0 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -91,7 +91,7 @@ llxHeader(); if ($object->id) { - $head=contract_prepare_head($object, $user); + $head=contract_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("Contract"), 0, 'contract'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3c5bb73d93e..8ad8ecd2331 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -888,7 +888,7 @@ abstract class CommonObject if (! $this->table_element) { - dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined", LOG_ERR); + dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined"); return -1; } @@ -2389,8 +2389,8 @@ abstract class CommonObject return 1; } } - - + + /** * Return incoterms informations * @@ -2409,13 +2409,13 @@ abstract class CommonObject $res = $this->db->fetch_object($result); $out .= $res->code; } - } - + } + $out .= ' - '.$this->location_incoterms; - + return $out; } - + /** * Return incoterms informations for pdf display * @@ -2430,12 +2430,12 @@ abstract class CommonObject $res = $this->db->fetch_object($resql); return 'Incoterm : '.$res->code.' - '.$this->location_incoterms; } - else + else { - return false; + return false; } } - + /** * Define incoterms values of current object * @@ -2457,14 +2457,14 @@ abstract class CommonObject { $this->fk_incoterms = $id_incoterm; $this->location_incoterms = $location; - + $sql = 'SELECT libelle FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; $res = $this->db->query($sql); if ($res) { $obj = $this->db->fetch_object($res); $this->libelle_incoterms = $obj->libelle; - } + } return 1; } else From c7c7c393ee9db5dc52eadc5371c07b3f7067b59e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 02:14:59 +0100 Subject: [PATCH 116/133] sql syntax errors --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 2 +- .../mysql/tables/llx_askpricesupplierdet_extrafields.sql | 2 +- 2 files changed, 2 insertions(+), 2 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 3233022d3f9..2a36ef78737 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 @@ -316,7 +316,7 @@ CREATE TABLE llx_askpricesupplier_extrafields ( ) ENGINE=innodb; CREATE TABLE llx_askpricesupplierdet_extrafields ( - rowid integer AUTO_INCREMENT PRIMAR KEY, + rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, fk_object integer NOT NULL, import_key varchar(14) DEFAULT NULL diff --git a/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql b/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql index 6ecbcf83d2c..7bfab6e408c 100644 --- a/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_askpricesupplierdet_extrafields.sql @@ -16,7 +16,7 @@ -- ======================================================================== CREATE TABLE llx_askpricesupplierdet_extrafields ( - rowid integer AUTO_INCREMENT PRIMAR KEY, + rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, fk_object integer NOT NULL, import_key varchar(14) DEFAULT NULL From a0762a5113942f6b9a2f1dc39c915fec1022a78f Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 6 Mar 2015 01:31:49 +0000 Subject: [PATCH 117/133] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/admin/system/filecheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 278aae8ea5b..8eff6821224 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -108,7 +108,7 @@ $db->close(); /** * Function to get list of updated or modified files * - * @param object $dir SimpleXMLElement of files to test + * @param SimpleXMLElement $dir SimpleXMLElement of files to test * @param string $path Path of file * @return array Array of filenames */ From 27e99793a373a7348ccf1185d051999f618f8782 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 6 Mar 2015 02:10:01 +0000 Subject: [PATCH 118/133] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- htdocs/core/class/cookie.class.php | 2 +- htdocs/core/class/html.form.class.php | 12 ++++++------ htdocs/core/class/html.formbank.class.php | 2 +- htdocs/core/class/html.formcron.class.php | 4 ++-- htdocs/core/class/html.formmailing.class.php | 2 +- htdocs/core/class/html.formother.class.php | 8 ++++---- htdocs/core/class/menu.class.php | 4 ++-- htdocs/core/class/mobiledetect.class.php | 8 ++++---- htdocs/core/class/openid.class.php | 14 +++++++------- htdocs/core/class/translate.class.php | 8 ++++---- htdocs/core/datepicker.php | 2 +- htdocs/core/db/mysql.class.php | 4 ++-- htdocs/core/db/mysqli.class.php | 6 +++--- htdocs/core/db/pgsql.class.php | 10 +++++----- htdocs/core/lib/json.lib.php | 2 +- .../askpricesupplier/modules_askpricesupplier.php | 4 ++-- htdocs/core/modules/commande/modules_commande.php | 4 ++-- htdocs/core/modules/contract/modules_contract.php | 4 ++-- htdocs/core/modules/dons/modules_don.php | 2 +- .../core/modules/expedition/modules_expedition.php | 4 ++-- .../expensereport/modules_expensereport.php | 4 ++-- htdocs/core/modules/export/modules_export.php | 2 +- htdocs/core/modules/facture/modules_facture.php | 4 ++-- htdocs/expedition/class/expeditionbatch.class.php | 4 ++-- 25 files changed, 62 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index b7f8e09677f..bf11c4fea13 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -206,7 +206,7 @@ abstract class CommonDocGenerator /** * Define array with couple subtitution key => subtitution value * - * @param Object $object contact + * @param Contact $object contact * @param Translate $outputlangs object for output * @param array_key $array_key Name of the key for return array * @return array of substitution key->code @@ -442,7 +442,7 @@ abstract class CommonDocGenerator /** * Define array with couple substitution key => substitution value * - * @param Object $object Main object to use as data source + * @param Expedition $object Main object to use as data source * @param Translate $outputlangs Lang object to use for output * @param array_key $array_key Name of the key for return array * @return array Array of substitution diff --git a/htdocs/core/class/cookie.class.php b/htdocs/core/class/cookie.class.php index bcca9fcfa73..150d52fae62 100644 --- a/htdocs/core/class/cookie.class.php +++ b/htdocs/core/class/cookie.class.php @@ -109,7 +109,7 @@ class DolCookie * * @param string $cookie Cookie name * @param string $value Cookie value - * @param string $expire Expiration + * @param integer $expire Expiration * @param string $path Path of cookie * @param string $domain Domain name * @param int $secure 0 or 1 diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c5cdbc3f9e7..31fb095e3c8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -480,7 +480,7 @@ class Form * @param string $selected Id or Code or Label of preselected country * @param string $htmlname Name of html select object * @param string $htmloption Options html on select object - * @param string $maxlength Max length for labels (0=no limit) + * @param integer $maxlength Max length for labels (0=no limit) * @return string HTML string with select */ function select_country($selected='',$htmlname='country_id',$htmloption='',$maxlength=0) @@ -658,7 +658,7 @@ class Form * @param string $htmlname Name of field in html form * @param int $showempty Add an empty field * @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select) - * @param string $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, -1=Force none (and set hidden field to 'service') + * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, -1=Force none (and set hidden field to 'service') * @return void */ function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0) @@ -1072,9 +1072,9 @@ class Form * @param int $showempty 0=no empty value, 1=add an empty value * @param string $exclude List of contacts id to exclude * @param string $limitto Disable answers that are not id in this array list - * @param string $showfunction Add function into label + * @param integer $showfunction Add function into label * @param string $moreclass Add more class to class style - * @param string $showsoc Add company into label + * @param integer $showsoc Add company into label * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param bool $options_only Return options only (for ajax treatment) @@ -1095,10 +1095,10 @@ class Form * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit) * @param string $exclude List of contacts id to exclude * @param string $limitto Disable answers that are not id in this array list - * @param string $showfunction Add function into label + * @param integer $showfunction Add function into label * @param string $moreclass Add more class to class style * @param bool $options_only Return options only (for ajax treatment) - * @param string $showsoc Add company into label + * @param integer $showsoc Add company into label * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return int <0 if KO, Nb of contact in list if OK diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index 12bff860a26..6335e25dd72 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -45,7 +45,7 @@ class FormBank /** * Retourne la liste des types de comptes financiers * - * @param string $selected Type pre-selectionne + * @param integer $selected Type pre-selectionne * @param string $htmlname Nom champ formulaire * @return void */ diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 4de88a7bfc9..86c80413855 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -47,8 +47,8 @@ class FormCron extends Form * Display On Off selector * * @param string $htmlname Html control name - * @param string $selected selected value - * @param string $readonly Select is read only or not + * @param integer $selected selected value + * @param integer $readonly Select is read only or not * @return string HTML select field */ function select_typejob($htmlname,$selected=0,$readonly=0) diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 98a76c84686..93fdac553a3 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -48,7 +48,7 @@ class FormMailing extends Form * * @param string $selectedid the selected id * @param string $htmlname name of controm - * @param number $show_empty show empty option + * @param integer $show_empty show empty option * @return string HTML select */ public function selectDestinariesStatus($selectedid='',$htmlname='dest_status', $show_empty=0) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index d418a32fd77..4ea60dbf2c1 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -157,7 +157,7 @@ class FormOther * * @param string $selected Preselected ecotaxes * @param string $htmlname Name of combo list - * @return void + * @return integer */ function select_ecotaxes($selected='',$htmlname='ecotaxe_id') { @@ -268,7 +268,7 @@ class FormOther /** * Return a HTML select list to select a percent * - * @param string $selected pourcentage pre-selectionne + * @param integer $selected pourcentage pre-selectionne * @param string $htmlname nom de la liste deroulante * @param int $disabled Disabled or not * @param int $increment increment value @@ -303,7 +303,7 @@ class FormOther * Return select list for categories (to use in form search selectors) * * @param int $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members) - * @param string $selected Preselected value + * @param integer $selected Preselected value * @param string $htmlname Name of combo list * @param int $nocateg Show also an entry "Not categorized" * @return string Html combo list code @@ -834,7 +834,7 @@ class FormOther * @param int $offset Offset * @param int $invert Invert * @param string $option Option - * @return void + * @return string */ function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') { diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 411158dea84..dff357d8f91 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -53,7 +53,7 @@ class Menu * * @param string $url Url to follow on click * @param string $titre Label of menu to add - * @param string $level Level of menu to add + * @param integer $level Level of menu to add * @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey) * @param string $target Target lien * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) @@ -71,7 +71,7 @@ class Menu * @param int $idafter Array key after which inserting new entry * @param string $url Url to follow on click * @param string $titre Label of menu to add - * @param string $level Level of menu to add + * @param integer $level Level of menu to add * @param int $enabled Menu active or not * @param string $target Target lien * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) diff --git a/htdocs/core/class/mobiledetect.class.php b/htdocs/core/class/mobiledetect.class.php index 297058698aa..b04e0e98c91 100644 --- a/htdocs/core/class/mobiledetect.class.php +++ b/htdocs/core/class/mobiledetect.class.php @@ -687,7 +687,7 @@ class MobileDetect /** * Retrieve the User-Agent. * - * @return string|null The user agent if it's set. + * @return string The user agent if it's set. */ public function getUserAgent() { @@ -879,7 +879,7 @@ class MobileDetect * * @param string $name Name * @param array $arguments Arguments - * @return mixed + * @return null|boolean * * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is' * @method boolean is[...]() @@ -926,7 +926,7 @@ class MobileDetect * * @param string $key Key * @param string $userAgent deprecated - * @return mixed + * @return null|boolean */ protected function matchUAAgainstKey($key, $userAgent = null) { @@ -1009,7 +1009,7 @@ class MobileDetect * @param string $key key * @param string $userAgent deprecated * @param string $httpHeaders deprecated - * @return bool|int|null + * @return null|boolean * * @todo: The httpHeaders part is not yet used. */ diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index a5e01998ecd..d46481a0c60 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -150,7 +150,7 @@ class SimpleOpenID /** * GetIdentity * - * @return void + * @return string */ function GetIdentity() { // Get Identity @@ -187,7 +187,7 @@ class SimpleOpenID /** * IsError * - * @return void + * @return boolean */ function IsError() { @@ -225,7 +225,7 @@ class SimpleOpenID * OpenID_Standarize * * @param string $openid_identity Server - * @return void + * @return string */ function OpenID_Standarize($openid_identity = null) { @@ -251,7 +251,7 @@ class SimpleOpenID * array2url * * @param array $arr An array - * @return boolean|string false if KO, string of url if OK + * @return false|string false if KO, string of url if OK */ function array2url($arr) { // converts associated array to URL Query String @@ -303,7 +303,7 @@ class SimpleOpenID * @param string $url URL * @param string $method Method * @param string $params Params - * @return boolean|unknown + * @return string */ function CURL_Request($url, $method="GET", $params = "") { // Remember, SSL MUST BE SUPPORTED @@ -384,7 +384,7 @@ class SimpleOpenID /** * GetRedirectURL * - * @return void + * @return string */ function GetRedirectURL() { @@ -428,7 +428,7 @@ class SimpleOpenID /** * ValidateWithServer * - * @return void + * @return boolean */ function ValidateWithServer() { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 7347b065a79..0e55da2769a 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -153,7 +153,7 @@ class Translate * If $domain is "file@module" instead of "file" then we look for module lang file * in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang * then in htdocs/module/langs/code_CODE/file.lang instead of htdocs/langs/code_CODE/file.lang - * @param string $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US) + * @param integer $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US) * @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed) * @param int $forcelangdir To force a different lang directory * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK @@ -548,7 +548,7 @@ class Translate * Return list of all available languages * * @param string $langdir Directory to scan - * @param string $maxlength Max length for each value in combo box (will be truncated) + * @param integer $maxlength Max length for each value in combo box (will be truncated) * @param int $usecode Show code instead of country name for language variant * @return array List of languages */ @@ -583,7 +583,7 @@ class Translate * Return if a filename $filename exists for current language (or alternate language) * * @param string $filename Language filename to search - * @param string $searchalt Search also alernate language file + * @param integer $searchalt Search also alernate language file * @return boolean true if exists and readable */ function file_exists($filename,$searchalt=0) @@ -720,7 +720,7 @@ class Translate * Return a currency code into its symbol * * @param string $currency_code Currency code - * @param string $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency. + * @param integer $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency. * @return string Currency symbol encoded into UTF8 */ function getCurrencySymbol($currency_code, $forceloadall=0) diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index c1918ed6247..eae723946f6 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -122,7 +122,7 @@ print ''."\n"; * Convert date to timestamp * * @param string $mysqldate Date YYYMMDD - * @return timestamp Timestamp + * @return integer Timestamp */ function xyzToUnixTimestamp($mysqldate) { diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index bd3e77f37d5..64efc837bcd 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -183,7 +183,7 @@ class DoliDBMysql extends DoliDB * @param string $login login * @param string $passwd password * @param string $name name of database (not used for mysql, used for pgsql) - * @param string $port Port of database server + * @param integer $port Port of database server * @return resource Database access handler * @see close */ @@ -314,7 +314,7 @@ class DoliDBMysql extends DoliDB /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_row($resultset) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index cd692db677c..1126f6c8a57 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -186,7 +186,7 @@ class DoliDBMysqli extends DoliDB * @param string $login login * @param string $passwd password * @param string $name name of database (not used for mysql, used for pgsql) - * @param string $port Port of database server + * @param integer $port Port of database server * @return resource Database access handler * @see close */ @@ -317,7 +317,7 @@ class DoliDBMysqli extends DoliDB /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_row($resultset) @@ -716,7 +716,7 @@ class DoliDBMysqli extends DoliDB * * @param string $table Name of table * @param string $field Optionnel : Name of field if we want description of field - * @return resultset Resultset x (x->Field, x->Type, ...) + * @return resource Resultset x (x->Field, x->Type, ...) */ function DDLDescTable($table,$field="") { diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 94a2e5fa975..285bdc2cdef 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -368,7 +368,7 @@ class DoliDBPgsql extends DoliDB * @param string $login Login * @param string $passwd Password * @param string $name Name of database (not used for mysql, used for pgsql) - * @param string $port Port of database server + * @param integer $port Port of database server * @return resource Database access handler * @see close */ @@ -546,7 +546,7 @@ class DoliDBPgsql extends DoliDB /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_array($resultset) @@ -559,7 +559,7 @@ class DoliDBPgsql extends DoliDB /** * Return datas as an array * - * @param Resultset $resultset Resultset of request + * @param resource $resultset Resultset of request * @return array Array */ function fetch_row($resultset) @@ -771,7 +771,7 @@ class DoliDBPgsql extends DoliDB * * @param string $fieldorvalue Field name or value to encrypt * @param int $withQuotes Return string with quotes - * @return return XXX(field) or XXX('value') or field or 'value' + * @return string XXX(field) or XXX('value') or field or 'value' */ function encrypt($fieldorvalue, $withQuotes=0) { @@ -1010,7 +1010,7 @@ class DoliDBPgsql extends DoliDB * * @param string $table Name of table * @param string $field Optionnel : Name of field if we want description of field - * @return resultset Resultset x (x->attname) + * @return resource Resultset x (x->attname) */ function DDLDescTable($table,$field="") { diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 0d92233e62a..121e719bb6f 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -269,7 +269,7 @@ function dol_json_decode($json, $assoc=false) /** * Return text according to type * - * @param mixed $val Value to decode + * @param string $val Value to decode * @return string Formated value */ function _unval($val) diff --git a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php index 1b0095308c8..4014452d8c2 100644 --- a/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php +++ b/htdocs/core/modules/askpricesupplier/modules_askpricesupplier.php @@ -43,7 +43,7 @@ abstract class ModelePDFAskPriceSupplier extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -149,7 +149,7 @@ abstract class ModeleNumRefAskPriceSupplier * Create a document onto disk according to template module. * * @param DoliDB $db Database handler - * @param object $object Object askpricesupplier + * @param AskPriceSupplier $object Object askpricesupplier * @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 diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 2caf1f905e6..9253f4dc650 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -45,7 +45,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -153,7 +153,7 @@ abstract class ModeleNumRefCommandes * Create a document onto disk accordign to template module. * * @param DoliDB $db Database handler - * @param Object $object Object order + * @param Commande $object Object order * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 9ffd5d93881..d4311bf3028 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -44,7 +44,7 @@ abstract class ModelePDFContract extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -148,7 +148,7 @@ class ModelNumRefContracts * Create a contract document on disk using template defined into CONTRACT_ADDON_PDF * * @param DoliDB $db objet base de donnee - * @param Object $object Object contract + * @param Contrat $object Object contract * @param string $modele force le modele a utiliser ('' par defaut) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index d676d2c6f70..8c894e7fa1f 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -40,7 +40,7 @@ abstract class ModeleDon extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index 43292ae95c4..d9205503e11 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -43,7 +43,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -146,7 +146,7 @@ abstract class ModelNumRefExpedition * Cree un bon d'expedition sur disque * * @param DoliDB $db Objet base de donnee - * @param Object $object Object expedition + * @param Expedition $object Object expedition * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs Objet lang a utiliser pour traduction * @return int <=0 if KO, >0 if OK diff --git a/htdocs/core/modules/expensereport/modules_expensereport.php b/htdocs/core/modules/expensereport/modules_expensereport.php index 3fa32af0fdf..5a6dcf29a34 100755 --- a/htdocs/core/modules/expensereport/modules_expensereport.php +++ b/htdocs/core/modules/expensereport/modules_expensereport.php @@ -30,7 +30,7 @@ class ModeleExpenseReport extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -52,7 +52,7 @@ class ModeleExpenseReport extends CommonDocGenerator * expensereport_pdf_create * * @param DoliDB $db Database handler - * @param Object $object Object order + * @param ExpenseReport $object Object order * @param string $message Message * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 62599016b3d..113f35299ca 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -43,7 +43,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * Load into memory list of available export format * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates (same content than array this->driverlabel) */ function liste_modeles($db,$maxfilenamelength=0) diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index bca513e3fd6..2bf03edf557 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -43,7 +43,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator * Return list of active generation modules * * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show + * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ static function liste_modeles($db,$maxfilenamelength=0) @@ -148,7 +148,7 @@ abstract class ModeleNumRefFactures * Create a document onto disk according to template module. * * @param DoliDB $db Database handler - * @param Object $object Object invoice + * @param Facture $object Object invoice * @param string $modele Force template to use ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index cc5726ed0c8..38fe5078d9e 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -147,7 +147,7 @@ class ExpeditionLineBatch extends CommonObject /** * Delete batch record attach to a shipment * - * @param object $db Database object + * @param DoliDB $db Database object * @param int $id_expedition rowid of shipment * @return int -1 if KO, 1 if OK */ @@ -172,7 +172,7 @@ class ExpeditionLineBatch extends CommonObject /** * Retrieve all batch number details link to a shipment line * - * @param object $db Database object + * @param DoliDB $db Database object * @param int $id_line_expdet id of shipment line * @return variant -1 if KO, array of ExpeditionLineBatch if OK */ From 77dd07c846e335869800b6e1e0f01ed6c7086e3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 13:12:33 +0100 Subject: [PATCH 119/133] Fix thumbs generation --- htdocs/categories/class/categorie.class.php | 16 +++++++++----- htdocs/product/class/product.class.php | 24 +++++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f5828ecdea7..b9876bb8382 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1330,17 +1330,23 @@ class Categorie extends CommonObject * Build thumb * * @param string $file Chemin du fichier d'origine - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) * @return void */ - function add_thumb($file, $maxWidth = 160, $maxHeight = 120) + function add_thumb($file) { - require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... if (file_exists($file)) { - vignette($file,$maxWidth,$maxHeight); + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality); } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e26f9102544..653925701ad 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3100,11 +3100,9 @@ class Product extends CommonObject * * @param string $sdir Target directory * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 by defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 by defaut) * @return int <0 if KO, >0 if OK */ - function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) + function add_photo($sdir, $file) { global $conf; @@ -3114,10 +3112,12 @@ class Product extends CommonObject $dir = $sdir; if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos"; + else $dir .= '/'.dol_sanitizeFileName($this->ref); dol_mkdir($dir); $dir_osencoded=$dir; + if (is_dir($dir_osencoded)) { $originImage = $dir . '/' . $file['name']; @@ -3128,7 +3128,7 @@ class Product extends CommonObject if (file_exists(dol_osencode($originImage))) { // Cree fichier en taille vignette - $this->add_thumb($originImage,$maxWidth,$maxHeight); + $this->add_thumb($originImage); } } @@ -3140,18 +3140,24 @@ class Product extends CommonObject * Build thumb * * @param string $file Chemin du fichier d'origine - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) * @return void */ - function add_thumb($file, $maxWidth = 160, $maxHeight = 120) + function add_thumb($file) { - require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... $file_osencoded=dol_osencode($file); if (file_exists($file_osencoded)) { - vignette($file,$maxWidth,$maxHeight); + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality); } } From a169b3348ee2d5249baccc0fadc8adeffd747c75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 14:36:22 +0100 Subject: [PATCH 120/133] Fix show alays date fields for contract module. Fix select of product were lost. --- htdocs/commande/card.php | 32 +++++++++++------------ htdocs/core/tpl/objectline_create.tpl.php | 22 +++++++--------- htdocs/fourn/commande/card.php | 6 ++--- htdocs/product/class/product.class.php | 4 +-- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 12150f9a61e..27c333eec21 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -207,13 +207,13 @@ if (empty($reshook)) if ($datecommande == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), 'errors'); $action = 'create'; - $error ++; + $error++; } if ($socid < 1) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); $action = 'create'; - $error ++; + $error++; } if (! $error) { @@ -334,7 +334,7 @@ if (empty($reshook)) $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); if ($result < 0) { - $error ++; + $error++; break; } @@ -349,14 +349,14 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) - $error ++; + $error++; } else { setEventMessage($srcobject->error, 'errors'); - $error ++; + $error++; } } else { setEventMessage($object->error, 'errors'); - $error ++; + $error++; } } else { // Required extrafield left blank, error message already defined by setOptionalsFromPost() @@ -390,7 +390,7 @@ if (empty($reshook)) $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); if ($result < 0) { setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); - $error ++; + $error++; } } @@ -554,24 +554,24 @@ if (empty($reshook)) if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; + $error++; } if ($qty == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error ++; + $error++; } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { @@ -826,7 +826,7 @@ if (empty($reshook)) 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 ++; + $error++; } } else { $type = GETPOST('type'); @@ -835,7 +835,7 @@ if (empty($reshook)) // Check parameters if (GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; + $error++; } } @@ -1137,10 +1137,10 @@ if (empty($reshook)) if (empty($reshook)) { $result = $object->insertExtraFields(); if ($result < 0) { - $error ++; + $error++; } } else if ($reshook < 0) - $error ++; + $error++; } if ($error) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 6037f6c77c9..e3f2431783f 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -153,12 +153,12 @@ else { if (empty($senderissupplier)) { - $form->select_produits('', 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); } else { $ajaxoptions=array( - 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tag will be edited with which ajax json response key + 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tags that will be edited with which ajax json response key 'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error' ); @@ -192,23 +192,16 @@ else {
service->enabled) && $dateSelector && GETPOST('type') != '0') +if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; else $colspan = 9; @@ -493,6 +486,11 @@ jQuery(document).ready(function() { if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus(); if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus(); }); + + + setforpredef(); + + }); /* Function to set fields from choice */ diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 7750250b00b..eefd5c961e2 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -251,7 +251,7 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $idprod=0; $productsupplier = new ProductFournisseur($db); - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-2; // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1) + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice') > 0) { @@ -294,12 +294,12 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $date_end ); } - if ($idprod == -2 || $idprod == 0) + if ($idprod == 0 || $idprod == -99) { // Product not selected $error++; $langs->load("errors"); - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")), 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), 'errors'); } if ($idprod == -1) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 653925701ad..ac3d8e967a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1229,14 +1229,14 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -3; } } } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -2; } } From e55a983c0373da451c4f4b07280afa82a0ecf0fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 16:13:09 +0100 Subject: [PATCH 121/133] Fix td balance --- htdocs/fourn/commande/dispatch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a68f11f0f69..81c9e410c28 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -393,7 +393,7 @@ if ($id > 0 || ! empty($ref)) } else { - print '"; } From dd3f569ede8ee53737d0643a515dfd3a2084e934 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 20:34:00 +0100 Subject: [PATCH 122/133] NEW: Enhance the natural_search function so we can use it to search numeric fields with criteria with operator <>= inside (< 100, >= 1000) --- htdocs/core/lib/functions.lib.php | 62 +++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 438f0ee22ca..c5d8d509b08 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4946,34 +4946,64 @@ function dol_getmypid() /** - * Natural search + * Generate natural SQL search string * - * @param mixed $fields String or array of strings filled with the fields names in the SQL query - * @param string $value The value to look for (example: "keyword1 keyword2") - * @return string $res The statement to append to the SQL query + * @param string|string[] $fields String or array of strings, filled with the name of fields in the SQL query + * @param string $value The value to look for. + * If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2 + * If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000" + * @param string $number 0=value is list of keywords, 1=value is a numeric test + * @return string $res The statement to append to the SQL query */ -function natural_search($fields, $value) +function natural_search($fields, $value, $numeric=0) { - global $db; + global $db,$langs; + + if ($numeric) + { + $value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do + } $crits = explode(' ', $value); $res = ''; if (! is_array($fields)) $fields = array($fields); - $end = count($fields); + $nboffields = count($fields); $end2 = count($crits); $j = 0; - foreach ($crits as $crit) { - $i = 0; - foreach ($fields as $field) { - if ( $i > 0 && $i < $end) $res .= " OR "; - $res .= $field . " LIKE '%" . $db->escape(trim($crit)) . "%'"; + foreach ($crits as $crit) + { + $i = 0; $i2 = 0; + $newres = ''; + foreach ($fields as $field) + { + if ($numeric) + { + $operator='='; + $newcrit = preg_replace('/([<>=]+)/','',trim($crit)); + + preg_match('/([<>=]+)/',trim($crit), $reg); + if ($reg[1]) + { + $operator = $reg[1]; + } + if ($newcrit != '') + { + $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.price2num($newcrit); + $i2++; // a criteria was added to string + } + } + else + { + $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'"; + $i2++; // a criteria was added to string + } $i++; } - if ($end > 1) $res .= ')'; - if ($j < $end2 - 1) $res .= " AND "; - if ($end > 1 && $j < $end2 - 1) $res .= '('; + if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : ''); $j++; } - return " AND " . ($end > 1? '(' : '') . $res; + $res = " AND (" . $res . ")"; + //print 'xx'.$res.'yy'; + return $res; } From 9e4e9a54111ae543692a77d1eac08b58151bfac1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 20:59:18 +0100 Subject: [PATCH 123/133] NEW: Can search on customer order amount into customer order list. --- htdocs/comm/card.php | 2 +- htdocs/comm/propal/list.php | 10 +++++----- htdocs/commande/list.php | 18 ++++++++++++++---- htdocs/compta/facture.php | 4 ++-- htdocs/compta/facture/list.php | 16 ++++++++-------- htdocs/core/lib/functions.lib.php | 2 +- htdocs/fourn/commande/list.php | 14 +++++++------- htdocs/fourn/facture/list.php | 14 +++++++------- 8 files changed, 45 insertions(+), 35 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index ffc01a998d5..78b786d2366 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -400,7 +400,7 @@ if ($id > 0) // display amount and link to unpaid bill $outstandigBills = $object->get_OutstandingBill(); if ($outstandigBills != 0) - print " / ".price($outstandigBills).''; + print " (".$langs->trans("CurrentOutstandingBill")." ".price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency).')'; print ''; print ''; } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index a3ef72bb6ca..da6e56c9460 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -182,9 +182,9 @@ if ($search_author) { $sql.= " AND u.login LIKE '%".$db->escape(trim($search_author))."%'"; } -if ($search_montant_ht) +if ($search_montant_ht != '') { - $sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'"; + $sql.= natural_search("p.total_ht", $search_montant_ht, 1); } if ($sall) { $sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall); @@ -316,12 +316,12 @@ if ($result) print ''; print ''; // Amount - print ''; // Author print ''; print ''; - print ''; + print ''; print '\n"; @@ -328,7 +337,8 @@ if ($resql) $generic_commande = new Commande($db); $generic_product = new Product($db); - while ($i < min($num,$limit)) { + while ($i < min($num,$limit)) + { $objp = $db->fetch_object($resql); $var=!$var; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 4cb696836bd..d38519bf6d5 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1962,11 +1962,11 @@ if ($action == 'create') // Outstanding Bill $outstandigBills = $soc->get_OutstandingBill(); print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; - print price($outstandigBills, '', $langs, 0, 0, - 1, $conf->currency); + print price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency); if ($soc->outstanding_limit != '') { if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); - print ' / ' . price($soc->outstanding_limit); + print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency); } print ')'; print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 56bd57c725a..dc081424ace 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -187,13 +187,13 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } -if ($search_montant_ht) +if ($search_montant_ht != '') { - $sql.= ' AND f.total = \''.$db->escape(price2num(trim($search_montant_ht))).'\''; + $sql.= natural_search('f.total', $search_montant_ht, 1); } -if ($search_montant_ttc) +if ($search_montant_ttc != '') { - $sql.= ' AND f.total_ttc = \''.$db->escape(price2num(trim($search_montant_ttc))).'\''; + $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); } if ($search_status != '') { @@ -263,8 +263,8 @@ if ($resql) if ($search_societe) $param.='&search_societe=' .$search_societe; if ($search_sale > 0) $param.='&search_sale=' .$search_sale; if ($search_user > 0) $param.='&search_user=' .$search_user; - if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; - if ($search_montant_ttc) $param.='&search_montant_ttc='.$search_montant_ttc; + if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht; + if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); $i = 0; @@ -323,9 +323,9 @@ if ($resql) print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; } print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; } print ''; if (! empty($conf->stock->enabled)) { - print ''; + print ''; } else { From fc0be43f5f8e4d4ccb90077bddcd7501c6825220 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 22:40:41 +0100 Subject: [PATCH 125/133] Fix: beautify search box --- htdocs/product/stats/commande.php | 8 +++++--- htdocs/product/stats/commande_fournisseur.php | 8 +++++--- htdocs/product/stats/facture.php | 4 +++- htdocs/product/stats/facture_fournisseur.php | 4 +++- htdocs/product/stats/propal.php | 4 +++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 2ae1dcd1582..49a443938ab 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -141,9 +141,9 @@ if ($id > 0 || ! empty($ref)) $sql.= " AND d.fk_commande = c.rowid"; $sql.= " AND d.fk_product =".$product->id; if (! empty($search_month)) - $sql.= ' AND MONTH(f.datef) IN (' . $search_month . ')'; + $sql.= ' AND MONTH(c.date_commande) IN (' . $search_month . ')'; if (! empty($search_year)) - $sql.= ' AND YEAR(f.datef) IN (' . $search_year . ')'; + $sql.= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND c.fk_soc = ".$socid; $sql.= " ORDER BY $sortfield $sortorder "; @@ -189,12 +189,14 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("CustomersOrders"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,$totalrecords,''); print '
'; - print $langs->trans('Period').'('.$langs->trans("DateInvoice") .') '; + print $langs->trans('Period').' ('.$langs->trans("OrderDate") .') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'.$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 'tva_assuj == "0") echo '0'; - else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); - } + if ($seller->tva_assuj == "0") echo '0'; + else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); ?> - "> - - "> - "> @@ -273,7 +266,7 @@ else {
'; + print ''; print $linktoprod; print "
 '; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; print ''; $formpropal->selectProposalStatus($viewstatut,1); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9d143d87eb2..c38b1a8e34f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -51,6 +51,7 @@ $sall=GETPOST('sall'); $socid=GETPOST('socid','int'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); +$search_total_ht=GETPOST('search_total_ht','alpha'); // Security check $id = (GETPOST('orderid')?GETPOST('orderid'):GETPOST('id','int')); @@ -79,6 +80,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_ref=''; $search_ref_customer=''; $search_company=''; + $search_total_ht=''; $orderyear=''; $ordermonth=''; $deliverymonth=''; @@ -96,6 +98,7 @@ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + /* * View */ @@ -198,7 +201,10 @@ if ($search_user > 0) { $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; } - +if ($search_total_ht != '') +{ + $sql.= natural_search('c.total_ht', $search_total_ht, 1); +} $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; $nbtotalofrecords = 0; @@ -252,7 +258,8 @@ if ($resql) if ($search_ref_customer) $param.='&search_ref_customer='.$search_ref_customer; if ($search_user > 0) $param.='&search_user='.$search_user; if ($search_sale > 0) $param.='&search_sale='.$search_sale; - + if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht; + $num = $db->num_rows($resql); print_barre_liste($title, $page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); $i = 0; @@ -316,7 +323,9 @@ if ($resql) print ''; $formother->select_year($deliveryyear?$deliveryyear:-1,'deliveryyear',1, 20, 5); print ' '; + print ''; + print ''; print ''; print "
   '; print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c5d8d509b08..509f237b0d6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4961,7 +4961,7 @@ function natural_search($fields, $value, $numeric=0) if ($numeric) { - $value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do + $value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } $crits = explode(' ', $value); $res = ''; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 613eb463366..6926997f0f1 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -100,7 +100,7 @@ $offset = $conf->liste_limit * $page ; /* - * Mode Liste + * Mode list */ $sql = "SELECT s.rowid as socid, s.nom as name, cf.date_commande as dc,"; @@ -130,13 +130,13 @@ if ($search_user) { $sql.= " AND u.login LIKE '%".$db->escape($search_user)."%'"; } -if ($search_ht) +if ($search_ht != '') { - $sql .= " AND cf.total_ht = '".$db->escape(price2num($search_ht))."'"; + $sql .= natural_search("cf.total_ht",$search_ht, 1); } -if ($search_ttc) +if ($search_ttc != '') { - $sql .= " AND cf.total_ttc = '".$db->escape(price2num($search_ttc))."'"; + $sql .= natural_search("cf.total_ttc", $search_ttc, 1); } if ($sall) { @@ -214,8 +214,8 @@ if ($resql) print '  '; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index d59870d8fc5..66ad20e4c05 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -153,7 +153,7 @@ if ($search_ref) if (is_numeric($search_ref)) $sql .= natural_search(array('fac.ref'), $search_ref); else $sql .= natural_search('fac.ref', $search_ref); } -if (search_ref_supplier) +if ($search_ref_supplier) { $sql .= natural_search('fac.ref_supplier', $search_ref_supplier); } @@ -178,14 +178,14 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company); } -if ($search_amount_no_tax) +if ($search_amount_no_tax != '') { - $sql .= " AND fac.total_ht = '".$db->escape(price2num($search_amount_no_tax))."'"; + $sql .= natural_search('fac.total_ht', $search_amount_no_tax, 1); } -if ($search_amount_all_tax) +if ($search_amount_all_tax != '') { - $sql .= " AND fac.total_ttc = '".$db->escape(price2num($search_amount_all_tax))."'"; + $sql .= natural_search('fac.total_ttc', $search_amount_all_tax, 1); } $nbtotalofrecords = 0; @@ -270,9 +270,9 @@ if ($resql) print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $liststatus=array('paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid")); print $form->selectarray('filtre', $liststatus, $filter, 1); From c80007c6801840bc0cb2ba2179be92d922c19f08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 21:57:58 +0100 Subject: [PATCH 124/133] Fix: we must use stockreal of stockvirtual when we are speaking about stock ('stock' alone is not accurate enough) --- htdocs/expedition/shipment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index d5d82f2baa3..973066971a3 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -402,7 +402,7 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("KeepToShip").''.$langs->trans("Stock").''.$langs->trans("RealStock").'
'; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 3141b3266e9..8cbdea41495 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -150,9 +150,9 @@ if ($id > 0 || ! empty($ref)) { $sql .= " AND d.fk_commande = c.rowid"; $sql .= " AND d.fk_product =" . $product->id; if (! empty($search_month)) - $sql .= ' AND MONTH(f.datef) IN (' . $search_month . ')'; + $sql .= ' AND MONTH(c.date_commande) IN (' . $search_month . ')'; if (! empty($search_year)) - $sql .= ' AND YEAR(f.datef) IN (' . $search_year . ')'; + $sql .= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; if ($socid) @@ -199,12 +199,14 @@ if ($id > 0 || ! empty($ref)) { print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print '
'; - print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') '; + print $langs->trans('Period') . ' (' . $langs->trans("OrderDate") . ') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index b59bc008f17..2ae8164b0f9 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -190,12 +190,14 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&id=".$product->id,$sortfield,$sortorder,'',$num,$totalrecords,''); print '
'; - print $langs->trans('Period').'('.$langs->trans("DateInvoice") .') '; + print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 0feb415cc43..2e8e84621ba 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -191,12 +191,14 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print '
'; - print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') '; + print $langs->trans('Period') . ' (' . $langs->trans("DateInvoice") . ') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 50d7c952b6d..10fd8247204 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -192,12 +192,14 @@ if ($id > 0 || ! empty($ref)) print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); print '
'; - print $langs->trans('Period') . '(' . $langs->trans("DateInvoice") . ') '; + print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; print $langs->trans('Month') . ': '; print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; print ''; print ''; print '
'; + print '
'; $i = 0; print '
'; From 6db3f1b30ed294d0054d35830b64d64c3977745f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Mar 2015 19:06:56 +0100 Subject: [PATCH 126/133] Add mdule askpricesupplier into MAIN__MODULES_FOR_EXTERNAL --- htdocs/core/class/conf.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 67b5b8147d5..b6cc390ca33 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -452,7 +452,7 @@ class Conf $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024); // Define list of limited modules - if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. + if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,askpricesupplier,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. // Enable select2 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) $conf->global->MAIN_USE_JQUERY_MULTISELECT='select2'; From 56b5bfd25b63041cb8d0298b939da4721e5509a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2015 02:08:26 +0100 Subject: [PATCH 127/133] NEW: Implement option SUPPLIER_ORDER_USE_DISPATCH_STATUS to add a status into each dispathing line of supplier order to "verify" a reception is ok. Status of order can be set to "total/done" only if line is verified. --- htdocs/core/class/commonobject.class.php | 3 +- htdocs/core/class/html.formorder.class.php | 6 +- .../class/fournisseur.commande.class.php | 82 +++++++++++-- .../fournisseur.commande.dispatch.class.php | 18 +-- htdocs/fourn/commande/card.php | 25 ++-- htdocs/fourn/commande/dispatch.php | 113 +++++++++++++----- htdocs/fourn/commande/list.php | 10 +- htdocs/langs/en_US/errors.lang | 1 + htdocs/langs/en_US/main.lang | 2 + htdocs/langs/en_US/orders.lang | 1 + htdocs/theme/eldy/style.css.php | 9 ++ 11 files changed, 200 insertions(+), 70 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8ad8ecd2331..02ccd13b97c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2141,7 +2141,8 @@ abstract class CommonObject $fieldstatus="fk_statut"; if ($elementTable == 'user') $fieldstatus="statut"; if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts"; - + if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql.= " SET ".$fieldstatus." = ".$status; // If status = 1 = validated, update also fk_user_valid diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index 5ea5b33c1f4..2abc0c38485 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -57,11 +57,11 @@ class FormOrder { print ''; print ''; print ''; - if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) print ''; + if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) print ''; print "\n"; $var=false; @@ -553,6 +591,7 @@ if ($id > 0 || ! empty($ref)) while ($i < $num) { $objp = $db->fetch_object($resql); + print ""; print ''; - } + // Add button to check/uncheck disaptching + print ''; + } + print "\n"; $i++; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 6926997f0f1..7e525a9d080 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -45,7 +45,7 @@ $search_user=GETPOST('search_user'); $search_ht=GETPOST('search_ht'); $search_ttc=GETPOST('search_ttc'); $sall=GETPOST('search_all'); -$search_status=(GETPOST('search_status','int')!=''?GETPOST('search_status','int'):GETPOST('statut','int')); +$search_status=(GETPOST('search_status','alpha')!=''?GETPOST('search_status','alpha'):GETPOST('statut','alpha')); // alpha and not intbecause it can be '6,7' $page = GETPOST('page','int'); $socid = GETPOST('socid','int'); @@ -153,9 +153,9 @@ if ($search_refsupp) { $sql.= " AND (cf.ref_supplier LIKE '%".$db->escape($search_refsupp)."%')"; } -if ($search_status >= 0) +if ($search_status != '' && $search_status >= 0) { - if ($search_status == 6 || $search_status == 7) $sql.=" AND cf.fk_statut IN (6,7)"; + if (strstr($search_status, ',')) $sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")"; else $sql.=" AND cf.fk_statut = ".$search_status; } @@ -205,9 +205,9 @@ if ($resql) print ''; - print ''; + print ''; if (empty($conf->global->SUPPLIER_ORDER_HIDE_REF_SUPPLIER)) print ''; - print ''; + print ''; if (! empty($conf->global->PROJECT_SHOW_REF_INTO_LISTS)) { print ''; - print ''; + print ''; print ''; - print ''; + print ''; print "\n"; $i++; From 7c08f33fe184fbebcff5c87e74f5858f2849f051 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2015 02:26:41 +0100 Subject: [PATCH 129/133] Missing style buttonRefused --- htdocs/theme/amarok/style.css.php | 18 ++++++++++++++++++ htdocs/theme/auguria/style.css.php | 17 +++++++++++++++++ htdocs/theme/bureau2crea/style.css.php | 17 +++++++++++++++++ htdocs/theme/cameleo/style.css.php | 17 +++++++++++++++++ 4 files changed, 69 insertions(+) diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index bd41d0735a5..c7f3d27dcfb 100644 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -1125,6 +1125,24 @@ td.formdocbutton {padding-top:6px;} ); color:white; } +.button:disabled { + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + cursor: auto; +} +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} + /* ============================================================================== */ /* Tables */ diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index 35e0cdd36c9..7278521e092 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -184,6 +184,23 @@ legend { margin-bottom: 8px; } padding: 0px 2px 0px 2px; margin: 0px 0px 0px 0px; } +.button:disabled { + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + cursor: auto; +} +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} form { padding: 0em 0em 0em 0em; margin: 0em 0em 0em 0em; diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php index b720bd4a802..31071f0b10c 100644 --- a/htdocs/theme/bureau2crea/style.css.php +++ b/htdocs/theme/bureau2crea/style.css.php @@ -209,6 +209,23 @@ legend { margin-bottom: 8px; } padding: 0px 2px 0px 2px; margin: 0px 0px 0px 0px; } +.button:disabled { + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + cursor: auto; +} +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} form { padding: 0em 0em 0em 0em; margin: 0em 0em 0em 0em; diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php index a49ad6daaec..d09cb844b88 100644 --- a/htdocs/theme/cameleo/style.css.php +++ b/htdocs/theme/cameleo/style.css.php @@ -185,6 +185,23 @@ legend { margin-bottom: 8px; } padding: 0px 2px 0px 2px; margin: 0px 0px 0px 0px; } +.button:disabled { + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + cursor: auto; +} +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} form { padding: 0em 0em 0em 0em; margin: 0em 0em 0em 0em; From 3894a48ffdaba5acfff20e1c34e71b0c190f9289 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2015 02:37:25 +0100 Subject: [PATCH 130/133] Fix: bad CSS --- htdocs/compta/bank/index.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 050db37fefc..9c9f0574c31 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -174,7 +174,11 @@ foreach ($accounts as $key=>$type) $total[$acc->currency_code] += $solde; } } -if (! $found) print ''; +if (! $found) +{ + $var = !$var; + print ''; +} // Total foreach ($total as $key=>$solde) { From 90abe5cdf97afcc9124fc02019e8eac75eb2e546 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 09:29:24 +0100 Subject: [PATCH 131/133] NEW: Add current salary on list of payment --- htdocs/compta/salaries/index.php | 22 ++++++++++++++++------ htdocs/langs/en_US/salaries.lang | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 678b3bfaa2e..79d139255c2 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2011-2014 Alexandre Spangaro + * 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 @@ -82,7 +83,7 @@ $form = new Form($db); $salstatic = new PaymentSalary($db); $userstatic = new User($db); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.salary, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,"; @@ -93,7 +94,7 @@ $sql.= " AND s.entity = ".$conf->entity; // Search criteria if ($search_ref) $sql.=" AND s.rowid=".$search_ref; if ($search_label) $sql.=" AND s.label LIKE '%".$db->escape($search_label)."%'"; -if ($search_amount) $sql.=" AND s.amount='".$db->escape(price2num(trim($search_amount)))."'"; +if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1); if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; @@ -124,9 +125,10 @@ if ($result) print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CurrentSalary"),$_SERVER["PHP_SELF"],"u.salary","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datev","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre(""); print "\n"; @@ -136,6 +138,9 @@ if ($result) print ''; + // People + print ''; + // Current salary print ''; // Label print ''; @@ -161,8 +166,13 @@ if ($result) $userstatic->firstname=$obj->firstname; $salstatic->id=$obj->rowid; $salstatic->ref=$obj->rowid; - print "\n"; + // Ref + print "\n"; + // User name print "\n"; + // Current salary + print "\n"; + // Label payment print "\n"; print '\n"; // Type @@ -176,7 +186,7 @@ if ($result) $i++; } - print ''; + print ''; print '"; print ""; diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 0087cbe83e6..0f5f636a3f3 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -10,3 +10,4 @@ SalariesPayments=Salaries payments ShowSalaryPayment=Show salary payment THM=Average hourly price TJM=Average daily price +CurrentSalary=Current salary \ No newline at end of file From dc300922906d939c2a5aea5d02618c61d93fb28c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 10:11:51 +0100 Subject: [PATCH 132/133] Add column to store salary ref when doing payment. --- htdocs/compta/charges/index.php | 15 ++++++++------- htdocs/compta/salaries/card.php | 9 +++++++-- .../compta/salaries/class/paymentsalary.class.php | 4 +++- htdocs/compta/salaries/index.php | 9 +++++++-- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 2 ++ .../install/mysql/tables/llx_payment_salary.sql | 1 + 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index ca03e11bcba..eb10fce7768 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -93,9 +93,10 @@ if ($conf->salaries->enabled) print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); - $sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql.= " WHERE s.entity = ".$conf->entity; + $sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm, s.salary, u.salary as current_salary"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE s.entity IN (".getEntity('user',1).")"; + $sql.= " AND u.rowid = s.fk_user"; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, @@ -132,11 +133,11 @@ if ($conf->salaries->enabled) print "\n"; - print '"; + print '"; // Ref payment - $sal_static->id=$obj->rowid; - $sal_static->ref=$obj->rowid; + $sal_static->id=$obj->rowid; + $sal_static->ref=$obj->rowid; print '\n"; print '\n"; @@ -146,7 +147,7 @@ if ($conf->salaries->enabled) $i++; } print ''; - print '"; + print '"; print ''; print ''; print '"; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 49c3192fa7f..3bd93659b5e 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -67,8 +67,8 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]); $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); - $sal->accountid=GETPOST("accountid"); - $sal->fk_user=GETPOST("fk_user"); + $sal->accountid=GETPOST("accountid","int"); + $sal->fk_user=GETPOST("fk_user","int"); $sal->datev=$datev; $sal->datep=$datep; $sal->amount=price2num(GETPOST("amount")); @@ -80,6 +80,11 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $sal->num_payment=GETPOST("num_payment"); $sal->fk_user_creat=$user->id; + // Set user current salary as ref salaray for the payment + $fuser=new User($db); + $fuser->fetch(GETPOST("fk_user","int")); + $sal->salary=$fuser->salary; + if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 83a1c937545..f566123809c 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -324,6 +324,7 @@ class PaymentSalary extends CommonObject $sql.= ", datep"; $sql.= ", datev"; $sql.= ", amount"; + $sql.= ", salary"; $sql.= ", fk_typepayment"; $sql.= ", num_payment"; if ($this->note) $sql.= ", note"; @@ -338,7 +339,8 @@ class PaymentSalary extends CommonObject $sql.= "'".$this->fk_user."'"; $sql.= ", '".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", '".$this->amount."'"; + $sql.= ", ".$this->amount; + $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); $sql.= ", '".$this->type_payment."'"; $sql.= ", '".$this->num_payment."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 79d139255c2..484010c9f03 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -83,7 +83,8 @@ $form = new Form($db); $salstatic = new PaymentSalary($db); $userstatic = new User($db); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.salary, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_societe as fk_soc,"; +$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,"; @@ -125,7 +126,7 @@ if ($result) print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("CurrentSalary"),$_SERVER["PHP_SELF"],"u.salary","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.salary","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datev","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); @@ -164,6 +165,10 @@ if ($result) $userstatic->id=$obj->uid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->admin=$obj->admin; + $userstatic->login=$obj->login; + $userstatic->email=$obj->email; + $userstatic->societe_id=$obj->fk_soc; $salstatic->id=$obj->rowid; $salstatic->ref=$obj->rowid; // Ref 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 2a36ef78737..2de1556ed3e 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,8 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +ALTER TABLE llx_payment_salary ADD COLUMN salary real after datev; + 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; diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index b82ff66ecc1..2498c771ba6 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -23,6 +23,7 @@ create table llx_payment_salary fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur + salary real, -- salary of user when payment was done amount real NOT NULL DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), From 35dfaf4dd14e0575bef702073e8b84bcbbfbe5ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Mar 2015 10:14:24 +0100 Subject: [PATCH 133/133] Natural search on numeric works also with several space after operator --- htdocs/core/lib/functions.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 509f237b0d6..d7fc398e082 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4949,7 +4949,7 @@ function dol_getmypid() * Generate natural SQL search string * * @param string|string[] $fields String or array of strings, filled with the name of fields in the SQL query - * @param string $value The value to look for. + * @param string $value The value to look for. * If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2 * If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000" * @param string $number 0=value is list of keywords, 1=value is a numeric test @@ -4958,10 +4958,10 @@ function dol_getmypid() function natural_search($fields, $value, $numeric=0) { global $db,$langs; - + if ($numeric) { - $value=preg_replace('/([<>=]+)\s([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do + $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } $crits = explode(' ', $value); $res = ''; @@ -4970,19 +4970,19 @@ function natural_search($fields, $value, $numeric=0) $nboffields = count($fields); $end2 = count($crits); $j = 0; - foreach ($crits as $crit) + foreach ($crits as $crit) { $i = 0; $i2 = 0; $newres = ''; - foreach ($fields as $field) + foreach ($fields as $field) { - if ($numeric) + if ($numeric) { $operator='='; $newcrit = preg_replace('/([<>=]+)/','',trim($crit)); - + preg_match('/([<>=]+)/',trim($crit), $reg); - if ($reg[1]) + if ($reg[1]) { $operator = $reg[1]; } @@ -4992,7 +4992,7 @@ function natural_search($fields, $value, $numeric=0) $i2++; // a criteria was added to string } } - else + else { $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'"; $i2++; // a criteria was added to string
'.$langs->trans("Warehouse").''.$langs->trans("Comment").''.$langs->trans("Status").''.$langs->trans("Status").'
'; print ''.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.''; @@ -588,8 +627,22 @@ if ($id > 0 || ! empty($ref)) //print $supplierorderdispatch->status; print $supplierorderdispatch->getLibStatut(5); print ''; + $disabled=''; + if ($commande->statut == 5) $disabled=1; + if (empty($objp->status)) + { + print 'dispatchlineid.'">'.$langs->trans("Check").''; + } + else + { + print 'dispatchlineid.'">'.$langs->trans("Uncheck").''; + } + print '
'; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index be75e3a96a3..3d83901194b 100755 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -160,6 +160,7 @@ ErrorPriceExpressionInternal=Internal error '%s' ErrorPriceExpressionUnknown=Unknown error '%s' ErrorSrcAndTargetWarehouseMustDiffers=Source and target warehouses must differs ErrorTryToMakeMoveOnProductRequiringBatchData=Error, trying to make a stock movement without batch/serial information, on a product requiring batch/serial information +ErrorCantSetReceptionToTotalDoneWithReceptionToApprove=All recorded receptions must first be verified before being allowed to do this action # Warnings WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index be893d52569..551807aad59 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -159,6 +159,7 @@ Search=Search SearchOf=Search Valid=Valid Approve=Approve +Disapprove=Disapprove ReOpen=Re-Open Upload=Send file ToLink=Link @@ -524,6 +525,7 @@ DateFromTo=From %s to %s DateFrom=From %s DateUntil=Until %s Check=Check +Uncheck=Uncheck Internal=Internal External=External Internals=Internal diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 4f6e0b0dfb2..ea3659b90de 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -42,6 +42,7 @@ StatusOrderCanceled=Canceled StatusOrderDraft=Draft (needs to be validated) StatusOrderValidated=Validated StatusOrderOnProcess=Ordered - Standby reception +StatusOrderOnProcessWithValidation=Ordered - Standby reception or validation StatusOrderProcessed=Processed StatusOrderToBill=Delivered StatusOrderToBill2=To bill diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ccf54a6f9b5..206b1df019e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -361,6 +361,15 @@ fieldset { border: 1px solid #AAAAAA !important; box-shadow: 2px 2px 3px #DDD; } -moz-box-shadow: none; cursor: auto; } +.buttonRefused { + pointer-events: none; + cursor: default; + opacity: 0.4; + filter: alpha(opacity=40); /* For IE8 and earlier */ + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} form { padding:0px; margin:0px; From 3e4845635962e323eb9d61ff53e54b1875dee8fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2015 02:13:47 +0100 Subject: [PATCH 128/133] Fix when no price defined, we must how nothing instead of 0 --- htdocs/fourn/product/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index afaf4c8e796..33e1ea46dd9 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -125,7 +125,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } -$sql .= " ORDER BY ".$sortfield." ".$sortorder; +$sql .= $db->order($sortfield,$sortorder); $sql .= $db->plimit($limit + 1, $offset); dol_syslog("fourn/product/list.php:", LOG_DEBUG); @@ -225,11 +225,11 @@ if ($resql) if ($companystatic->id > 0) print $companystatic->getNomUrl(1,'supplier'); print ''.price($objp->price).''.(isset($objp->price) ? price($objp->price) : '').''.$objp->qty.''.price($objp->unitprice).''.(isset($objp->unitprice) ? price($objp->unitprice) : '').'
'.$langs->trans("None").'
'.$langs->trans("None").'
'; print ''; print '  ".$salstatic->getNomUrl(1)."".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".($obj->salary?price($obj->salary):'')."".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->dm),'day')."
'.$langs->trans("Total").'
'.$langs->trans("Total").''.price($total,0,$outputlangs,1,-1,-1,$conf->currency)." 
".$obj->label."'.price($obj->amount)."'.($obj->salary?price($obj->salary):'')."'.$sal_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm),'day')."
'.$langs->trans("Total").''.price($total)."'."  '.price($total)."