diff --git a/ChangeLog b/ChangeLog index 8a80591f652..e516382f62f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,9 +8,12 @@ For Users: NEW: Stable module: Website NEW: Stable module: WebDAV NEW: Stable module: Module Builder -NEW: Stable module "Skype" has been replaced with module "Social Networks" to support more tools. +NEW: Stable module "Skype" has been replaced with module "Social Networks" to support more tools. +NEW: Experimental module "TakePos" NEW: Dolibarr can provide information in page title when multicompany is enabled of not, making Android application like DoliDroid able to provide native features for multicompany module. +NEW: Compatibility with PHP 7.3 + For developers: * Code changes to be more compatible with PSR2 diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 3d3c8fb6e54..fd465dd1803 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -622,8 +622,9 @@ if (empty($reshook)) // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "members")); - // Get email content fro mtemplae + // Get email content from template $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION; @@ -693,8 +694,9 @@ if (empty($reshook)) // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "members")); - // Get email content fro mtemplae + // Get email content from template $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION; @@ -1384,6 +1386,7 @@ else // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage=null; @@ -1444,8 +1447,9 @@ else // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "members")); - // Get email content fro mtemplae + // Get email content from template $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index f3e4e4d0df8..a4e80d3b626 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2628,6 +2628,7 @@ class Adherent extends CommonObject // Send reminder email $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "members")); dol_syslog("sendReminderForExpiredSubscription Language set to ".$outputlangs->defaultlang); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a9d7fd7ead3..dffd1446af0 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -56,8 +56,10 @@ class AdherentType extends CommonObject */ public $libelle; - /** @var string Label */ - public $label; + /** + * @var string Adherent type label + */ + public $label; /** * @var int Subsription required (0 or 1) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 7b90878dff7..51e1a8b244e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -582,7 +582,7 @@ if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titr if (! empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'],$_SERVER["PHP_SELF"],'d.address','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'],$_SERVER["PHP_SELF"],'d.zip','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'],$_SERVER["PHP_SELF"],'d.town','',$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.town']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'],$_SERVER["PHP_SELF"],'d.phone','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'],$_SERVER["PHP_SELF"],'d.phone_perso','',$param,'',$sortfield,$sortorder); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 78a7ce8495f..08c3c3c87f5 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -359,8 +359,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "members")); - // Get email content fro mtemplae + // Get email content from template $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; @@ -1053,8 +1054,9 @@ if ($rowid > 0) // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "members")); - // Get email content fro mtemplae + // Get email content from template $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 0f1f88f8c42..e3ea95d18b5 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -328,20 +328,20 @@ if ($action == 'edit' || $action == 'updateedit') // Name print ''; - print ''."\n"; + print ''."\n"; // Addresse print ''; - print ''."\n"; + print ''."\n"; print ''; - print ''."\n"; + print ''."\n"; print ''; - print ''."\n"; + print ''."\n"; // Country @@ -363,29 +363,29 @@ if ($action == 'edit' || $action == 'updateedit') print ''; - print ''; + print ''; print ''."\n"; print ''; - print ''; + print ''; print ''."\n"; print ''; - print ''; + print ''; print ''."\n"; // Web print ''; - print ''; + print ''; print ''."\n"; // Barcode if (! empty($conf->barcode->enabled)) { print ''; - print ''; + print ''; print ''; } @@ -424,19 +424,19 @@ if ($action == 'edit' || $action == 'updateedit') // Managing Director(s) print ''; - print ''; + print ''; // GDPR contact print ''; print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc")); print ''; - print ''; + print ''; // Capital print ''; - print ''; + print ''; // Juridical Status @@ -455,7 +455,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -471,7 +471,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -487,7 +487,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -503,7 +503,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -519,7 +519,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -535,7 +535,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -547,7 +547,7 @@ if ($action == 'edit' || $action == 'updateedit') // TVA Intra print ''; - print ''; + print ''; print ''; // Object of the company diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 984ddfbefd7..4d75ab44235 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2018 Laurent Destailleur * Copyright (C) 2017-2018 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,13 @@ */ /** - * \file htdocs/admin/defaultvalues.php - * \brief Page to set default values used used in a create form + * \file htdocs/admin/defaultvalues.php + * \brief Page to set default values used used in a create form + * Default values are stored into $user->default_values[url]['createform']['querystring'|'_noquery_'][paramkey]=paramvalue + * Default filters are stored into $user->default_values[url]['filters']['querystring'|'_noquery_'][paramkey]=paramvalue + * Default sort order are stored into $user->default_values[url]['sortorder']['querystring'|'_noquery_'][paramkey]=paramvalue + * Default focus are stored into $user->default_values[url]['focus']['querystring'|'_noquery_'][paramkey]=paramvalue + * Mandatory fields are stored into $user->default_values[url]['mandatory']['querystring'|'_noquery_'][paramkey]=paramvalue */ require '../main.inc.php'; @@ -230,9 +235,9 @@ if ($mode == 'sortorder') { print info_admin($langs->trans("WarningSettingSortOrder")).'
'; } -if ($mode == 'focus') +if ($mode == 'mandatory') { - print info_admin($langs->trans("FeatureNotYetAvailable")).'
'; + print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'
'; } print ''; @@ -261,7 +266,7 @@ else } print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder); // Value -if ($mode != 'focus') +if ($mode != 'focus' && $mode != 'mandatory') { if ($mode != 'sortorder') { @@ -294,14 +299,14 @@ print "\n"; print ''; // Page print ''; -print ''; +print ''; print ''."\n"; // Field print ''; -print ''; +print ''; print ''; // Value -if ($mode != 'focus') +if ($mode != 'focus' && $mode != 'mandatory') { print ''; print ''; @@ -311,15 +316,16 @@ if ($mode != 'focus') if (! empty($conf->multicompany->enabled) && !$user->entity) { print ''; - print ''; + print ''; // We see environment, but to change it we must switch on other entity print ''; - print ''; } else { print ''; print ''; + print ''; } +print ''; $disabled=''; if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled=' disabled="disabled"'; print ''; @@ -363,7 +369,7 @@ if ($result) print ''."\n"; // Value - if ($mode != 'focus') + if ($mode != 'focus' && $mode != 'mandatory') { print ''; /*print ''; @@ -376,6 +382,9 @@ if ($result) print ''; } + // Multicompany + print ''; + // Actions print ''; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index e0f3f72f927..970971c8d29 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -242,10 +242,10 @@ if ($resql) { $obj = $db->fetch_object($resql); - preg_match('/^([0-9]+)/i',$obj->note,$reg); + preg_match('/^([0-9]+)/i',$obj->note,$reg); $idrss = $reg[1]; - $keyrssurl="EXTERNAL_RSS_URLRSS_".$idrss; - $keyrsstitle="EXTERNAL_RSS_URLRSS_".$idrss; + $keyrsstitle="EXTERNAL_RSS_TITLE_".$idrss; + $keyrssurl="EXTERNAL_RSS_URLRSS_".$idrss; //print "x".$idrss; $rssparser=new RssParser($db); diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index b1732e0883b..643269bfacd 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -96,7 +96,7 @@ $usefilter=0; $listofsessions=listOfSessions(); $num=count($listofsessions); -print_barre_liste($langs->trans("Sessions"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'setup'); +print_barre_liste($langs->trans("Sessions"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'', $num, ($num?$num:''),'setup'); // Do not show numer (0) if no session found (it means we can't know) $savehandler=ini_get("session.save_handler"); $savepath=ini_get("session.save_path"); diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index dbd472af1d3..8aee71b4926 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -108,17 +108,17 @@ class Asset extends CommonObject public $entity; - /** - * @var string Asset label - */ - public $label; + /** + * @var string Asset label + */ + public $label; public $amount; /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; /** * @var string description diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index df2f4c1415e..f1c6f9d771b 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -46,8 +46,10 @@ class AssetType extends CommonObject public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - /** @var string Label */ - public $label; + /** + * @var string Asset type label + */ + public $label; /** @var string Accountancy code asset */ public $accountancy_code_asset; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index cba114714e6..b87c1b0c066 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -993,7 +993,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && (! 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)); setEventMessages($mesg, null, 'errors'); } else { @@ -1057,7 +1057,7 @@ if (empty($reshook)) } // Update a line within proposal - else if ($action == 'updateligne' && $usercancreate && GETPOST('save')) + else if ($action == 'updateline' && $usercancreate && GETPOST('save')) { // Define info_bits $info_bits = 0; @@ -1112,8 +1112,7 @@ if (empty($reshook)) $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))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error ++; } @@ -1194,7 +1193,7 @@ if (empty($reshook)) } } - else if ($action == 'updateligne' && $usercancreate && GETPOST('cancel','alpha')) + else if ($action == 'updateline' && $usercancreate && GETPOST('cancel','alpha')) { header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition exit(); @@ -2284,7 +2283,7 @@ if ($action == 'create') print '
- + '; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2160e77cc2d..263a425ff01 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1620,6 +1620,7 @@ class Propal extends CommonObject $line->product_type = $objp->product_type; $line->label = $objp->custom_label; $line->desc = $objp->description; // Description ligne + $line->description = $objp->description; // Description ligne $line->qty = $objp->qty; $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; @@ -3550,103 +3551,13 @@ class Propal extends CommonObject } /** - * Retrieve an array of propal lines + * Retrieve an array of proposal lines * * @return int >0 if OK, <0 if KO */ function getLinesArray() { return $this->fetch_lines(); - /* - $this->lines = array(); - - $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; - $sql.= ' pt.qty, pt.vat_src_code, pt.tva_tx, pt.localtax1_tx, pt.localtax2_tx, pt.localtax1_type, pt.localtax2_type, pt.remise_percent, pt.subprice, pt.info_bits,'; - $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.total_localtax1, pt.total_localtax2, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code,'; - $sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,'; - $sql.= ' pt.fk_unit,'; - $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.description as product_desc, p.tobatch as product_tobatch,'; - $sql.= ' p.entity,'; - $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc'; - $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]->desc = $obj->description; - $this->lines[$i]->description = $obj->description; - $this->lines[$i]->fk_product = $obj->fk_product; - $this->lines[$i]->ref = $obj->ref; - $this->lines[$i]->product_ref = $obj->ref; - $this->lines[$i]->entity = $obj->entity; // Product entity - $this->lines[$i]->product_label = $obj->product_label; - $this->lines[$i]->product_desc = $obj->product_desc; - $this->lines[$i]->product_tobatch = $obj->product_tobatch; - $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]->vat_src_code = $obj->vat_src_code; - $this->lines[$i]->tva_tx = $obj->tva_tx; - $this->lines[$i]->localtax1_tx = $obj->localtax1_tx; - $this->lines[$i]->localtax2_tx = $obj->localtax2_tx; - $this->lines[$i]->localtax1_type = $obj->localtax1_type; - $this->lines[$i]->localtax2_type = $obj->localtax2_type; - $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]->total_localtax1 = $obj->total_localtax1; - $this->lines[$i]->total_localtax2 = $obj->total_localtax2; - $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); - $this->lines[$i]->fk_unit = $obj->fk_unit; - - // Multicurrency - $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; - $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; - $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; - $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - - $i++; - } - $this->db->free($resql); - - return 1; - } - else - { - $this->error=$this->db->error(); - return -1; - }*/ } /** diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ced62e9d27a..75b949ff203 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -931,7 +931,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! 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)); setEventMessages($mesg, null, 'errors'); } else { @@ -1052,7 +1052,7 @@ if (empty($reshook)) $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))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c45067740af..b9d19ba5b64 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -59,7 +59,7 @@ class Account extends CommonObject public $rowid; /** - * Label + * Account Label * @var string */ public $label; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 1f01355050c..0794634e3a3 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -1,6 +1,4 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin @@ -428,7 +426,7 @@ foreach ($accounts as $key=>$type) // Ref if (! empty($arrayfields['b.ref']['checked'])) { - print ''.$obj->getNomUrl(1).''; + print ''.$obj->getNomUrl(1).''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index 2a4af918234..9e00bf10ae0 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -1,7 +1,6 @@ - - * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2017 Pierre-Henry Favre * * This program is free software; you can redistribute it and/or modify @@ -18,9 +17,9 @@ * along with this program. If not, see . */ /** - * \file htdocs/compta/recap-compta.php - * \ingroup compta - * \brief Page de fiche recap customer + * \file htdocs/compta/compta-files.php + * \ingroup compta + * \brief Page to show portoflio and files of a thirdparty and download it */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -30,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; + restrictedArea($user,'banque'); + $langs->load("companies"); if (! empty($conf->facture->enabled)) $langs->load("bills"); $date_start =GETPOST('date_start','alpha'); @@ -67,15 +68,22 @@ $arrayfields=array( 'date'=>array('label'=>"Date", 'checked'=>1), //... ); + + /* * Actions */ + //$parameters = array('socid' => $id); //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks //if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + + /* - * Fetch the lines/files from db / + * View */ + $filesarray=array(); $result=false; if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f1419f83e45..4d538bfc68b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -954,6 +954,8 @@ if (empty($reshook)) if($facture_source->type == Facture::TYPE_SITUATION) { + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // Credit note line need to be linked to the situation invoice it is create from if(!empty($facture_source->tab_previous_situation_invoice)) { @@ -977,7 +979,7 @@ if (empty($reshook)) $maxPrevSituationPercent = 0; foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if($prevLine->id == $line->fk_prev_id) + if($prevLine->id == $source_fk_prev_id) { $maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent); @@ -1535,6 +1537,7 @@ if (empty($reshook)) $line->origin = $object->origin; $line->origin_id = $line->id; $line->fetch_optionals($line->id); + $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée if ($line->fk_remise_except) @@ -1960,7 +1963,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! 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)); setEventMessages($mesg, null, 'errors'); } else { @@ -2032,7 +2035,7 @@ if (empty($reshook)) } } - elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) + elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) { if (! $object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); @@ -2123,7 +2126,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -2255,7 +2258,7 @@ if (empty($reshook)) } } - else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { + else if ($action == 'updateline' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -4511,7 +4514,7 @@ else if ($id > 0 || ! empty($ref)) print ' - + '; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3ab5d84bfdb..048f686df3b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1253,12 +1253,14 @@ class Facture extends CommonInvoice if ($addlinktonotes) { - $txttoshow=($user->societe_id>0?$this->note_public:$this->note_private); + $txttoshow=($user->socid > 0 ? $this->note_public : $this->note_private); if ($txttoshow) { $notetoshow=$langs->trans("ViewPrivateNote").':
'.dol_string_nohtmltag($txttoshow,1); $result.=' '; - $result.=''.img_picto('','object_generic').''; + $result.=''; + $result.=img_picto('','note'); + $result.=''; //$result.=img_picto($langs->trans("ViewNote"),'object_generic'); //$result.=''; $result.=''; @@ -4913,9 +4915,10 @@ class FactureLigne extends CommonInvoiceLine * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. * * @param int $invoiceid Invoice id + * @param bool $include_credit_note Include credit note or not * @return int >= 0 */ - function get_prev_progress($invoiceid) + function get_prev_progress($invoiceid, $include_credit_note=true) { // phpcs:enable if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { @@ -4930,7 +4933,26 @@ class FactureLigne extends CommonInvoiceLine $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { $res = $this->db->fetch_array($resql); - return floatval($res['situation_percent']); + + $returnPercent = floatval($res['situation_percent']); + + if($include_credit_note) { + + $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd'; + $sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) '; + $sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id; + $sql.= ' AND f.situation_cycle_ref = '.$tmpinvoice->situation_cycle_ref; // Prevent cycle outed + $sql.= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; + + $res = $this->db->query($sql); + if($res) { + while($obj = $this->db->fetch_object($res)) { + $returnPercent = $returnPercent + floatval($obj->situation_percent); + } + } + } + + return $returnPercent; } else { $this->error = $this->db->error(); dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 3fa091e0665..a8eadd76a93 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -664,7 +664,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! 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)); setEventMessages($mesg, null, 'errors'); @@ -744,7 +744,7 @@ if (empty($reshook)) } } - elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) + elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) { if (! $object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); @@ -831,7 +831,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error ++; @@ -1626,7 +1626,7 @@ else // Lines print ' - + '; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 72cfa38e8c2..2e5cb83883f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -904,7 +904,7 @@ if ($resql) $projectstatic=new Project($db); $discount = new DiscountAbsolute($db); - + if ($num > 0) { $i=0; @@ -914,6 +914,7 @@ if ($resql) $obj = $db->fetch_object($resql); $datelimit=$db->jdate($obj->datelimite); + $facturestatic->id=$obj->id; $facturestatic->ref=$obj->ref; $facturestatic->type=$obj->type; @@ -957,12 +958,10 @@ if ($resql) print ''; - print ''; - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } // Zip diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index a2c937abc0a..0c0247dc7fa 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -566,7 +566,7 @@ if (empty($reshook)) $info_bits=0; if ($tva_npr) $info_bits |= 0x01; - if($price_min && (price2num($pu_ht)*(1-price2num($remise_percent)/100) < price2num($price_min))) + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& ($price_min && (price2num($pu_ht)*(1-price2num($remise_percent)/100) < price2num($price_min)))) { $object->error = $langs->trans("CantBeLessThanMinPrice",price(price2num($price_min,'MU'),0,$langs,0,0,-1,$conf->currency)); $result = -1 ; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e76c7c34376..26641f1b602 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1710,7 +1710,7 @@ class Contrat extends CommonObject else { $this->db->rollback(); - dol_syslog(get_class($this)."::updateligne Erreur -2"); + dol_syslog(get_class($this)."::updateline Erreur -2"); return -2; } } @@ -1718,7 +1718,7 @@ class Contrat extends CommonObject { $this->db->rollback(); $this->error=$this->db->error(); - dol_syslog(get_class($this)."::updateligne Erreur -1"); + dol_syslog(get_class($this)."::updateline Erreur -1"); return -1; } } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index e616afefd99..3331a7718fd 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -622,7 +622,7 @@ while ($i < min($num,$limit)) if (!empty($obj->note_private) || !empty($obj->note_public)) { print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; + print ''.img_picto($langs->trans("ViewPrivateNote"),'note').''; print ''; } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index d1a46e4d0b9..7562cd609c2 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -389,13 +389,17 @@ class CMailFile // TODO if (! empty($moreinheader)) ... // Give the message a subject - $this->message->setSubject($this->encodetorfc2822($subject)); + try { + $result = $this->message->setSubject($subject); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } // Set the From address with an associative array //$this->message->setFrom(array('john@doe.com' => 'John Doe')); if (! empty($from)) { try { - $this->message->setFrom($this->getArrayAddress($from)); + $result = $this->message->setFrom($this->getArrayAddress($from)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } @@ -404,7 +408,7 @@ class CMailFile // Set the To addresses with an associative array if (! empty($to)) { try { - $this->message->setTo($this->getArrayAddress($to)); + $result = $this->message->setTo($this->getArrayAddress($to)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } @@ -412,13 +416,17 @@ class CMailFile if (! empty($replyto)) { try { - $this->message->SetReplyTo($this->getArrayAddress($replyto)); + $result = $this->message->SetReplyTo($this->getArrayAddress($replyto)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } } - $this->message->setCharSet($conf->file->character_set_client); + try { + $result = $this->message->setCharSet($conf->file->character_set_client); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } if (! empty($this->html)) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8f7366541e3..a11cd3dd49e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -976,7 +976,7 @@ abstract class CommonObject * @param string $source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) * @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) - * @return array Array of contacts + * @return array|int Array of contacts, -1 if error */ function liste_contact($statut=-1,$source='external',$list=0,$code='') { @@ -2930,7 +2930,9 @@ abstract class CommonObject } /** - * Fetch array of objects linked to current object. Links are loaded into this->linkedObjects array and this->linkedObjectsIds + * Fetch array of objects linked to current object (object of enabled modules only). Links are loaded into + * this->linkedObjectsIds array and + * this->linkedObjects array if $loadalsoobjects = 1 * Possible usage for parameters: * - all parameters empty -> we look all link to current object (current object can be source or target) * - source id+type -> will get target list linked to source @@ -2938,17 +2940,18 @@ abstract class CommonObject * - source id+type + target type -> will get target list of the type * - target id+type + target source -> will get source list of the type * - * @param int $sourceid Object source id (if not defined, id of object) - * @param string $sourcetype Object source type (if not defined, element name of object) - * @param int $targetid Object target id (if not defined, id of object) - * @param string $targettype Object target type (if not defined, elemennt name of object) - * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided - * @param int $alsosametype 0=Return only links to object that differs from source. 1=Include also link to objects of same type. - * @param string $orderby SQL 'ORDER BY' clause - * @return int <0 if KO, >0 if OK + * @param int $sourceid Object source id (if not defined, id of object) + * @param string $sourcetype Object source type (if not defined, element name of object) + * @param int $targetid Object target id (if not defined, id of object) + * @param string $targettype Object target type (if not defined, elemennt name of object) + * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided + * @param int $alsosametype 0=Return only links to object that differs from source type. 1=Include also link to objects of same type. + * @param string $orderby SQL 'ORDER BY' clause + * @param int $loadalsoobjects Load also array this->linkedObjects (Use 0 to increase performances) + * @return int <0 if KO, >0 if OK * @see add_object_linked, updateObjectLinked, deleteObjectLinked */ - function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1,$orderby='sourcetype') + function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1,$orderby='sourcetype',$loadalsoobjects=1) { global $conf; @@ -2977,10 +2980,10 @@ abstract class CommonObject $targettype = (! empty($targettype) ? $targettype : $this->element); /*if (empty($sourceid) && empty($targetid)) - { - dol_syslog('Bad usage of function. No source nor target id defined (nor as parameter nor as object id)', LOG_ERR); - return -1; - }*/ + { + dol_syslog('Bad usage of function. No source nor target id defined (nor as parameter nor as object id)', LOG_ERR); + return -1; + }*/ // Links between objects are stored in table element_element $sql = 'SELECT rowid, fk_source, sourcetype, fk_target, targettype'; @@ -3042,7 +3045,8 @@ abstract class CommonObject if (! empty($this->linkedObjectsIds)) { - foreach($this->linkedObjectsIds as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) + $tmparray = $this->linkedObjectsIds; + foreach($tmparray as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) { // Parse element/subelement (ex: project_task, cabinetmed_consultation, ...) $module = $element = $subelement = $objecttype; @@ -3108,21 +3112,28 @@ abstract class CommonObject // Here $module, $classfile and $classname are set if ($conf->$module->enabled && (($element != $this->element) || $alsosametype)) { - dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); - //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); - if (class_exists($classname)) + if ($loadalsoobjects) { - foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element + dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); + //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); + if (class_exists($classname)) { - $object = new $classname($this->db); - $ret = $object->fetch($objectid); - if ($ret >= 0) + foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element { - $this->linkedObjects[$objecttype][$i] = $object; + $object = new $classname($this->db); + $ret = $object->fetch($objectid); + if ($ret >= 0) + { + $this->linkedObjects[$objecttype][$i] = $object; + } } } } } + else + { + unset($this->linkedObjectsIds[$objecttype]); + } } } return 1; @@ -5260,37 +5271,34 @@ abstract class CommonObject $val=$this->fields[$key]; $out=''; - $type=''; - $param['options']=array(); - $size =$this->fields[$key]['size']; - // Because we work on extrafields - if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ - $param['options']=array($reg[1].':'.$reg[2]=>'N'); - $type ='link'; - }else if(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)){ - $param['options']=array($reg[1].':'.$reg[2]=>'N'); - $type ='link'; - }else if(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){ - - $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); - $type ='sellist'; - }else if(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)){ - - $param['options']=array(); - $type ='varchar'; - $size=$reg[1]; - }else if(preg_match('/varchar/', $val['type'])){ - - $param['options']=array(); - $type ='varchar'; - }else if(is_array($this->fields[$key]['arrayofkeyval'])){ - - $param['options']=$this->fields[$key]['arrayofkeyval']; - $type ='select'; - }else { - $param['options']=array(); - $type =$this->fields[$key]['type']; - } + $type=''; + $param = array(); + $param['options']=array(); + $size =$this->fields[$key]['size']; + // Because we work on extrafields + if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[1].':'.$reg[2]=>'N'); + $type ='link'; + } elseif(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)) { + $param['options']=array($reg[1].':'.$reg[2]=>'N'); + $type ='link'; + } elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); + $type ='sellist'; + } elseif(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)) { + $param['options']=array(); + $type ='varchar'; + $size=$reg[1]; + } elseif(preg_match('/varchar/', $val['type'])) { + $param['options']=array(); + $type ='varchar'; + } elseif(is_array($this->fields[$key]['arrayofkeyval'])) { + $param['options']=$this->fields[$key]['arrayofkeyval']; + $type ='select'; + } else { + $param['options']=array(); + $type =$this->fields[$key]['type']; + } $label=$this->fields[$key]['label']; //$elementtype=$this->fields[$key]['elementtype']; // Seems not used diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 5289ed882ff..d5bf6f3317e 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -1,10 +1,10 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2006-2013 Laurent Destailleur - * Copyright (C) 2015 Francis Appels + * Copyright (C) 2015 Francis Appels * * 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 @@ -218,26 +218,26 @@ abstract class CommonStickerGenerator $pdf->SetDrawColor(0,0,0); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * protected Convert units (in to mm, mm to in) + * Convert units (in to mm, mm to in) * $src and $dest must be 'in' or 'mm' * * @param int $value value - * @param string $src from - * @param string $dest to + * @param string $src from ('in' or 'mm') + * @param string $dest to ('in' or 'mm') * @return float value value after conversion */ - function _Convert_Metric($value, $src, $dest) + private function convertMetric($value, $src, $dest) { - // phpcs:enable if ($src != $dest) { - $tab['in'] = 39.37008; - $tab['mm'] = 1000; + $tab = array( + 'in'=>39.37008, + 'mm'=>1000 + ); return $value * $tab[$dest] / $tab[$src]; - } else { - return $value; } + + return $value; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps @@ -273,14 +273,14 @@ abstract class CommonStickerGenerator $this->_Metric = $format['metric']; $this->_Avery_Name = $format['name']; $this->_Avery_Code = $format['code']; - $this->_Margin_Left = $this->_Convert_Metric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc); - $this->_Margin_Top = $this->_Convert_Metric($format['marginTop'], $this->_Metric, $this->_Metric_Doc); - $this->_X_Space = $this->_Convert_Metric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc); - $this->_Y_Space = $this->_Convert_Metric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc); + $this->_Margin_Left = $this->convertMetric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc); + $this->_Margin_Top = $this->convertMetric($format['marginTop'], $this->_Metric, $this->_Metric_Doc); + $this->_X_Space = $this->convertMetric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc); + $this->_Y_Space = $this->convertMetric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc); $this->_X_Number = $format['NX']; $this->_Y_Number = $format['NY']; - $this->_Width = $this->_Convert_Metric($format['width'], $this->_Metric, $this->_Metric_Doc); - $this->_Height = $this->_Convert_Metric($format['height'], $this->_Metric, $this->_Metric_Doc); + $this->_Width = $this->convertMetric($format['width'], $this->_Metric, $this->_Metric_Doc); + $this->_Height = $this->convertMetric($format['height'], $this->_Metric, $this->_Metric_Doc); $this->Set_Char_Size($pdf, $format['font-size']); } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index d2bf33b5461..c5304fec31c 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -99,7 +99,11 @@ class EmailSenderProfile extends CommonObject */ public $entity; - public $label; + /** + * @var string Email Sender Profile label + */ + public $label; + public $email; public $date_creation; public $tms; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 149f1681725..cee64d930cc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3422,7 +3422,7 @@ class Form if ($obj->situation_final != 1) { //Not prov? if (substr($obj->facnumber, 1, 4) != 'PROV') { - if ($selected == $obj->situation_final) { + if ($selected == $obj->rowid) { $opt .= ''; } else { $opt .= ''; diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 4532a7a294a..bad8d7ffdca 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -763,7 +763,7 @@ function xml2php($xml) } //Let see if the new child is not in the array - if ($tab==false && in_array($key,array_keys($array))) + if ($tab === false && in_array($key,array_keys($array))) { //If this element is already in the array we will create an indexed array $tmp = $array[$key]; @@ -772,7 +772,7 @@ function xml2php($xml) $array[$key][] = $child; $tab = true; } - elseif($tab == true) + elseif($tab === true) { //Add an element in an existing array $array[$key][] = $child; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index c900a30ea18..4014adfc272 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -729,6 +729,11 @@ function defaultvalues_prepare_head() $head[$h][2] = 'focus'; $h++; + $head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=mandatory"; + $head[$h][1] = $langs->trans("DefaultMandatory"); + $head[$h][2] = 'mandatory'; + $h++; + /*$head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=searchkey"; $head[$h][1] = $langs->trans("TranslationKeySearch"); $head[$h][2] = 'searchkey'; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 1b10f6d4233..8f01ea6aebe 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -923,41 +923,41 @@ function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $ha * This replace old function monthArrayOrSelected. * * @param Translate $outputlangs Object langs - * @param int $short 1=Return short label + * @param int $short 0=Return long label, 1=Return short label * @return array Month string or array if selected < 0 */ function monthArray($outputlangs,$short=0) { $montharray = array ( - 1 => $outputlangs->trans("January"), - 2 => $outputlangs->trans("February"), - 3 => $outputlangs->trans("March"), - 4 => $outputlangs->trans("April"), - 5 => $outputlangs->trans("May"), - 6 => $outputlangs->trans("June"), - 7 => $outputlangs->trans("July"), - 8 => $outputlangs->trans("August"), - 9 => $outputlangs->trans("September"), - 10 => $outputlangs->trans("October"), - 11 => $outputlangs->trans("November"), - 12 => $outputlangs->trans("December") + 1 => $outputlangs->trans("Month01"), + 2 => $outputlangs->trans("Month02"), + 3 => $outputlangs->trans("Month03"), + 4 => $outputlangs->trans("Month04"), + 5 => $outputlangs->trans("Month05"), + 6 => $outputlangs->trans("Month06"), + 7 => $outputlangs->trans("Month07"), + 8 => $outputlangs->trans("Month08"), + 9 => $outputlangs->trans("Month09"), + 10 => $outputlangs->trans("Month10"), + 11 => $outputlangs->trans("Month11"), + 12 => $outputlangs->trans("Month12") ); if (! empty($short)) { $montharray = array ( - 1 => $outputlangs->trans("JanuaryMin"), - 2 => $outputlangs->trans("FebruaryMin"), - 3 => $outputlangs->trans("MarchMin"), - 4 => $outputlangs->trans("AprilMin"), - 5 => $outputlangs->trans("MayMin"), - 6 => $outputlangs->trans("JuneMin"), - 7 => $outputlangs->trans("JulyMin"), - 8 => $outputlangs->trans("AugustMin"), - 9 => $outputlangs->trans("SeptemberMin"), - 10 => $outputlangs->trans("OctoberMin"), - 11 => $outputlangs->trans("NovemberMin"), - 12 => $outputlangs->trans("DecemberMin") + 1 => $outputlangs->trans("MonthShort01"), + 2 => $outputlangs->trans("MonthShort02"), + 3 => $outputlangs->trans("MonthShort03"), + 4 => $outputlangs->trans("MonthShort04"), + 5 => $outputlangs->trans("MonthShort05"), + 6 => $outputlangs->trans("MonthShort06"), + 7 => $outputlangs->trans("MonthShort07"), + 8 => $outputlangs->trans("MonthShort08"), + 9 => $outputlangs->trans("MonthShort09"), + 10 => $outputlangs->trans("MonthShort10"), + 11 => $outputlangs->trans("MonthShort11"), + 12 => $outputlangs->trans("MonthShort12") ); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8b7e4b70c63..b2b8aee122c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -430,7 +430,7 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu } elseif (isset($user->default_values[$relativepathstring]['filters'])) { - foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) + foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) // $defkey is a querystring like 'a=b&c=d', $defval is key of user { $qualified = 0; if ($defkey != '_noquery_') @@ -586,7 +586,6 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu // Save data into session if key start with 'search_' or is 'smonth', 'syear', 'month', 'year' if (empty($method) || $method == 3 || $method == 4) { - //if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder', 'sortfield", 'smonth', 'syear', 'month', 'year'))) if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder','sortfield'))) { //var_dump($paramname.' - '.$out.' '.$user->default_values[$relativepathstring]['filters'][$paramname]); @@ -595,8 +594,7 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu // - posted value not empty, or // - if posted value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not). - //if (! empty($out) || ! empty($user->default_values[$relativepathstring]['filters'][$paramname])) - if ($out != '') // $out = '0' like 'abc' is a search criteria to keep + if ($out != '') // $out = '0' or 'abc', it is a search criteria to keep { $user->lastsearch_values_tmp[$relativepathstring][$paramname]=$out; } @@ -3152,8 +3150,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithoutext, array( - 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', - 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow') + 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', + 'note','switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow') )) { $fakey = $pictowithoutext; $facolor = ''; $fasize = ''; @@ -3197,6 +3195,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithoutext == 'grip_title' || $pictowithoutext == 'grip') { $fakey = 'fa-arrows'; } + elseif ($pictowithoutext == 'listlight') { + $fakey = 'fa-download'; + $facolor = '#999'; + $marginleftonlyshort=1; + } elseif ($pictowithoutext == 'printer') { $fakey = 'fa-print'; $fasize = '1.2em'; @@ -3206,6 +3209,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-crop'; $facolor = '#444'; } + elseif ($pictowithoutext == 'note') { + $fakey = 'fa-sticky-note-o'; + $facolor = '#999'; + $marginleftonlyshort=1; + } elseif ($pictowithoutext == 'uparrow') { $fakey = 'fa-mail-forward'; $facolor = '#555'; @@ -4257,7 +4265,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so // Left //if ($picto && $titre) print ''; print ''; @@ -7025,7 +7033,8 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= */ function printCommonFooter($zone='private') { - global $conf, $hookmanager; + global $conf, $hookmanager, $user; + global $action; global $micro_start_time; if ($zone == 'private') print "\n".''."\n"; @@ -7058,7 +7067,71 @@ function printCommonFooter($zone='private') print '});'."\n"; } - // Google Analytics (need Google module) + // Management of focus and mandatory for fields + if ($action == 'create' || $action == 'edit') + { + print '/* Code js to manage focus and mandatory form fields */'."\n"; + $relativepathstring = $_SERVER["PHP_SELF"]; + // Clean $relativepathstring + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + foreach($user->default_values[$relativepathstring]['focus'] as $defkey => $defval) + { + $qualified = 0; + if ($defkey != '_noquery_') + { + $tmpqueryarraytohave=explode('&', $defkey); + $foundintru=0; + foreach($tmpqueryarraytohave as $tmpquerytohave) + { + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + } + if (! $foundintru) $qualified=1; + //var_dump($defkey.'-'.$qualified); + } + else $qualified = 1; + + if ($qualified) + { + foreach($defval as $paramkey => $paramval) + { + // Add property 'required' on input + print 'jQuery("input[name=\''.$paramkey.'\']").focus();'."\n"; + } + } + } + foreach($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) + { + $qualified = 0; + if ($defkey != '_noquery_') + { + $tmpqueryarraytohave=explode('&', $defkey); + $foundintru=0; + foreach($tmpqueryarraytohave as $tmpquerytohave) + { + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + } + if (! $foundintru) $qualified=1; + //var_dump($defkey.'-'.$qualified); + } + else $qualified = 1; + + if ($qualified) + { + foreach($defval as $paramkey => $paramval) + { + // Add property 'required' on input + print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; + print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; // required on a select works only if key is "", this does not happen in Dolibarr + } + } + } + } + + // Google Analytics + // TODO Add a hook here if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID)) { if (($conf->dol_use_jmobile != 4)) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 57bb32ef1a3..1cce7527018 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -172,7 +172,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -213,7 +213,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -320,7 +320,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -361,7 +361,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -465,7 +465,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = -1"; $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; $sql.= " ORDER BY e.rowid"; if (! $sql) @@ -641,7 +641,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -682,7 +682,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -789,7 +789,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -830,7 +830,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -934,7 +934,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = -1"; $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; $sql.= " ORDER BY e.rowid"; if (! $sql) diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index f62b699b4ef..9b49be6063f 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -114,7 +114,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc // 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'; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); if (! empty($conf->bank->dir_output)) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index e0c82446962..d3b5d12d620 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -224,7 +224,7 @@ class pdf_einstein extends ModelePDFCommandes // 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'; - // Translations + // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); $nblignes = count($object->lines); @@ -1239,7 +1239,7 @@ class pdf_einstein extends ModelePDFCommandes { global $conf,$langs,$hookmanager; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 8a3fdd53ebc..f70514b2912 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -216,6 +216,7 @@ class doc_generic_contract_odt extends ModelePDFContract $sav_charset_output=$outputlangs->charset_output; $outputlangs->charset_output='UTF-8'; + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->contrat->dir_output) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index c7c393c96e3..fe0a79c6c8e 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -180,7 +180,7 @@ class pdf_strato extends ModelePDFContract // 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'; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "companies", "contracts")); if ($conf->contrat->dir_output) @@ -542,7 +542,7 @@ class pdf_strato extends ModelePDFContract $default_font_size = pdf_getPDFFontSize($outputlangs); - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "contract", "companies")); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 3890c03ba62..8f6c10119c4 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -83,6 +83,7 @@ class html_cerfafr extends ModeleDon if (! is_object($outputlangs)) $outputlangs=$langs; + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations")); $currency = !empty($currency) ? $currency : $conf->currency; diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 5a128ec99d3..38696cb3cc2 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -227,6 +227,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $sav_charset_output=$outputlangs->charset_output; $outputlangs->charset_output='UTF-8'; + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->expedition->dir_output."/sending") diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 68f6f544fc4..3d786bf111d 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -165,7 +165,7 @@ class pdf_merou extends ModelePdfExpedition // 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'; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); if ($conf->expedition->dir_output) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 678c5d5da7e..5c663e61348 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -196,7 +196,7 @@ class pdf_rouget extends ModelePdfExpedition // 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'; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); $nblignes = count($object->lines); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 28f36a406e0..f05c19885da 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -211,7 +211,7 @@ class pdf_standard extends ModeleExpenseReport // 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'; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "trips", "projects", "dict")); $nblignes = count($object->lines); @@ -568,9 +568,9 @@ class pdf_standard extends ModeleExpenseReport */ function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "trips", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index c99da970a6b..af770999fda 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -239,7 +239,7 @@ class pdf_crabe extends ModelePDFFactures // 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'; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); $nblignes = count($object->lines); @@ -1574,7 +1574,7 @@ class pdf_crabe extends ModelePDFFactures { global $conf, $langs; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "bills", "propal", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 7dc4f0594ab..b67da288ae7 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -172,7 +172,7 @@ class pdf_soleil extends ModelePDFFicheinter // 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'; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "interventions", "dict", "companies")); if ($conf->ficheinter->dir_output) diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 3227c75b3af..4793ebe7b27 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -195,7 +195,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder // 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'; - // Translations + // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "sendings", "deliveries")); if ($conf->expedition->dir_output) diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 2b33e09c1ac..79495595774 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -81,7 +81,6 @@ class modCashDesk extends DolibarrModules // Permissions $this->rights = array(); - $this->rights_class = 'cashdesk'; $r=0; $r++; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index ab62edc00f6..15b34dfbeac 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -133,6 +133,13 @@ class modProduct extends DolibarrModules $this->rights[$r][4] = 'export'; $r++; + $this->rights[$r][0] = 39; + $this->rights[$r][1] = 'Ignore minimum price'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'ignore_price_min_advance'; + $r++; + // Menus //------- diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php new file mode 100644 index 00000000000..4603ba74c04 --- /dev/null +++ b/htdocs/core/modules/modTakePos.class.php @@ -0,0 +1,326 @@ + + * Copyright (C) 2018 SuperAdmin + * + * 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 takepos Module TakePos + * \brief TakePos module descriptor. + * + * \file htdocs/takepos/core/modules/modTakePos.class.php + * \ingroup takepos + * \brief Description and activation file for module TakePos + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Class to describe and enable module TakePos + */ +class modTakePos extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs,$conf; + + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 50150; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'takepos'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' + // It is used to group modules by family in module setup page + $this->family = "portal"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '90'; + // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + + // Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module). + $this->name = preg_replace('/^mod/i','',get_class($this)); + // Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module). + $this->description = "Point of sales module (Touch Screen POS)"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "Point Of Sales (compliant with touch screen)"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = 'experimental'; + // Key used in llx_const table to save module status enabled/disabled (where TAKEPOS is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='list'; + + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) + // for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable) + // for specific path of parts (eg: /takepos/core/modules/barcode) + // for specific css file (eg: /takepos/css/takepos.css.php) + $this->module_parts = array( + 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) + 'login' => 0, // Set this to 1 if module has its own login method file (core/login) + 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) + 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) + 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) + 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) + 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) + 'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' + ); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/takepos/temp","/takepos/subdir"); + $this->dirs = array(); + + // Config pages. Put here list of php page, stored into takepos/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@takepos"); + + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'always'=>'modCategorie', 'FR'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->langfiles = array("cashdesk"); + $this->phpmin = array(5,43); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('TAKEPOS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('TAKEPOS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array( + //1=>array('TAKEPOS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); + + + if (! isset($conf->takepos) || ! isset($conf->takepos->enabled)) + { + $conf->takepos=new stdClass(); + $conf->takepos->enabled=0; + } + + + // Array to add new pages in new tabs + $this->tabs = array(); + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@takepos:$user->rights->takepos->read:/takepos/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@takepos:$user->rights->othermodule->read:/takepos/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // + // Where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + + + // Dictionaries + $this->dictionaries=array(); + /* Example: + $this->dictionaries=array( + 'langs'=>'mylangfile@takepos', + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor + 'tablib'=>array("Table1","Table2","Table3"), // Label of tables + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order + 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) + 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') + 'tabcond'=>array($conf->takepos->enabled,$conf->takepos->enabled,$conf->takepos->enabled) // Condition to show each dictionary + ); + */ + + + // Boxes/Widgets + // Add here list of php file(s) stored in takepos/core/boxes that contains class to show a widget. + $this->boxes = array( + //0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'), + //1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'), + //2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos') + ); + + + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + //0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/takepos/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true) + ); + // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) + // ); + + + // Permissions + $this->rights = array(); // Permission array used by this module + + /*$r=0; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read myobject of TakePos'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2) + + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update myobject of TakePos'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2) + + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete myobject of TakePos'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->takepos->level1->level2) + */ + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + + // Add here entries to declare new menus + + /* BEGIN MODULEBUILDER TOPMENU */ + $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'top', // This is a Top menu entry + 'titre'=>'PointOfSale', + 'mainmenu'=>'takepos', + 'leftmenu'=>'', + 'url'=>'/takepos/takepos.php', + 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. + 'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules + 'target'=>'takepos', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + + /* END MODULEBUILDER TOPMENU */ + + /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT + $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=takepos', // '' if this is a top menu. For left menu, 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'=>'List MyObject', + 'mainmenu'=>'takepos', + 'leftmenu'=>'takepos_myobject_list', + 'url'=>'/takepos/myobject_list.php', + 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=takepos,fk_leftmenu=takepos', // '' if this is a top menu. For left menu, 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'=>'New MyObject', + 'mainmenu'=>'takepos', + 'leftmenu'=>'takepos_myobject_new', + 'url'=>'/takepos/myobject_page.php?action=create', + 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + END MODULEBUILDER LEFTMENU MYOBJECT */ + + + // Exports + $r=1; + + /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ + /* + $langs->load("cashdesk"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='myobject@takepos'; + $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; + $r++; */ + /* END MODULEBUILDER EXPORT MYOBJECT */ + } + + /** + * 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 + */ + public function init($options='') + { + $this->_load_tables('/takepos/sql/'); + + $sql = array(); + + // Remove permissions and default values + $this->remove($options); + + 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 + */ + public function remove($options = '') + { + $sql = array(); + + return $this->_remove($sql, $options); + } +} diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 1ee00f486e5..82b33d35240 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -240,6 +240,7 @@ class doc_generic_product_odt extends ModelePDFProduct $sav_charset_output=$outputlangs->charset_output; $outputlangs->charset_output='UTF-8'; + // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->produit->dir_output) diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 941ebb4db3e..7df62bec482 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -445,6 +445,7 @@ class doc_generic_task_odt extends ModelePDFTask $sav_charset_output=$outputlangs->charset_output; $outputlangs->charset_output='UTF-8'; + // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); if ($conf->projet->dir_output) diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index d914f6953ae..c18950a87d1 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -122,24 +122,22 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode $return='000001'; - $field='';$where=''; - if ($type == 0) - { + $field=''; + $where=''; + $prefix = ''; + if ($type == 0) { $field = 'code_client'; + $prefix = $this->prefixcustomer; //$where = ' AND client in (1,2)'; - } - else if ($type == 1) - { + } elseif ($type == 1) { $field = 'code_fournisseur'; + $prefix = $this->prefixsupplier; //$where = ' AND fournisseur = 1'; - } - else return -1; + } else { + return -1; + } - - if ($type == 0) $prefix=$this->prefixcustomer; - if ($type == 1) $prefix=$this->prefixsupplier; - - // D'abord on recupere la valeur max (reponse immediate car champ indexe) + // D'abord on recupere la valeur max (reponse immediate car champ indexe) $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."societe"; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index c20e57f2d5c..31097dd8c34 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -214,7 +214,7 @@ class pdf_aurore extends ModelePDFSupplierProposal // 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'; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal")); $nblignes = count($object->lines); @@ -1280,9 +1280,9 @@ class pdf_aurore extends ModelePDFSupplierProposal */ function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs; + global $conf, $langs; - // Translations + // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "bills", "supplier_proposal", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index b6dd2a2873b..a8170935eb0 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -33,12 +33,12 @@ class mod_ticket_universal extends ModeleNumRefTicket * Dolibarr version of the loaded document * @public string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) */ - public $error = ''; + public $error = ''; /** * @var string Nom du modele diff --git a/htdocs/core/tpl/bloc_showhide.tpl.php b/htdocs/core/tpl/bloc_showhide.tpl.php index 2fe6204f3b9..3f9c1eb0a1d 100644 --- a/htdocs/core/tpl/bloc_showhide.tpl.php +++ b/htdocs/core/tpl/bloc_showhide.tpl.php @@ -1,6 +1,7 @@ - * Copyright (C) 2013 Laurent Destailleur +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Laurent Destailleur + * Copyright (C) 2018 Frédéric 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 @@ -42,7 +43,7 @@ print '});'."\n"; print '$("#show-'.$blocname.'").click(function(){'."\n"; print ' setShowHide(1);'."\n"; -print ' $("#'.$blocname.'").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n"; +print ' $("#'.$blocname.'_bloc").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n"; print ' $(this).hide();'."\n"; print ' $("#hide-'.$blocname.'").show();'."\n"; print '});'."\n"; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index b6f11828ffe..4a4301c5a5f 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -74,6 +74,7 @@ if ($action == 'presend') { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($newlang); + // Load traductions files requiredby by page $outputlangs->loadLangs(array('commercial','bills','orders','contracts','members','propal','products','supplier_proposal','interventions')); } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 88ac2ee98bb..0a5f3bc43bd 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -259,9 +259,9 @@ if (!empty($extrafieldsline)) '.$line->product_label.''; + } + } + foreach ($invoice->lines as $line){ + if ($line->special_code=="3") continue; + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter2, $existing); + $count=count($result); + if ($count>0){ + $sql="UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid"; + $db->query($sql); + $order_receipt_printer2.=''.$line->product_label.''; + } + } + $invoice->fetch($placeid); +} + +?> + + +'; +print '
'; + print ''; print $facturestatic->getNomUrl(1,'',200,0,'',0,1); print empty($obj->increment)?'':' ('.$obj->increment.')'; - print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->id; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b60fdd8886b..04132fa9b75 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -732,7 +732,7 @@ while ($i < min($num,$limit)) // Job position if (! empty($arrayfields['p.poste']['checked'])) { - print ''.dol_trunc($obj->poste,20).''.$obj->poste.''.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).''; - if ($picto && $titre) print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh widthpictotitle" id="pictotitle"', $pictoisfullpath); + if ($picto && $titre) print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath); print '
'.$titre; if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') print ' ('.$totalnboflines.')'; print '
trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:''); - print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start?0:1, "updateligne", 1, 0); + print $form->selectDate($line->date_start, 'date_start', $hourmin, $hourmin, $line->date_start?0:1, "updateline", 1, 0); print ' '.$langs->trans('to').' '; - print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end?0:1, "updateligne", 1, 0); + print $form->selectDate($line->date_end, 'date_end', $hourmin, $hourmin, $line->date_end?0:1, "updateline", 1, 0); print ' + societe_id) $socid=$user->societe_id; +$result = restrictedArea($user,'societe',$socid,''); + +$search_all=trim(GETPOST('search_all', 'alphanohtml')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars + +$search_id=trim(GETPOST("search_id","int")); +$search_nom=trim(GETPOST("search_nom")); +$search_alias=trim(GETPOST("search_alias")); +$search_nom_only=trim(GETPOST("search_nom_only")); +$search_barcode=trim(GETPOST("search_barcode")); +$search_customer_code=trim(GETPOST('search_customer_code')); +$search_supplier_code=trim(GETPOST('search_supplier_code')); +$search_account_customer_code=trim(GETPOST('search_account_customer_code')); +$search_account_supplier_code=trim(GETPOST('search_account_supplier_code')); +$search_town=trim(GETPOST("search_town")); +$search_zip=trim(GETPOST("search_zip")); +$search_state=trim(GETPOST("search_state")); +$search_region=trim(GETPOST("search_region")); +$search_email=trim(GETPOST('search_email')); +$search_phone=trim(GETPOST('search_phone')); +$search_url=trim(GETPOST('search_url')); +$search_idprof1=trim(GETPOST('search_idprof1')); +$search_idprof2=trim(GETPOST('search_idprof2')); +$search_idprof3=trim(GETPOST('search_idprof3')); +$search_idprof4=trim(GETPOST('search_idprof4')); +$search_idprof5=trim(GETPOST('search_idprof5')); +$search_idprof6=trim(GETPOST('search_idprof6')); +$search_vat=trim(GETPOST('search_vat')); +$search_sale=trim(GETPOST("search_sale",'int')); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); +$search_categ_sup=trim(GETPOST("search_categ_sup",'int')); +$search_country=GETPOST("search_country",'intcomma'); +$search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); +$search_status=GETPOST("search_status",'int'); +$search_type=GETPOST('search_type','alpha'); +$search_level_from = GETPOST("search_level_from","alpha"); +$search_level_to = GETPOST("search_level_to","alpha"); +$search_stcomm=GETPOST('search_stcomm','int'); +$search_import_key = GETPOST("search_import_key","alpha"); + +$type=GETPOST('type'); +$optioncss=GETPOST('optioncss','alpha'); +$mode=GETPOST("mode"); + +$diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id; + +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield=GETPOST("sortfield",'alpha'); +$sortorder=GETPOST("sortorder",'alpha'); +$page=GETPOST("page",'int'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="s.nom"; +if (empty($page) || $page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$contextpage='thirdpartylist'; +/*if ($search_type == '1,3') { $contextpage='customerlist'; $type='c'; } +if ($search_type == '2,3') { $contextpage='prospectlist'; $type='p'; } +if ($search_type == '4') { $contextpage='supplierlist'; $type='f'; } +*/ +if ($type == 'c') { $contextpage='customerlist'; if ($search_type=='') $search_type='1,3'; } +if ($type == 'p') { $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; } +if ($type == 'f') { $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; } + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array($contextpage)); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('societe'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 's.nom'=>"ThirdPartyName", + 's.name_alias'=>"AliasNameShort", + 's.code_client'=>"CustomerCode", + 's.code_fournisseur'=>"SupplierCode", + 's.code_compta'=>"CustomerAccountancyCodeShort", + 's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort", + 's.email'=>"EMail", + 's.url'=>"URL", + 's.tva_intra'=>"VATIntra", + 's.siren'=>"ProfId1", + 's.siret'=>"ProfId2", + 's.ape'=>"ProfId3", +); +if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4'; +if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5'; +if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6']='ProfId6'; +if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod'; + +// Define list of fields to show into list +$checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0); +$checkedsuppliercode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); +$checkedcustomeraccountcode=(in_array($contextpage, array('customerlist')) ? 1 : 0); +$checkedsupplieraccountcode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); +$checkedtypetiers=1; +$checkedprofid1=0; +$checkedprofid2=0; +$checkedprofid3=0; +$checkedprofid4=0; +$checkedprofid5=0; +$checkedprofid6=0; +//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); +//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); +//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); +$checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0); +$checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0); +$arrayfields=array( + 's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)), + 's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), + 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), + 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode), + 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode), + 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.town'=>array('label'=>"Town", 'checked'=>1), + 's.zip'=>array('label'=>"Zip", 'checked'=>1), + 'state.nom'=>array('label'=>"State", 'checked'=>0), + 'region.nom'=>array('label'=>"Region", 'checked'=>0), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), + 's.email'=>array('label'=>"Email", 'checked'=>0), + 's.url'=>array('label'=>"Url", 'checked'=>0), + 's.phone'=>array('label'=>"Phone", 'checked'=>1), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), + 's.siren'=>array('label'=>"ProfId1Short", 'checked'=>$checkedprofid1), + 's.siret'=>array('label'=>"ProfId2Short", 'checked'=>$checkedprofid2), + 's.ape'=>array('label'=>"ProfId3Short", 'checked'=>$checkedprofid3), + 's.idprof4'=>array('label'=>"ProfId4Short", 'checked'=>$checkedprofid4), + 's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5), + 's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6), + 's.tva_intra'=>array('label'=>"VATIntra", 'checked'=>0), + 'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1), + 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel), + 's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm), + 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + 's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + 's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), + 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + } +} + +$object = new Societe($db); + + +/* + * Actions + */ + +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$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)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Did we click on purge search criteria ? + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + $search_id=''; + $search_nom=''; + $search_alias=''; + $search_categ_cus=0; + $search_categ_sup=0; + $search_sale=''; + $search_barcode=""; + $search_customer_code=''; + $search_supplier_code=''; + $search_account_customer_code=''; + $search_account_supplier_code=''; + $search_town=""; + $search_zip=""; + $search_state=""; + $search_country=''; + $search_email=''; + $search_phone=''; + $search_url=''; + $search_idprof1=''; + $search_idprof2=''; + $search_idprof3=''; + $search_idprof4=''; + $search_idprof5=''; + $search_idprof6=''; + $search_vat=''; + $search_type=''; + $search_type_thirdparty=''; + $search_status=-1; + $search_stcomm=''; + $search_level_from=''; + $search_level_to=''; + $search_import_key=''; + $toselect=''; + $search_array_options=array(); + } + + // Mass actions + $objectclass='Societe'; + $objectlabel='ThirdParty'; + $permtoread = $user->rights->societe->lire; + $permtodelete = $user->rights->societe->supprimer; + $uploaddir = $conf->societe->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + if ($action == 'setstcomm') + { + $object = new Client($db); + $result=$object->fetch(GETPOST('stcommsocid')); + $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); + $result=$object->update($object->id, $user); + if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); + + $action=''; + } +} + +if ($search_status=='') $search_status=1; // always display active thirdparty first + + + +/* + * View + */ + +/* + REM: Rules on permissions to see thirdparties + Internal or External user + No permission to see customers => See nothing + Internal user socid=0 + Permission to see ALL customers => See all thirdparties + Internal user socid=0 + No permission to see ALL customers => See only thirdparties linked to user that are sale representative + External user socid=x + Permission to see ALL customers => Can see only himself + External user socid=x + No permission to see ALL customers => Can see only himself + */ + +$form=new Form($db); +$formother=new FormOther($db); +$companystatic=new Societe($db); +$formcompany=new FormCompany($db); +$prospectstatic=new Client($db); +$prospectstatic->client=2; +$prospectstatic->loadCacheOfProspStatus(); + + +$title=$langs->trans("ListOfThirdParties"); +if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers"); +if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title=$langs->trans("ListOfProspects"); +if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title=$langs->trans("ListOfSuppliers"); + +// If both parameters are set, search for everything BETWEEN them +if ($search_level_from != '' && $search_level_to != '') +{ + // Ensure that these parameters are numbers + $search_level_from = (int) $search_level_from; + $search_level_to = (int) $search_level_to; + + // If from is greater than to, reverse orders + if ($search_level_from > $search_level_to) + { + $tmp = $search_level_to; + $search_level_to = $search_level_from; + $search_level_from = $tmp; + } + + // Generate the SQL request + $sortwhere = '(sortorder BETWEEN '.$search_level_from.' AND '.$search_level_to.') AS is_in_range'; +} +// If only "from" parameter is set, search for everything GREATER THAN it +else if ($search_level_from != '') +{ + // Ensure that this parameter is a number + $search_level_from = (int) $search_level_from; + + // Generate the SQL request + $sortwhere = '(sortorder >= '.$search_level_from.') AS is_in_range'; +} +// If only "to" parameter is set, search for everything LOWER THAN it +else if ($search_level_to != '') +{ + // Ensure that this parameter is a number + $search_level_to = (int) $search_level_to; + + // Generate the SQL request + $sortwhere = '(sortorder <= '.$search_level_to.') AS is_in_range'; +} +// If no parameters are set, dont search for anything +else +{ + $sortwhere = '0 as is_in_range'; +} + +// Select every potentiels, and note each potentiels which fit in search parameters +dol_syslog('societe/list.php',LOG_DEBUG); +$sql = "SELECT code, label, sortorder, ".$sortwhere; +$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; +$sql.= " WHERE active > 0"; +$sql.= " ORDER BY sortorder"; + +$resql = $db->query($sql); +if ($resql) +{ + $tab_level = array(); + $search_levels = array(); + + while ($obj = $db->fetch_object($resql)) + { + // Compute level text + $level=$langs->trans($obj->code); + if ($level == $obj->code) $level=$langs->trans($obj->label); + + // Put it in the array sorted by sortorder + $tab_level[$obj->sortorder] = $level; + + // If this potentiel fit in parameters, add its code to the $search_levels array + if ($obj->is_in_range == 1) + { + $search_levels[] = '"'.preg_replace('[^A-Za-z0-9_-]', '', $obj->code).'"'; + } + } + + // Implode the $search_levels array so that it can be use in a "IN (...)" where clause. + // If no paramters was set, $search_levels will be empty + $search_levels = implode(',', $search_levels); +} +else dol_print_error($db); + +$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; +$sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; +$sql.= " s.email, s.phone, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; +$sql.= " s.tms as date_update, s.datec as date_creation,"; +$sql.= " s.code_compta,s.code_compta_fournisseur,"; +$sql.= " typent.code as typent_code,"; +$sql.= " state.code_departement as state_code, state.nom as state_name,"; +$sql.= " region.code_region as region_code, region.nom as region_name"; +// We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) +if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; +// We'll need these fields in order to filter by categ +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; +if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc"; +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)"; +// We'll need this table joined to the select in order to filter by categ +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ +$sql.= " ,".MAIN_DB_PREFIX."c_stcomm as st"; +// We'll need this table joined to the select in order to filter by sale +if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE s.fk_stcomm = st.id"; +$sql.= " AND s.entity IN (".getEntity('societe').")"; +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; +if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale +if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible +if ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale); +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_sup > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_sup); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; +if ($search_categ_sup == -2) $sql.= " AND cs.fk_categorie IS NULL"; + +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if (strlen($search_cti)) $sql.= natural_search('s.phone', $search_cti); + +if ($search_id > 0) $sql.= natural_search("s.rowid",$search_id,1); +if ($search_nom) $sql.= natural_search("s.nom",$search_nom); +if ($search_alias) $sql.= natural_search("s.name_alias",$search_alias); +if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only); +if ($search_customer_code) $sql.= natural_search("s.code_client",$search_customer_code); +if ($search_supplier_code) $sql.= natural_search("s.code_fournisseur",$search_supplier_code); +if ($search_account_customer_code) $sql.= natural_search("s.code_compta",$search_account_customer_code); +if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fournisseur",$search_account_supplier_code); +if ($search_town) $sql.= natural_search("s.town",$search_town); +if (strlen($search_zip)) $sql.= natural_search("s.zip",$search_zip); +if ($search_state) $sql.= natural_search("state.nom",$search_state); +if ($search_region) $sql.= natural_search("region.nom",$search_region); +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_email) $sql.= natural_search("s.email",$search_email); +if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone); +if ($search_url) $sql.= natural_search("s.url",$search_url); +if (strlen($search_idprof1)) $sql.= natural_search("s.siren",$search_idprof1); +if (strlen($search_idprof2)) $sql.= natural_search("s.siret",$search_idprof2); +if (strlen($search_idprof3)) $sql.= natural_search("s.ape",$search_idprof3); +if (strlen($search_idprof4)) $sql.= natural_search("s.idprof4",$search_idprof4); +if (strlen($search_idprof5)) $sql.= natural_search("s.idprof5",$search_idprof5); +if (strlen($search_idprof6)) $sql.= natural_search("s.idprof6",$search_idprof6); +if (strlen($search_vat)) $sql.= natural_search("s.tva_intra",$search_vat); +// Filter on type of thirdparty +if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; +if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1"; +if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; +if ($search_status!='' && $search_status >= 0) $sql .= " AND s.status = ".$db->escape($search_status); +if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s.barcode", $search_barcode); +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; +if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')'; +if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm",$search_stcomm,2); +if ($search_import_key) $sql.= natural_search("s.import_key",$search_import_key); +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +$sql.= $db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit+1, $offset); + +$resql = $db->query($sql); +if (! $resql) +{ + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + +$arrayofselected=is_array($toselect)?$toselect:array(); + +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id); + exit; +} + +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('',$langs->trans("ThirdParty"),$help_url); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($search_all != '') $param = "&sall=".urlencode($search_all); +if ($sall != '') $param .= "&sall=".urlencode($sall); +if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); +if ($search_categ_sup > 0) $param.='&search_categ_sup='.urlencode($search_categ_sup); +if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); +if ($search_id > 0) $param.= "&search_id=".urlencode($search_id); +if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); +if ($search_alias != '') $param.= "&search_alias=".urlencode($search_alias); +if ($search_town != '') $param.= "&search_town=".urlencode($search_town); +if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); +if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); +if ($search_email != '') $param.= "&search_email=".urlencode($search_email); +if ($search_url != '') $param.= "&search_url=".urlencode($search_url); +if ($search_state != '') $param.= "&search_state=".urlencode($search_state); +if ($search_country != '') $param.= "&search_country=".urlencode($search_country); +if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code); +if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code); +if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code); +if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code); +if ($search_barcode != '') $param.= "&search_barcode=".urlencode($search_barcode); +if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1); +if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2); +if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3); +if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4); +if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5); +if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6); +if ($search_vat != '') $param.= '&search_vat='.urlencode($search_vat); +if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); +if ($search_type != '') $param.='&search_type='.urlencode($search_type); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($search_status != '') $param.='&search_status='.urlencode($search_status); +if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm); +if ($search_level_from != '') $param.='&search_level_from='.urlencode($search_level_from); +if ($search_level_to != '') $param.='&search_level_to='.urlencode($search_level_to); +if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); +if ($type != '') $param.='&type='.urlencode($type); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// Show delete result message +if (GETPOST('delsoc')) +{ + setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs'); +} + +// List of mass actions available +$arrayofmassactions = array( + 'presend'=>$langs->trans("SendByMail"), +// 'builddoc'=>$langs->trans("PDFMerge"), +); +//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + +$langs->load("other"); +$textprofid=array(); +foreach(array(1,2,3,4,5,6) as $key) +{ + $label=$langs->transnoentities("ProfId".$key.$mysoc->country_code); + $textprofid[$key]=''; + if ($label != "ProfId".$key.$mysoc->country_code) + { // Get only text between () + if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1]; + $textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label); + } +} + +$topicmail="Information"; +$modelmail="thirdparty"; +$objecttmp=new Societe($db); +$trackid='thi'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); +} + +// Filter on categories +$moreforfilter=''; +if (empty($type) || $type == 'c' || $type == 'p') +{ + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort')); + $moreforfilter.='
'; + } +} +if (empty($type) || $type == 'f') +{ + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('SuppliersCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('supplier',$search_categ_sup,'search_categ_sup',1); + $moreforfilter.='
'; + } +} + +// If the user can view prospects other than his' +if ($user->rights->societe->client->voir || $socid) +{ + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('SalesRepresentatives'). ': '; + $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300'); + $moreforfilter.='
'; +} +if ($moreforfilter) +{ + print '
'; + print $moreforfilter; + $parameters=array('type'=>$type); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + +if (empty($arrayfields['customerorsupplier']['checked'])) print ''; + +print '
'; +print ''."\n"; + +// Fields title search +print ''; +if (! empty($arrayfields['s.rowid']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['s.nom']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['s.name_alias']['checked'])) +{ + print ''; +} +// Barcode +if (! empty($arrayfields['s.barcode']['checked'])) +{ + print ''; +} +// Customer code +if (! empty($arrayfields['s.code_client']['checked'])) +{ + print ''; +} +// Supplier code +if (! empty($arrayfields['s.code_fournisseur']['checked'])) +{ + print ''; +} +// Account Customer code +if (! empty($arrayfields['s.code_compta']['checked'])) +{ + print ''; +} +// Account Supplier code +if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) +{ + print ''; +} +// Town +if (! empty($arrayfields['s.town']['checked'])) +{ + print ''; +} +// Zip +if (! empty($arrayfields['s.zip']['checked'])) +{ + print ''; +} +// State +if (! empty($arrayfields['state.nom']['checked'])) +{ + print ''; +} +// Region +if (! empty($arrayfields['region.nom']['checked'])) +{ + print ''; +} +// Country +if (! empty($arrayfields['country.code_iso']['checked'])) +{ + print ''; +} +// Company type +if (! empty($arrayfields['typent.code']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['s.email']['checked'])) +{ + // Email + print ''; +} +if (! empty($arrayfields['s.phone']['checked'])) +{ + // Phone + print ''; +} +if (! empty($arrayfields['s.url']['checked'])) +{ + // Url + print ''; +} +if (! empty($arrayfields['s.siren']['checked'])) +{ + // IdProf1 + print ''; +} +if (! empty($arrayfields['s.siret']['checked'])) +{ + // IdProf2 + print ''; +} +if (! empty($arrayfields['s.ape']['checked'])) +{ + // IdProf3 + print ''; +} +if (! empty($arrayfields['s.idprof4']['checked'])) +{ + // IdProf4 + print ''; +} +if (! empty($arrayfields['s.idprof5']['checked'])) +{ + // IdProf5 + print ''; +} +if (! empty($arrayfields['s.idprof6']['checked'])) +{ + // IdProf6 + print ''; +} +if (! empty($arrayfields['s.tva_intra']['checked'])) +{ + // Vat number + print ''; +} + +// Type (customer/prospect/supplier) +if (! empty($arrayfields['customerorsupplier']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) +{ + // Prospect level + print ''; +} + +if (! empty($arrayfields['s.fk_stcomm']['checked'])) +{ + // Prospect status + print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (! empty($arrayfields['s.datec']['checked'])) +{ + print ''; +} +// Date modification +if (! empty($arrayfields['s.tms']['checked'])) +{ + print ''; +} +// Status +if (! empty($arrayfields['s.status']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['s.import_key']['checked'])) +{ + print ''; +} +// Action column +print ''; + +print "\n"; + +print ''; +if (! empty($arrayfields['s.rowid']['checked'])) print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titre($arrayfields['s.tva_intra']['label'],$_SERVER["PHP_SELF"],"s.tva_intra","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer +if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'],$_SERVER["PHP_SELF"],"s.import_key","",$param,'align="center"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + + +$i = 0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + + $companystatic->id=$obj->rowid; + $companystatic->name=$obj->name; + $companystatic->name_alias=$obj->name_alias; + $companystatic->logo=$obj->logo; + $companystatic->canvas=$obj->canvas; + $companystatic->client=$obj->client; + $companystatic->status=$obj->status; + $companystatic->email=$obj->email; + $companystatic->fournisseur=$obj->fournisseur; + $companystatic->code_client=$obj->code_client; + $companystatic->code_fournisseur=$obj->code_fournisseur; + + $companystatic->code_compta_client=$obj->code_compta; + $companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur; + + $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; + + print ''; + if (! empty($arrayfields['s.rowid']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.nom']['checked'])) + { + $savalias = $obj->name_alias; + if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias=''; + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.name_alias']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + // Barcode + if (! empty($arrayfields['s.barcode']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Customer code + if (! empty($arrayfields['s.code_client']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Supplier code + if (! empty($arrayfields['s.code_fournisseur']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Account customer code + if (! empty($arrayfields['s.code_compta']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Account supplier code + if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Town + if (! empty($arrayfields['s.town']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Zip + if (! empty($arrayfields['s.zip']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Region + if (! empty($arrayfields['region.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Type ent + if (! empty($arrayfields['typent.code']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.email']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.phone']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.url']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.siren']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.siret']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.ape']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.idprof4']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.idprof5']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.idprof6']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.tva_intra']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Type + if (! empty($arrayfields['customerorsupplier']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) + { + // Prospect level + print '"; + if (! $i) $totalarray['nbfield']++; + } + + if (! empty($arrayfields['s.fk_stcomm']['checked'])) + { + // Prospect status + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['s.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['s.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['s.status']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.import_key']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''."\n"; + $i++; +} + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print "
'; + print ''; + print ''; + if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($type != '') print ''; + print ''; + $options_from = ''; // Generate in $options_from the list of each option sorted + foreach ($tab_level as $tab_level_sortorder => $tab_level_label) + { + $options_from .= ''; + } + array_reverse($tab_level, true); // Reverse the list + $options_to = ''; // Generate in $options_to the list of each option sorted in the reversed order + foreach ($tab_level as $tab_level_sortorder => $tab_level_label) + { + $options_to .= ''; + } + + // Print these two select + print $langs->trans("From").' '; + print ' '; + print $langs->trans("to").' '; + + print ''; + $arraystcomm=array(); + foreach($prospectstatic->cacheprospectstatus as $key => $val) + { + $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); + } + print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); + print ''; + print ''; + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1); + print ''; + print ''; + print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + print $obj->rowid; + print "'; + print $obj->name; + print "'; + print $companystatic->name_alias; + print "'.$obj->barcode.''.$obj->code_client.''.$obj->code_fournisseur.''.$obj->code_compta.''.$obj->code_compta_fournisseur.'".$obj->town."".$obj->zip."".$obj->state_name."".$obj->region_name."'; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; + if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print '".$obj->email."".$obj->phone."".$obj->url."".$obj->idprof1."".$obj->idprof2."".$obj->idprof3."".$obj->idprof4."".$obj->idprof5."".$obj->idprof6."".$obj->tva_intra."'; + $s=''; + if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + $companystatic->name=$langs->trans("Customer"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'customer',0,1); + } + if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + { + if ($s) $s.=" / "; + $companystatic->name=$langs->trans("Prospect"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'prospect',0,1); + } + if (! empty($conf->fournisseur->enabled) && $obj->fournisseur) + { + if ($s) $s.=" / "; + $companystatic->name=$langs->trans("Supplier"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'supplier',0,1); + } + print $s; + print ''; + print $companystatic->getLibProspLevel(); + print "
'; + print '
'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']); + print '
-
'; + foreach($prospectstatic->cacheprospectstatus as $key => $val) + { + $titlealt='default'; + if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; + if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt,$val['code']).''; + } + print '
'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$companystatic->getLibStatut(3).''; + print $obj->import_key; + print "'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
"; +print "
"; + +print ''; + +llxFooter(); +$db->close(); diff --git a/htdocs/takepos/dev/img/README.md b/htdocs/takepos/dev/img/README.md new file mode 100644 index 00000000000..5cd4c76d010 --- /dev/null +++ b/htdocs/takepos/dev/img/README.md @@ -0,0 +1,53 @@ +Source images +============= + +Used to generate icons and publication assets. + +Icons +----- + +### Dolibarr + +These resides in the [/img](../../img) directory. + +#### Small + +Required. +Name must begin by ```object_```. + +- Sample: ![object_takepos.png](../../img/object_takepos.png) [object_takepos.png](../../img/object_takepos.png) +- Size: 14×14 pixels +- Type: PNG + +#### Large + +Optional. + +- Sample: ![takepos.png](../../img/takepos.png) [takepos.png](../../img/takepos.png) +- Size: 32×32 pixels +- Type: PNG + +### Dolistore + +Designed to fit a 512×512 icon + publisher branding. + +- Size: 704×704 +- Type: PNG + +Export to 512×512 + +### Transifex + +- Size: 96×96 +- Type: PNG + +### Others + +To be on the safe side, you may also want to generate all popular sizes: +- 16×16 +- 32×32 +- 48×48 +- 64×64 +- 128×128 +- 256×256 +- 512×512 diff --git a/htdocs/takepos/dev/img/gfdl-129x44.png b/htdocs/takepos/dev/img/gfdl-129x44.png new file mode 100644 index 00000000000..f2bacfd179a Binary files /dev/null and b/htdocs/takepos/dev/img/gfdl-129x44.png differ diff --git a/htdocs/takepos/dev/img/gfdl-66x23.png b/htdocs/takepos/dev/img/gfdl-66x23.png new file mode 100644 index 00000000000..b43479bf3c8 Binary files /dev/null and b/htdocs/takepos/dev/img/gfdl-66x23.png differ diff --git a/htdocs/takepos/dev/img/gfdl-logo.svg b/htdocs/takepos/dev/img/gfdl-logo.svg new file mode 100644 index 00000000000..a0daca0ead8 --- /dev/null +++ b/htdocs/takepos/dev/img/gfdl-logo.svg @@ -0,0 +1,110 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + GFDL + + + + + + + diff --git a/htdocs/takepos/dev/img/gpl-v3-logo.svg b/htdocs/takepos/dev/img/gpl-v3-logo.svg new file mode 100644 index 00000000000..6754c994bda --- /dev/null +++ b/htdocs/takepos/dev/img/gpl-v3-logo.svg @@ -0,0 +1,389 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/htdocs/takepos/dev/img/gplv3-127x51.png b/htdocs/takepos/dev/img/gplv3-127x51.png new file mode 100644 index 00000000000..3e9136e6266 Binary files /dev/null and b/htdocs/takepos/dev/img/gplv3-127x51.png differ diff --git a/htdocs/takepos/dev/img/gplv3-88x31.png b/htdocs/takepos/dev/img/gplv3-88x31.png new file mode 100644 index 00000000000..ba78d4c4941 Binary files /dev/null and b/htdocs/takepos/dev/img/gplv3-88x31.png differ diff --git a/htdocs/takepos/dev/img/takepos.svg b/htdocs/takepos/dev/img/takepos.svg new file mode 100644 index 00000000000..f51ead1a94e --- /dev/null +++ b/htdocs/takepos/dev/img/takepos.svg @@ -0,0 +1,70 @@ + + + + + + + + + + image/svg+xml + + + + + + + M + + diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php new file mode 100644 index 00000000000..8dd6f729950 --- /dev/null +++ b/htdocs/takepos/floors.php @@ -0,0 +1,176 @@ + + * + * 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 . + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +$_GET['theme']="md"; // Force theme. MD theme provides better look and feel to TakePOS + +require '../main.inc.php'; // Load $user and permissions + +$floor=GETPOST('floor','alpha'); +if ($floor=="") $floor=1; +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$left = GETPOST('left','alpha'); +$top = GETPOST('top','alpha'); +$place = GETPOST('place','int'); +$newname = GETPOST('newname'); +$mode = GETPOST('mode','alpha'); + +if ($action=="getTables"){ + $sql="SELECT * from ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor; + $resql = $db->query($sql); + $rows = array(); + while($row = $db->fetch_array ($resql)){ + $rows[] = $row; + } + echo json_encode($rows); + exit; +} + +if ($action=="update") +{ + if ($left>95) $left=95; + if ($top>95) $top=95; + if ($left>3 or $top>4) $db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set leftpos=$left, toppos=$top where label='$place'"); + else $db->query("delete from ".MAIN_DB_PREFIX."takepos_floor_tables where label='$place'"); +} + +if ($action=="updatename") +{ + $newname = preg_replace("/[^a-zA-Z0-9\s]/", "", $newname); // Only English chars + if (strlen($newname) > 3) $newname = substr($newname, 0, 3); // Only 3 chars + $db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label='$newname' where label='$place'"); +} + +if ($action=="add") +{ + $asdf=$db->query("insert into ".MAIN_DB_PREFIX."takepos_floor_tables values ('', '', '', '45', '45', $floor)"); + $db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label=rowid where label=''"); // No empty table names +} + +// Title +$title='TakePOS - Dolibarr '.DOL_VERSION; +if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; +top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); +?> + + + + + + +admin){?> + + + +
+
+

';">trans("Floor")." ".$floor; ?>

+
+
+ + \ No newline at end of file diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php new file mode 100644 index 00000000000..f97d46518e3 --- /dev/null +++ b/htdocs/takepos/freezone.php @@ -0,0 +1,60 @@ + + * + * 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 . + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +require '../main.inc.php'; // Load $user and permissions + +$langs->load("bills"); +$langs->load("cashdesk"); + +$place = GETPOST('place','int'); + + +/* + * View + */ + +top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + +?> + + + +
+
+ + + + +
+ + + \ No newline at end of file diff --git a/htdocs/takepos/genimg/add.jpg b/htdocs/takepos/genimg/add.jpg new file mode 100644 index 00000000000..976fd10697d Binary files /dev/null and b/htdocs/takepos/genimg/add.jpg differ diff --git a/htdocs/takepos/genimg/empty.jpg b/htdocs/takepos/genimg/empty.jpg new file mode 100644 index 00000000000..8883f7c9957 Binary files /dev/null and b/htdocs/takepos/genimg/empty.jpg differ diff --git a/htdocs/takepos/genimg/index.php b/htdocs/takepos/genimg/index.php new file mode 100644 index 00000000000..ff1b368b743 --- /dev/null +++ b/htdocs/takepos/genimg/index.php @@ -0,0 +1,143 @@ + + * + * 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 . + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +require '../../main.inc.php'; // Load $user and permissions + +$id= GETPOST('id'); +$w= GETPOST('w'); +$h= GETPOST('h'); +$query= GETPOST('query'); + + + +/* + * View + */ + +header('Content-Type: image/jpeg'); +header('Cache-Control: max-age=604800, public, must-revalidate'); +header('Pragma: cache'); + +if ($query=="cat") +{ + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; + + $object = new Categorie($db); + $result = $object->fetch($id); + $upload_dir = $conf->categorie->multidir_output[$object->entity]; + $pdir = get_exdir($object->id,2,0,0,$object,'category') . $object->id ."/photos/"; + $dir = $upload_dir.'/'.$pdir; + foreach ($object->liste_photos($dir) as $key => $obj) + { + $filename=$obj['photo']; + } + + // The file + $filename = $dir.$filename; + if (!file_exists($filename)) $filename="empty.jpg"; + + // Dimensions + list($width, $height) = getimagesize($filename); + $new_width = $w; + $new_height = $h; + + // Resample + $image_p = imagecreatetruecolor($new_width, $new_height); + $image = imagecreatefromjpeg($filename); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + + // Add icon + $icon = imagecreatefromjpeg('add.jpg'); + list($width, $height) = getimagesize('add.jpg'); + $new_width = $w*0.3; + $new_height = $h*0.3; + $icon_p = imagecreatetruecolor($new_width, $new_height); + imagecopyresampled($icon_p, $icon, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + imagecopymerge($image_p, $icon_p, 0, 0, 0, 0, $new_width, $new_height, 100); + + // Output + imagejpeg($image_p, null, 100); +} +else if ($query=="pro") +{ + require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; + + $objProd = new Product($db); + $objProd->fetch($id); + + $dir .= get_exdir(0,0,0,0,$objProd,'product').$objProd->ref.'/'; + $pdir .= get_exdir(0,0,0,0,$objProd,'product').$objProd->ref.'/'; + + foreach ($objProd->liste_photos($dir) as $key => $obj) + { + $filename=$obj['photo']; + } + $filename = $dir.$filename; + + if (!file_exists($filename)){ + $dir = $conf->product->multidir_output[$objProd->entity].'/'.$pdir; + foreach ($objProd->liste_photos($dir) as $key => $obj) + { + $filename=$obj['photo']; + } + $filename = $dir.$filename; + } + + if (!file_exists($filename)) $filename="empty.jpg"; + + // Dimensions + list($width, $height) = getimagesize($filename); + $new_width = $w; + $new_height = $h; + + // Resample + $image_p = imagecreatetruecolor($new_width, $new_height); + $image = imagecreatefromjpeg($filename); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + + // Output + imagejpeg($image_p, null, 100); +} +else +{ + // The file + $filename = $query.".jpg"; + + // Dimensions + list($width, $height) = getimagesize($filename); + $new_width = $w; + $new_height = $h; + + // Resample + $image_p = imagecreatetruecolor($new_width, $new_height); + $image = imagecreatefromjpeg($filename); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + + // Output + imagejpeg($image_p, null, 100); +} diff --git a/htdocs/takepos/img/arrow-next-top.png b/htdocs/takepos/img/arrow-next-top.png new file mode 100644 index 00000000000..70f720cab10 Binary files /dev/null and b/htdocs/takepos/img/arrow-next-top.png differ diff --git a/htdocs/takepos/img/arrow-next.png b/htdocs/takepos/img/arrow-next.png new file mode 100644 index 00000000000..1056f024390 Binary files /dev/null and b/htdocs/takepos/img/arrow-next.png differ diff --git a/htdocs/takepos/img/arrow-prev-top.png b/htdocs/takepos/img/arrow-prev-top.png new file mode 100644 index 00000000000..23567d35890 Binary files /dev/null and b/htdocs/takepos/img/arrow-prev-top.png differ diff --git a/htdocs/takepos/img/arrow-prev.png b/htdocs/takepos/img/arrow-prev.png new file mode 100644 index 00000000000..b7311f26f54 Binary files /dev/null and b/htdocs/takepos/img/arrow-prev.png differ diff --git a/htdocs/takepos/img/gfdl.png b/htdocs/takepos/img/gfdl.png new file mode 100644 index 00000000000..f2bacfd179a Binary files /dev/null and b/htdocs/takepos/img/gfdl.png differ diff --git a/htdocs/takepos/img/gplv3.png b/htdocs/takepos/img/gplv3.png new file mode 100644 index 00000000000..ba78d4c4941 Binary files /dev/null and b/htdocs/takepos/img/gplv3.png differ diff --git a/htdocs/takepos/img/marketplace/cashcontrol.jpg b/htdocs/takepos/img/marketplace/cashcontrol.jpg new file mode 100644 index 00000000000..66240218dff Binary files /dev/null and b/htdocs/takepos/img/marketplace/cashcontrol.jpg differ diff --git a/htdocs/takepos/img/marketplace/takeposmobile.jpg b/htdocs/takepos/img/marketplace/takeposmobile.jpg new file mode 100644 index 00000000000..918f7c49d5e Binary files /dev/null and b/htdocs/takepos/img/marketplace/takeposmobile.jpg differ diff --git a/htdocs/takepos/img/object_takepos.png b/htdocs/takepos/img/object_takepos.png new file mode 100644 index 00000000000..5a307bfc62f Binary files /dev/null and b/htdocs/takepos/img/object_takepos.png differ diff --git a/htdocs/takepos/img/table.gif b/htdocs/takepos/img/table.gif new file mode 100644 index 00000000000..54f7a209d89 Binary files /dev/null and b/htdocs/takepos/img/table.gif differ diff --git a/htdocs/takepos/img/takepos.png b/htdocs/takepos/img/takepos.png new file mode 100644 index 00000000000..be9d3dcfc3f Binary files /dev/null and b/htdocs/takepos/img/takepos.png differ diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php new file mode 100644 index 00000000000..91b43dad675 --- /dev/null +++ b/htdocs/takepos/invoice.php @@ -0,0 +1,287 @@ + + * + * 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 . + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +require '../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + +$langs->load("bills"); +$langs->load("cashdesk"); + +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$idproduct = GETPOST('idproduct','int'); +$place = GETPOST('place','int'); +$number = GETPOST('number'); +$idline = GETPOST('idline'); +$desc = GETPOST('desc','alpha'); +$pay = GETPOST('pay'); + +$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where facnumber='(PROV-POS-".$place.")'"; +$resql = $db->query($sql); +$row = $db->fetch_array ($resql); +$placeid=$row[0]; +if (! $placeid) $placeid=0; // not necesary +else{ + $invoice = new Facture($db); + $invoice->fetch($placeid); +} + +/* + * Actions + */ + +if ($action == 'valid' && $user->rights->facture->creer){ + if ($pay=="cash") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CASH; + else if ($pay=="card") $bankaccount=$conf->global->CASHDESK_ID_BANKACCOUNT_CB; + $now=dol_now(); + $invoice = new Facture($db); + $invoice->fetch($placeid); + if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); + else $invoice->validate($user); + // Add the payment + $payment=new Paiement($db); + $payment->datepaye=$now; + $payment->bank_account=$bankaccount; + $payment->amounts[$invoice->id]=$invoice->total_ttc; + if ($pay=="cash") $payment->paiementid=4; + else if ($pay=="card") $payment->paiementid=6; + $payment->num_paiement=$invoice->facnumber; + $payment->create($user); + $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + $invoice->set_paid($user); +} + +if (($action=="addline" or $action=="freezone") and $placeid==0) +{ + if ($placeid==0) { + $invoice = new Facture($db); + $invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY; + $invoice->date=mktime(); + $invoice->ref="asdf"; + $placeid=$invoice->create($user); + $sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$place.")' where rowid=".$placeid; + $db->query($sql); + } +} + +if ($action=="addline"){ + $prod = new Product($db); + $prod->fetch($idproduct); + $invoice->addline($prod->description, $prod->price, 1, $prod->tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $prod->remise_percent, '', 0, 0, 0, '', $prod->price_base_type, $prod->price_ttc, $prod->type, - 1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); + $invoice->fetch($placeid); +} + +if ($action=="freezone"){ + $invoice->addline($desc, $number, 1, $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS, 0, 0, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, - 1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); + $invoice->fetch($placeid); +} + +if ($action=="deleteline"){ + if ($idline>0 and $placeid>0){ //If exist invoice and line, to avoid errors if deleted from other device or no line selected + $invoice->deleteline($idline); + $invoice->fetch($placeid); + } + else if ($placeid>0){ //If exist invoice, but no line selected, proced to delete last line + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture='$placeid' order by rowid DESC"; + $resql = $db->query($sql); + $row = $db->fetch_array ($resql); + $deletelineid=$row[0]; + $invoice->deleteline($deletelineid); + $invoice->fetch($deletelineid); + } +} + +if ($action=="updateqty"){ + foreach ($invoice->lines as $line){ + if ($line->id==$idline) $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, + $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, + $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, + $line->fk_unit); + } + $invoice->fetch($placeid); +} + +if ($action=="updateprice"){ + foreach ($invoice->lines as $line){ + if ($line->id==$idline) $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, + $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, + $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, + $line->fk_unit); + } + $invoice->fetch($placeid); +} + +if ($action=="updatereduction"){ + foreach ($invoice->lines as $line){ + if ($line->id==$idline) $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, + $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, + $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, + $line->fk_unit); + } + $invoice->fetch($placeid); +} + +if ($action=="order"){ + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $headerorder='
'.$langs->trans('Place').' '.$place.'
'; + $footerorder='
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; + $order_receipt_printer1=""; + $order_receipt_printer2=""; + $catsprinter1 = explode(';',$conf->global->TAKEPOS_PRINTED_CATEGORIES_1); + $catsprinter2 = explode(';',$conf->global->TAKEPOS_PRINTED_CATEGORIES_2); + foreach ($invoice->lines as $line){ + if ($line->special_code=="3") continue; + $c = new Categorie($db); + $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); + $result = array_intersect($catsprinter1, $existing); + $count=count($result); + if ($count>0){ + $sql="UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=$line->rowid"; + $db->query($sql); + $order_receipt_printer1.='
'.$line->qty.'
'.$line->qty.'
'; +print ''; +print ''; +print ''; +print ''; +print "\n"; +if ($placeid>0) foreach ($invoice->lines as $line) +{ + print ''; + print ''; + print ''; + print ''; + print ''; +} +print '
'.$langs->trans('Description').''.$langs->trans('Qty').''.$langs->trans('TotalHTShort').'
'.$line->product_label.$line->desc.''.$line->qty.''.price($line->total_ttc).'
'; +print '

'.$langs->trans('TotalTTC'); +if($conf->global->TAKEPOS_BAR_RESTAURANT) print " ".$langs->trans('Place')." ".$place; +print ': '.price($invoice->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).' 

'; + +//if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY){ + $soc = new Societe($db); + if ($invoice->socid > 0) $soc->fetch($invoice->socid); + else $soc->fetch($conf->global->CASHDESK_ID_THIRDPARTY); + print '

'; + print $langs->trans("Customer").': '.$soc->name; + print '

'; +//} +if ($action=="valid"){ + print '

'.$invoice->facnumber." ".$langs->trans('BillShortStatusValidated').'

'; + if ($conf->global->TAKEBOX) print '
'; + else print '
'; +} +if ($action=="search"){ + print '
+ '; +} +print ''; diff --git a/htdocs/takepos/js/jquery.colorbox-min.js b/htdocs/takepos/js/jquery.colorbox-min.js new file mode 100644 index 00000000000..b5109a262ef --- /dev/null +++ b/htdocs/takepos/js/jquery.colorbox-min.js @@ -0,0 +1,6 @@ +/*! + Colorbox 1.6.4 + license: MIT + http://www.jacklmoore.com/colorbox +*/ +(function(t,e,i){function n(i,n,o){var r=e.createElement(i);return n&&(r.id=Z+n),o&&(r.style.cssText=o),t(r)}function o(){return i.innerHeight?i.innerHeight:t(i).height()}function r(e,i){i!==Object(i)&&(i={}),this.cache={},this.el=e,this.value=function(e){var n;return void 0===this.cache[e]&&(n=t(this.el).attr("data-cbox-"+e),void 0!==n?this.cache[e]=n:void 0!==i[e]?this.cache[e]=i[e]:void 0!==X[e]&&(this.cache[e]=X[e])),this.cache[e]},this.get=function(e){var i=this.value(e);return t.isFunction(i)?i.call(this.el,this):i}}function h(t){var e=W.length,i=(A+t)%e;return 0>i?e+i:i}function a(t,e){return Math.round((/%/.test(t)?("x"===e?E.width():o())/100:1)*parseInt(t,10))}function s(t,e){return t.get("photo")||t.get("photoRegex").test(e)}function l(t,e){return t.get("retinaUrl")&&i.devicePixelRatio>1?e.replace(t.get("photoRegex"),t.get("retinaSuffix")):e}function d(t){"contains"in x[0]&&!x[0].contains(t.target)&&t.target!==v[0]&&(t.stopPropagation(),x.focus())}function c(t){c.str!==t&&(x.add(v).removeClass(c.str).addClass(t),c.str=t)}function g(e){A=0,e&&e!==!1&&"nofollow"!==e?(W=t("."+te).filter(function(){var i=t.data(this,Y),n=new r(this,i);return n.get("rel")===e}),A=W.index(_.el),-1===A&&(W=W.add(_.el),A=W.length-1)):W=t(_.el)}function u(i){t(e).trigger(i),ae.triggerHandler(i)}function f(i){var o;if(!G){if(o=t(i).data(Y),_=new r(i,o),g(_.get("rel")),!U){U=$=!0,c(_.get("className")),x.css({visibility:"hidden",display:"block",opacity:""}),I=n(se,"LoadedContent","width:0; height:0; overflow:hidden; visibility:hidden"),b.css({width:"",height:""}).append(I),j=T.height()+k.height()+b.outerHeight(!0)-b.height(),D=C.width()+H.width()+b.outerWidth(!0)-b.width(),N=I.outerHeight(!0),z=I.outerWidth(!0);var h=a(_.get("initialWidth"),"x"),s=a(_.get("initialHeight"),"y"),l=_.get("maxWidth"),f=_.get("maxHeight");_.w=Math.max((l!==!1?Math.min(h,a(l,"x")):h)-z-D,0),_.h=Math.max((f!==!1?Math.min(s,a(f,"y")):s)-N-j,0),I.css({width:"",height:_.h}),J.position(),u(ee),_.get("onOpen"),O.add(F).hide(),x.focus(),_.get("trapFocus")&&e.addEventListener&&(e.addEventListener("focus",d,!0),ae.one(re,function(){e.removeEventListener("focus",d,!0)})),_.get("returnFocus")&&ae.one(re,function(){t(_.el).focus()})}var p=parseFloat(_.get("opacity"));v.css({opacity:p===p?p:"",cursor:_.get("overlayClose")?"pointer":"",visibility:"visible"}).show(),_.get("closeButton")?B.html(_.get("close")).appendTo(b):B.appendTo("
"),w()}}function p(){x||(V=!1,E=t(i),x=n(se).attr({id:Y,"class":t.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),v=n(se,"Overlay").hide(),L=t([n(se,"LoadingOverlay")[0],n(se,"LoadingGraphic")[0]]),y=n(se,"Wrapper"),b=n(se,"Content").append(F=n(se,"Title"),R=n(se,"Current"),P=t(' + + + + + + + + + + + + + + + +
+ + + \ No newline at end of file diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php new file mode 100644 index 00000000000..6b2cb1a5505 --- /dev/null +++ b/htdocs/takepos/receipt.php @@ -0,0 +1,108 @@ + + * Copyright (C) 2011 Laurent Destailleur + * Copyright (C) 2012 Marcos García + * Copyright (C) 2018 Andreu Bisquerra + * + * 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 . + */ + +require '../main.inc.php'; // Load $user and permissions +include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + +$langs->load("main"); +$langs->load('cashdesk'); + + +/* + * View + */ + +top_httphead('text/html'); + +$facid=GETPOST('facid','int'); +$place=GETPOST('place','int'); +if ($place>0){ + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where facnumber='(PROV-POS-".$place.")'"; + $resql = $db->query($sql); + $row = $db->fetch_array ($resql); + $facid=$row[0]; +} +$object=new Facture($db); +$object->fetch($facid); + +// IMPORTANT: This file is sended to 'Takepos Printing' application. Keep basic file. No external files as css, js... If you need images use absolut path. +?> + + +
+ +name; ?> + +
+
+

+ +

+

+trans('Date')." ".dol_print_date($object->date, 'day').'
'; +if ($mysoc->country_code == 'ES') print "Factura simplificada "; +print $object->ref; +?> +

+
+ + + + + + + + + + + lines as $line) + { + ?> + + + + + + + +
trans("Label"); ?>trans("Qty"); ?>trans("TotalTTC"); ?>
product_label;?>qty;?>total_ttc);?>
+
+ + + + + + + + + + + +
trans("TotalHT");?>total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n";?>
trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n";?>
trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n";?>
+ + + + diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php new file mode 100644 index 00000000000..8dec143bffe --- /dev/null +++ b/htdocs/takepos/takepos.php @@ -0,0 +1,403 @@ + + * + * 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 . + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +$_GET['theme']="md"; // Force theme. MD theme provides better look and feel to TakePOS + +require '../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + +$place = GETPOST('place','int'); +if ($place=="") $place="0"; +$action = GETPOST('action','alpha'); + +$langs->loadLangs(array("bills","orders","commercial","cashdesk")); + + +/* + * View + */ + +// Title +$title='TakePOS - Dolibarr '.DOL_VERSION; +if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; +top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + +?> + + + + + + + + +
+
+ +
+ + + + + + + + + + + + + + + + +
+ +$langs->trans("SearchProduct"), + 'action'=>'Search();'); +$menus[$r++]=array('title'=>$langs->trans("FreeZone"), + 'action'=>'FreeZone();'); +$menus[$r++]=array('title'=>$langs->trans("Customer"), + 'action'=>'Customer();'); +$menus[$r++]=array('title'=>$langs->trans("BackOffice"), + 'action'=>'window.open(\''.DOL_URL_ROOT.'\', \'backoffice\');'); +$menus[$r++]=array('title'=>$langs->trans("ValidateBill"), + 'action'=>'CloseBill();'); +$menus[$r++]=array('title'=>$langs->trans("Logout"), + 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';'); +if($conf->global->TAKEPOS_BAR_RESTAURANT){ + $menus[$r++]=array('title'=>$langs->trans("Floors"), + 'action'=>'Floors();'); + if ($conf->global->TAKEPOS_ORDER_PRINTERS){ + $menus[$r++]=array('title'=>$langs->trans("Order"), + 'action'=>'TakeposPrintingOrder();'); + } +} +?> +
+'.$menu['title'].''; +} +?> +
+ +
+ +
id='catdiv'> + width="98%" id='catimg'/> +
+
+
+
+ +
+ +
+ +
onclick="MoreProducts('less');" onclick="MoreProducts('more');" > + width="95%" id='proimg'/> +
+
+
+
+ +
+ + +close(); + + + diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 03abd661d7d..1b5508987e5 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -264,7 +264,7 @@ body { trans("DIRECTION").";\n"; ?> } -.thumbstat, a.tab { font-weight: bold !important; } +.thumbstat { font-weight: bold !important; } th a { font-weight: !important; } a.tab { font-weight: bold !important; } @@ -553,7 +553,7 @@ form { margin:0px; } form#addproduct { - padding-top: 6px; + padding-top: 10px; } div.float { @@ -1169,8 +1169,8 @@ td.showDragHandle { table-layout: fixed; } #id-right, #id-left { - padding-top: 16px; - padding-bottom: 16px; + padding-top: 20px; + padding-bottom: 20px; display: table-cell; /* DOL_XXX Empeche fonctionnement correct du scroll horizontal sur tableau, avec datatable ou CSS */ float: none; @@ -1275,8 +1275,8 @@ div.fiche { div.fiche { - margin-: dol_optimize_smallscreen)?'25':'6')); ?>px; - margin-: dol_optimize_smallscreen)?'24':'6')); ?>px; + margin-: dol_optimize_smallscreen)?'30':'6')); ?>px; + margin-: dol_optimize_smallscreen)?'29':'6')); ?>px; } @@ -1707,6 +1707,10 @@ div.mainmenu.cashdesk { background-image: url(); } +div.mainmenu.takepos { + background-image: url(); +} + div.mainmenu.companies { background-image: url(); } @@ -1776,7 +1780,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; // Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); // Put here list of menu entries we are sure we don't want $divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); foreach($mainmenuusedarray as $val) @@ -2335,6 +2339,7 @@ div.tabBar table.tableforservicepart2:last-child { } .tableforservicepart1 .tdhrthin { height: unset; + padding-top: 0 !important; } div.popuptabset { @@ -5055,7 +5060,7 @@ dl.dropdown { .dropdown dd ul li { white-space: nowrap; font-weight: normal; - padding: 4px 8px 4px 8px; + padding: 7px 8px 7px 8px; /* color: rgb(); */ color: #000; } @@ -5073,7 +5078,7 @@ dl.dropdown { color: #888; } .dropdown dd ul li a:hover { - background-color:#fff; + background-color:#eee; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index d88a84c5090..1adf763017b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -100,7 +100,7 @@ $dol_no_mouse_hover=$conf->dol_no_mouse_hover; //$user->conf->THEME_ELDY_ENABLE_PERSONALIZED=0; //var_dump($user->conf->THEME_ELDY_RGB); -$useboldtitle=(isset($conf->global->THEME_ELDY_USEBOLDTITLE)?$conf->global->THEME_ELDY_USEBOLDTITLE:1); +$useboldtitle=(isset($conf->global->THEME_ELDY_USEBOLDTITLE)?$conf->global->THEME_ELDY_USEBOLDTITLE:0); $borderwidth=2; // Case of option always editable @@ -257,7 +257,8 @@ body { trans("DIRECTION").";\n"; ?> } -th a, .thumbstat, a.tab { font-weight: bold !important; } +.thumbstat { font-weight: bold !important; } +th a { font-weight: !important; } a.tab { font-weight: bold !important; } a:link, a:visited, a:hover, a:active { font-family: ; font-weight: normal; color: rgb(); text-decoration: none; } @@ -1696,6 +1697,10 @@ div.mainmenu.cashdesk { background-image: url(); } +div.mainmenu.takepos { + background-image: url(); +} + div.mainmenu.companies { background-image: url(); } @@ -1769,7 +1774,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; // Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); // Put here list of menu entries we are sure we don't want $divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); foreach($mainmenuusedarray as $val) @@ -4891,7 +4896,7 @@ dl.dropdown { box-shadow: 1px 1px 10px #aaa; display:none; right:0px; /* pop is align on right */ - padding: 2px 15px 2px 5px; + padding: 0 0 0 0; position:absolute; top:2px; list-style:none; @@ -4901,9 +4906,12 @@ dl.dropdown { .dropdown dd ul li { white-space: nowrap; font-weight: normal; - padding: 4px; + padding: 7px 8px 7px 8px; color: #000; } +.dropdown dd ul li:hover { + background: #eee; +} .dropdown dd ul li input[type="checkbox"] { margin-right: 3px; } @@ -4915,7 +4923,7 @@ dl.dropdown { color: #888; } .dropdown dd ul li a:hover { - background-color:#fff; + background-color: #eee; } diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 845ca8ca773..2fd26b5797b 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -60,6 +60,9 @@ class ActionsTicket public $template_dir; public $template; + /** + * @var string ticket action label + */ public $label; /** diff --git a/htdocs/user/group/index.html b/htdocs/user/group/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/user/group/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/user/index.html b/htdocs/user/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/user/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/user/notify/index.html b/htdocs/user/notify/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/user/notify/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/website/index.php b/htdocs/website/index.php index c3facf51551..19c9c31da71 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1937,16 +1937,15 @@ if (count($object->records) > 0) // There is at least one web site print '
'; diff --git a/test/phpunit/functional/TakePosFunctionalTest.php b/test/phpunit/functional/TakePosFunctionalTest.php new file mode 100644 index 00000000000..b01d86eda10 --- /dev/null +++ b/test/phpunit/functional/TakePosFunctionalTest.php @@ -0,0 +1,317 @@ + + * Copyright (C) 2018 SuperAdmin + * + * 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 test/functional/TakePosFunctionalTest.php + * \ingroup takepos + * \brief Example Selenium test. + */ + +namespace test\functional; + +use PHPUnit_Extensions_Selenium2TestCase_WebDriverException; + +/** + * Class TakePosFunctionalTest + * + * Requires chromedriver for Google Chrome + * Requires geckodriver for Mozilla Firefox + * + * @fixme Firefox (Geckodriver/Marionette) support + * @todo Opera linux support + * @todo Windows support (IE, Google Chrome, Mozilla Firefox, Safari) + * @todo OSX support (Safari, Google Chrome, Mozilla Firefox) + * + * @package Testtakepos + */ +class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase +{ + // TODO: move to a global configuration file? + /** @var string Base URL of the webserver under test */ + protected static $base_url = 'http://dev.zenfusion.fr'; + /** + * @var string Dolibarr admin username + * @see authenticate + */ + protected static $dol_admin_user = 'admin'; + /** + * @var string Dolibarr admin password + * @see authenticate + */ + protected static $dol_admin_pass = 'admin'; + /** @var int Dolibarr module ID */ + private static $module_id = 500000; // TODO: autodetect? + + /** @var array Browsers to test with */ + public static $browsers = array( + array( + 'browser' => 'Google Chrome on Linux', + 'browserName' => 'chrome', + 'sessionStrategy' => 'shared', + 'desiredCapabilities' => array() + ), + // Geckodriver does not keep the session at the moment?! + // XPath selectors also don't seem to work +// array( +// 'browser' => 'Mozilla Firefox on Linux', +// 'browserName' => 'firefox', +// 'sessionStrategy' => 'shared', +// 'desiredCapabilities' => array( +// 'marionette' => true +// ) +// ) + ); + + /** + * Helper function to select links by href + * + * @param string $value Href + * @return mixed Helper string + */ + protected function byHref($value) + { + $anchor = null; + $anchors = $this->elements($this->using('tag name')->value('a')); + foreach ($anchors as $anchor) { + if (strstr($anchor->attribute('href'), $value)) { + break; + } + } + return $anchor; + } + + /** + * Global test setup + * + * @return void + */ + public static function setUpBeforeClass() + { + } + + /** + * Unit test setup + * + * @return void + */ + public function setUp() + { + $this->setSeleniumServerRequestsTimeout(3600); + $this->setBrowserUrl(self::$base_url); + } + + /** + * Verify pre conditions + * + * @return void + */ + protected function assertPreConditions() + { + } + + /** + * Handle Dolibarr authentication + * + * @return void + */ + private function authenticate() + { + try { + if ($this->byId('login')) { + $login = $this->byId('username'); + $login->clear(); + $login->value('admin'); + $password = $this->byId('password'); + $password->clear(); + $password->value('admin'); + $this->byId('login')->submit(); + } + } catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + // Login does not exist. Assume we are already authenticated + } + } + + /** + * Test enabling developer mode + * + * @return void + */ + public function testEnableDeveloperMode() + { + $this->url('/admin/const.php'); + $this->authenticate(); + $main_features_level_path='//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]'; + $main_features_level = $this->byXPath($main_features_level_path); + $main_features_level->clear(); + $main_features_level->value('2'); + $this->byName('update')->click(); + // Page reloaded, we need a new XPath + $main_features_level = $this->byXPath($main_features_level_path); + $this->assertEquals('2', $main_features_level->value(), "MAIN_FEATURES_LEVEL value is 2"); + } + + /** + * Test enabling the module + * + * @return void + * + * @depends testEnableDeveloperMode + */ + public function testModuleEnabled() + { + $this->url('/admin/modules.php'); + $this->authenticate(); + $module_status_image_path='//a[contains(@href, "' . self::$module_id . '")]/img'; + $module_status_image = $this->byXPath($module_status_image_path); + if (strstr($module_status_image->attribute('src'), 'switch_off.png')) { + // Enable the module + $this->byHref('modTakePos')->click(); + } else { + // Disable the module + $this->byHref('modTakePos')->click(); + // Reenable the module + $this->byHref('modTakePos')->click(); + } + // Page reloaded, we need a new Xpath + $module_status_image = $this->byXPath($module_status_image_path); + $this->assertContains('switch_on.png', $module_status_image->attribute('src'), "Module enabled"); + } + + /** + * Test access to the configuration page + * + * @return void + * + * @depends testModuleEnabled + */ + public function testConfigurationPage() + { + $this->url('/custom/takepos/admin/setup.php'); + $this->authenticate(); + $this->assertContains('takepos/admin/setup.php', $this->url(), 'Configuration page'); + } + + /** + * Test access to the about page + * + * @return void + * + * @depends testConfigurationPage + */ + public function testAboutPage() + { + $this->url('/custom/takepos/admin/about.php'); + $this->authenticate(); + $this->assertContains('takepos/admin/about.php', $this->url(), 'About page'); + } + + /** + * Test about page is rendering Markdown + * + * @return void + * + * @depends testAboutPage + */ + public function testAboutPageRendersMarkdownReadme() + { + $this->url('/custom/takepos/admin/about.php'); + $this->authenticate(); + $this->assertEquals( + 'Dolibarr Module Template (aka My Module)', + $this->byTag('h1')->text(), + "Readme title" + ); + } + + /** + * Test box is properly declared + * + * @return void + * + * @depends testModuleEnabled + */ + public function testBoxDeclared() + { + $this->url('/admin/boxes.php'); + $this->authenticate(); + $this->assertContains('takeposwidget1', $this->source(), "Box enabled"); + } + + /** + * Test trigger is properly enabled + * + * @return void + * + * @depends testModuleEnabled + */ + public function testTriggerDeclared() + { + $this->url('/admin/triggers.php'); + $this->authenticate(); + $this->assertContains( + 'interface_99_modTakePos_TakePosTriggers.class.php', + $this->byTag('body')->text(), + "Trigger declared" + ); + } + + /** + * Test trigger is properly declared + * + * @return void + * + * @depends testTriggerDeclared + */ + public function testTriggerEnabled() + { + $this->url('/admin/triggers.php'); + $this->authenticate(); + $this->assertContains( + 'tick.png', + $this->byXPath('//td[text()="interface_99_modTakePos_MyTrigger.class.php"]/following::img')->attribute('src'), + "Trigger enabled" + ); + } + + /** + * Verify post conditions + * + * @return void + */ + protected function assertPostConditions() + { + } + + /** + * Unit test teardown + * + * @return void + */ + public function tearDown() + { + } + + /** + * Global test teardown + * + * @return void + */ + public static function tearDownAfterClass() + { + } +}