diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 0ca95ace51d..831aa15c68a 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -9,6 +9,7 @@ filter: - dev/* - doc/* - test/* + - htdocs/includes/* paths: - htdocs/* - scripts/* diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index f1f1218f554..0d927b7305b 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -76,19 +76,17 @@ if ($action == 'add') { $res = $object->create($user); - if ($res == 0) { - } else { - if ($res == - 3) { - $error = 1; - $action = "create"; - } - if ($res == - 4) { - $error = 2; - $action = "create"; - } + if ($res == - 3) { + $error = 1; + $action = "create"; + } + if ($res == - 4) { + $error = 2; + $action = "create"; } } - Header("Location: account.php"); + header("Location: account.php"); + exit; } else if ($action == 'edit') { if (! GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); @@ -134,7 +132,8 @@ if ($action == 'add') { $result = $object->delete($user); if ($result > 0) { - Header("Location: account.php"); + header("Location: account.php"); + exit; } } diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index 8d629175902..a749ff269e5 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -48,7 +48,7 @@ abstract class ActionsAdherentCardCommon /** - * Instantiation of DAO class + * Instantiation of DAO class. Init ->object * * @return int 0 * @deprecated Using getInstanceDao should not be used. @@ -83,18 +83,18 @@ abstract class ActionsAdherentCardCommon */ function getObject($id) { - $ret = $this->getInstanceDao(); + //$ret = $this->getInstanceDao(); - if (is_object($this->object) && method_exists($this->object,'fetch')) + /*if (is_object($this->object) && method_exists($this->object,'fetch')) { if (! empty($id)) $this->object->fetch($id); } else - { + {*/ $object = new Adherent($this->db); if (! empty($id)) $object->fetch($id); $this->object = $object; - } + //} } /** @@ -121,11 +121,11 @@ abstract class ActionsAdherentCardCommon // Creation user $nuser = new User($this->db); - $result=$nuser->create_from_member($this->object,$_POST["login"]); + $result=$nuser->create_from_member($this->object,GETPOST("login")); if ($result > 0) { - $result2=$nuser->setPassword($user,$_POST["password"],0,1,1); + $result2=$nuser->setPassword($user,GETPOST("password"),0,1,1); if ($result2) { $this->db->commit(); @@ -424,13 +424,14 @@ abstract class ActionsAdherentCardCommon if ($resql) { $obj = $this->db->fetch_object($resql); + + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } else { dol_print_error($this->db); } - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 1cc09394023..01ce37ee3a8 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2013-2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify @@ -28,6 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->load("members"); $langs->load("companies"); @@ -43,6 +44,11 @@ $search_ref=GETPOST("search_ref"); $search_lastname=GETPOST("search_lastname"); $search_firstname=GETPOST("search_firstname"); $search_login=GETPOST("search_login"); +$search_address=GETPOST("search_address"); +$search_zip=GETPOST("search_zip"); +$search_town=GETPOST("search_town"); +$search_state=GETPOST("search_state"); +$search_country=GETPOST("search_country"); $type=GETPOST("type"); $search_email=GETPOST("search_email"); $search_categ = GETPOST("search_categ",'int'); @@ -50,6 +56,8 @@ $catid = GETPOST("catid",'int'); $sall=GETPOST("sall"); $optioncss = GETPOST('optioncss','alpha'); +if ($statut < -1) $statut = ''; + $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -66,7 +74,7 @@ $hookmanager->initHooks(array('memberlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('member'); +$extralabels = $extrafields->fetch_name_optionals_label('adherent'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // List of fields to search into when doing a "search in all" @@ -88,7 +96,7 @@ $arrayfields=array( 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), - 'd.societe'=>array('label'=>$langs->trans("Company"), 'checked'=>1), + 'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1), 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), 'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1), 't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1), @@ -96,8 +104,10 @@ $arrayfields=array( 'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0), 'd.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), 'd.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0), - 'd.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0), - 'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0), + 'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0), + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), + /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0), + 'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/ 'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>500), 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), @@ -139,10 +149,14 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_address=""; $search_zip=""; $search_town=""; + $search_state=""; + $search_country=''; $search_morphy=""; $search_categ=""; $catid=""; $sall=""; + $statut=''; + $search_array_options=array(); } @@ -160,9 +174,11 @@ llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adhé $now=dol_now(); $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; -$sql.= " d.datefin,"; -$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; -$sql.= " t.libelle as type, t.cotisation"; +$sql.= " d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; +$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; +$sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; +$sql.= " t.libelle as type, t.cotisation,"; +$sql.= " state.code_departement as state_code, state.nom as state_name"; // Add fields for extrafields foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; // Add fields from hooks @@ -170,7 +186,10 @@ $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."adherent as d"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_adherent_type = t.rowid "; if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid); @@ -180,7 +199,7 @@ if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; $sql.= " AND d.entity IN (".getEntity('adherent', 1).")"; if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall); if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type); -if (isset($_GET["statut"]) || isset($_POST["statut"])) $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules +if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules if ($search_ref) { if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")"; @@ -189,6 +208,10 @@ if ($search_ref) if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); if ($search_login) $sql.= natural_search("d.login", $search_login); if ($search_email) $sql.= natural_search("d.email", $search_email); +if ($search_town) $sql.= natural_search("d.town",$search_town); +if ($search_zip) $sql.= natural_search("d.zip",$search_zip); +if ($search_state) $sql.= natural_search("state.nom",$search_state); +if ($search_country) $sql .= " AND d.country IN (".$search_country.')'; if ($filter == 'uptodate') $sql.=" AND datefin >= '".$db->idate($now)."'"; if ($filter == 'outofdate') $sql.=" AND (datefin IS NULL OR datefin < '".$db->idate($now)."')"; @@ -253,19 +276,23 @@ if ($resql) } $param=''; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($statut != "") $param.="&statut=".$statut; - if ($search_nom) $param.="&search_nom=".$search_nom; - if ($search_firstname) $param.="&search_firstname=".$search_firstname; - if ($search_lastname) $param.="&search_lastname=".$search_lastname; - if ($search_login) $param.="&search_login=".$search_login; - if ($search_email) $param.="&search_email=".$search_email; - if ($search_company) $param.="&search_company=".$search_company; - if ($search_zip) $param.="&search_zip=".$search_zip; - if ($search_town) $param.="&search_town=".$search_town; - if ($filter) $param.="&filter=".$filter; - if ($type > 0) $param.="&type=".$type; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($statut != "") $param.="&statut=".urlencode($statut); + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_nom) $param.="&search_nom=".urlencode($search_nom); + if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname); + if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); + if ($search_login) $param.="&search_login=".urlencode($search_login); + if ($search_email) $param.="&search_email=".urlencode($search_email); + if ($search_company) $param.="&search_company=".urlencode($search_company); + if ($search_address != '') $param.= "&search_address=".urlencode($search_address); + if ($search_town != '') $param.= "&search_town=".urlencode($search_town); + if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); + if ($search_state != '') $param.= "&search_state=".urlencode($search_state); + if ($search_country != '') $param.= "&search_country=".urlencode($search_country); + if ($filter) $param.="&filter=".urlencode($filter); + if ($type > 0) $param.="&type=".urlencode($type); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields foreach ($search_array_options as $key => $val) { @@ -325,15 +352,17 @@ if ($resql) if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'],$_SERVER["PHP_SELF"],'d.rowid','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.company','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.societe','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'],$_SERVER["PHP_SELF"],'d.login','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'],$_SERVER["PHP_SELF"],'d.morphy','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'],$_SERVER["PHP_SELF"],'t.libelle','',$param,'',$sortfield,$sortorder); 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($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'],$_SERVER["PHP_SELF"],'d.email','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'],$_SERVER["PHP_SELF"],'d.datefin','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'],$_SERVER["PHP_SELF"],'d.datefin','',$param,'align="center"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -350,7 +379,7 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'],$_SERVER["PHP_SELF"],"d.statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); @@ -360,66 +389,172 @@ if ($resql) print ''; // Ref - if (! empty($arrayfields['c.ref']['checked'])) + if (! empty($arrayfields['d.ref']['checked'])) { print ''; print ''; print ''; } - print ''; - print ''; + if (! empty($arrayfields['d.firstname']['checked'])) + { + print ''; + print ''; + } + + if (! empty($arrayfields['d.lastname']['checked'])) + { + print ''; + print ''; + } + + if (! empty($arrayfields['d.company']['checked'])) + { + print ''; + print ''; + } + + if (! empty($arrayfields['d.login']['checked'])) + { + print ''; + print ''; + } + + if (! empty($arrayfields['d.morphy']['checked'])) + { + print ''; + print ''; + } + + if (! empty($arrayfields['t.libelle']['checked'])) + { + print ''; + $listetype=$membertypestatic->liste_array(); + print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); + print ''; + } + + if (! empty($arrayfields['d.address']['checked'])) + { + print ''; + print ''; + } + + if (! empty($arrayfields['d.zip']['checked'])) + { + print ''; + print ''; + } + if (! empty($arrayfields['d.town']['checked'])) + { + print ''; + print ''; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print ''; + print ''; + print ''; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; + } + // Email + if (! empty($arrayfields['d.email']['checked'])) + { + print ''; + print ''; + } - print ''; - print ''; - - print ''; - print ''; - - print ''; - $listetype=$membertypestatic->liste_array(); - print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); + if (! empty($arrayfields['d.datefin']['checked'])) + { + print ''; + print ''; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + } + } + } + // 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['d.datec']['checked'])) + { + print ''; + print ''; + } + // Date modification + if (! empty($arrayfields['d.tms']['checked'])) + { + print ''; + print ''; + } + // Status + if (! empty($arrayfields['d.statut']['checked'])) + { + print ''; + $liststatus=array( + '-1'=>$langs->trans("Draft"), + '1'=>$langs->trans("Validated"), + '0'=>$langs->trans("Resiliated") + ); + print $form->selectarray('statut', $liststatus, $statut, -2); + print ''; + } + // Action column + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; print ''; - - print ' '; - - print ''; - print ''; - - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Status - print ' '; - - // Action column - print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print ''; - + print "\n"; $var=True; while ($i < $num && $i < $conf->liste_limit) { - $objp = $db->fetch_object($resql); + $obj = $db->fetch_object($resql); - $datefin=$db->jdate($objp->datefin); - $memberstatic->id=$objp->rowid; - $memberstatic->ref=$objp->rowid; - $memberstatic->lastname=$objp->lastname; - $memberstatic->firstname=$objp->firstname; - $memberstatic->statut=$objp->statut; + $datefin=$db->jdate($obj->datefin); + $memberstatic->id=$obj->rowid; + $memberstatic->ref=$obj->rowid; + $memberstatic->lastname=$obj->lastname; + $memberstatic->firstname=$obj->firstname; + $memberstatic->societe=$obj->company; + $memberstatic->statut=$obj->statut; $memberstatic->datefin= $datefin; - - if (! empty($objp->fk_soc)) { - $memberstatic->socid = $objp->fk_soc; - $memberstatic->fetch_thirdparty(); + $memberstatic->socid = $obj->fk_soc; + + if (! empty($obj->fk_soc)) { + $memberstatic->fetch_thirdparty(); $companyname=$memberstatic->thirdparty->name; } else { - $companyname=$objp->company; + $companyname=$obj->company; } $var=!$var; @@ -430,85 +565,188 @@ if ($resql) print ''.($i+1).''; } - // Ref - print ""; - print $memberstatic->getNomUrl(1); - print "\n"; - + // Ref + if (! empty($arrayfields['d.ref']['checked'])) + { + print ""; + print $memberstatic->getNomUrl(1); + print "\n"; + } // Lastname - print "rowid\">"; - print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : ''); - print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : ''); - print (! empty($companyname) ? dol_trunc($companyname, 32) : ''); - print "\n"; - - // Login - print "".$objp->login."\n"; - - // Type - $membertypestatic->id=$objp->type_id; - $membertypestatic->libelle=$objp->type; - print ''; - print $membertypestatic->getNomUrl(1,32); - print ''; - - // Moral/Physique - print "".$memberstatic->getmorphylib($objp->morphy)."\n"; - + if (! empty($arrayfields['d.lastname']['checked'])) + { + print ""; + print $obj->lastname; + print "\n"; + } + // Firstname + if (! empty($arrayfields['d.firstname']['checked'])) + { + print ""; + print $obj->firstname; + print "\n"; + } + // Company + if (! empty($arrayfields['d.company']['checked'])) + { + print ""; + print $companyname; + print "\n"; + } + // Login + if (! empty($arrayfields['d.login']['checked'])) + { + print "".$obj->login."\n"; + } + // Moral/Physique + if (! empty($arrayfields['d.morphy']['checked'])) + { + print "".$memberstatic->getmorphylib($obj->morphy)."\n"; + } + // Type label + if (! empty($arrayfields['t.libelle']['checked'])) + { + $membertypestatic->id=$obj->type_id; + $membertypestatic->libelle=$obj->type; + print ''; + print $membertypestatic->getNomUrl(1,32); + print ''; + } + // Address + if (! empty($arrayfields['d.address']['checked'])) + { + print ''; + print $obj->address; + print ''; + } + // Town + if (! empty($arrayfields['d.town']['checked'])) + { + print ''; + print $obj->town; + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Zip + if (! empty($arrayfields['d.zip']['checked'])) + { + print ''; + print $obj->zip; + print ''; + if (! $i) $totalarray['nbfield']++; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print "".$obj->state_name."\n"; + if (! $i) $totalarray['nbfield']++; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + $tmparray=getCountry($obj->country,'all'); + print $tmparray['label']; + print ''; + if (! $i) $totalarray['nbfield']++; + } // EMail - print "".dol_print_email($objp->email,0,0,1)."\n"; - - $parameters=array('obj' => $obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Statut - print ''; - print $memberstatic->LibStatut($objp->statut,$objp->cotisation,$datefin,2); - print ""; - + if (! empty($arrayfields['d.email']['checked'])) + { + print "".dol_print_email($obj->email,0,0,1)."\n"; + } // End of subscription date - if ($datefin) + $datefin=$db->jdate($obj->datefin); + if (! empty($arrayfields['d.datefin']['checked'])) { - print ''; - print dol_print_date($datefin,'day'); - if ($memberstatic->hasDelay()) { - print " ".img_warning($langs->trans("SubscriptionLate")); - } - print ''; + if ($datefin) + { + print ''; + print dol_print_date($datefin,'day'); + if ($memberstatic->hasDelay()) { + print " ".img_warning($langs->trans("SubscriptionLate")); + } + print ''; + } + else + { + print ''; + if ($obj->cotisation == 'yes') + { + print $langs->trans("SubscriptionNotReceived"); + if ($obj->statut > 0) print " ".img_warning(); + } + else + { + print ' '; + } + print ''; + } } - else + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - print ''; - if ($objp->cotisation == 'yes') - { - print $langs->trans("SubscriptionNotReceived"); - if ($objp->statut > 0) print " ".img_warning(); - } - else - { - print ' '; - } - print ''; + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } } - - // Actions + // 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['d.datec']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['d.tms']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['d.statut']['checked'])) + { + print ''; + print $memberstatic->LibStatut($obj->statut,$obj->cotisation,$datefin,2); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action column print ''; if ($user->rights->adherent->creer) { - print "rowid."&action=edit&backtopage=1\">".img_edit().""; + print "rowid."&action=edit&backtopage=1\">".img_edit().""; } print ' '; - if ($user->rights->adherent->supprimer && $objp->statut == -1) + if ($user->rights->adherent->supprimer && $obj->statut == -1) { - print "rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png').""; + print "rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png').""; } - if ($user->rights->adherent->supprimer && $objp->statut == 1) + if ($user->rights->adherent->supprimer && $obj->statut == 1) { - print "rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png').""; + print "rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png').""; } print ""; - + if (! $i) $totalarray['nbfield']++; + print "\n"; $i++; } diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 588170fbb90..5a142f3e51e 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -119,19 +119,19 @@ function create_script_table($list) global $sortby,$bc,$langs; $var=true; - if (isset($_GET['order']) && ($_GET['order'] == "asc" || $_GET['order'] =="desc")) { - $order = $_GET['order']; + if (GETPOT('order') == "asc" || GETPOST('order') =="desc") { + $order = GETPOST('order'); } else { $order = "asc"; } - if (isset($_GET['sort'])) { - switch ($_GET['sort']) { + if (GETPOST('order')) { + switch (GETPOST('order')) { case "mtime": case "size": case "reloads": case "hits": - $sortby = $_GET['sort']; + $sortby = GETPOST('sort'); ($order == "asc" ? uasort($list, 'compare') : uasort($list, 'revcompare')); break; default: diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index b827fe88737..175aaa65665 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -318,7 +318,7 @@ function backup_tables($outputfile, $tables='*') $columns = count($row); for($j=0; $j<$columns; $j++) { // Processing each columns of the row to ensure that we correctly save the value (eg: add quotes for string - in fact we add quotes for everything, it's easier) - if ($row[$j] == null and !is_string($row[$j])) { + if ($row[$j] == null && !is_string($row[$j])) { // IMPORTANT: if the field is NULL we set it NULL $row[$j] = 'NULL'; } elseif(is_string($row[$j]) && $row[$j] == '') { diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 3db5dd93e49..ecc6b6a0166 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -417,14 +417,7 @@ if ($id) if (empty($reshook)) { - if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') - { - fieldList($fieldlist,$obj,$tabname[$id],'hide'); - } - else - { - fieldList($fieldlist,$obj,$tabname[$id],'add'); - } + fieldListWebsites($fieldlist,$obj,$tabname[$id],'add'); } if ($id == 4) print ''; @@ -487,46 +480,9 @@ if ($id) */ $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); - else $valuetoshow=$langs->trans("Amount"); - $align='right'; - } - if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $sortable=0; } - if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $sortable=0; } - if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { - $valuetoshow=$langs->trans("Label"); - if ($id != 25) $valuetoshow.="*"; - } - if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; } - if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } - if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } - if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); } - if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } - if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); } - if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); } - if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); } - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } - if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; } - if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; } - if ($fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='account_parent') { $valuetoshow=$langs->trans("Accountsparent"); } - if ($fieldlist[$field]=='pcg_type') { $valuetoshow=$langs->trans("Pcg_type"); } - if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } - if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); } - if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } - if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } // Affiche nom du champ if ($showfield) @@ -534,8 +490,6 @@ if ($id) print getTitleFieldOfList($valuetoshow,0,$_SERVER["PHP_SELF"],($sortable?$fieldlist[$field]:''),($page?'page='.$page.'&':'').'&id='.$id,"","align=".$align,$sortfield,$sortorder); } } - // Favorite - Only activated on country dictionary - if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"),0,$_SERVER["PHP_SELF"],"favorite",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList($langs->trans("Status"),0,$_SERVER["PHP_SELF"],"status",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder); print getTitleFieldOfList(''); @@ -562,7 +516,7 @@ if ($id) $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); + if (empty($reshook)) fieldListWebsites($fieldlist,$obj,$tabname[$id],'edit'); print ' '; print ' '; @@ -582,172 +536,6 @@ if ($id) $showfield=1; $align="left"; $valuetoshow=$obj->$fieldlist[$field]; - if ($value == 'type_template') - { - $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; - } - if ($value == 'element') - { - $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; - } - else if ($value == 'source') - { - $valuetoshow = isset($sourceList[$valuetoshow])?$sourceList[$valuetoshow]:$valuetoshow; - } - else if ($valuetoshow=='all') { - $valuetoshow=$langs->trans('All'); - } - else if ($fieldlist[$field]=='country') { - if (empty($obj->country_code)) - { - $valuetoshow='-'; - } - else - { - $key=$langs->trans("Country".strtoupper($obj->country_code)); - $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country); - } - } - else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm' || $fieldlist[$field] == 'deductible') { - $valuetoshow=yn($valuetoshow); - $align="center"; - } - else if ($fieldlist[$field]=='price' || preg_match('/^amount/i',$fieldlist[$field])) { - $valuetoshow=price($valuetoshow); - } - else if ($fieldlist[$field]=='libelle_facture') { - $langs->load("bills"); - $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - $valuetoshow=nl2br($valuetoshow); - } - else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { - $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { - $langs->load("propal"); - $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { - $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') { - $key=$langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') { - $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') { - $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') { - $key=$langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { - $langs->load('agenda'); - $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { - $langs->load("bills"); - $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { - $langs->load("bills"); - $key=$langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') { - $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { - $langs->load("orders"); - $key=$langs->trans($obj->code); - $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field]; - } - else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { - $langs->load("sendings"); - $key=$langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); - } - else if ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format') - { - $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); - } - else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') - { - $langs->load('trips'); - $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { - $showfield=0; - } - else if ($fieldlist[$field]=='unicode') { - $valuetoshow = $langs->getCurrencySymbol($obj->code,1); - } - else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { - $langs->load("products"); - $valuetoshow=$langs->trans($obj->$fieldlist[$field]); - } - else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { - $langs->load("products"); - $valuetoshow = $langs->trans($obj->$fieldlist[$field]); - } - else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) - { - $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$fieldlist[$field]); - } - - else if ($fieldlist[$field]=='localtax1_type') { - if ($obj->localtax1 != 0) - $valuetoshow=$localtax_typeList[$valuetoshow]; - else - $valuetoshow = ''; - $align="center"; - } - else if ($fieldlist[$field]=='localtax2_type') { - if ($obj->localtax2 != 0) - $valuetoshow=$localtax_typeList[$valuetoshow]; - else - $valuetoshow = ''; - $align="center"; - } - else if ($fieldlist[$field]=='localtax1') { - $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - if ($obj->localtax1 == 0) - $valuetoshow = ''; - $align="right"; - } - else if ($fieldlist[$field]=='localtax2') { - $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - if ($obj->localtax2 == 0) - $valuetoshow = ''; - $align="right"; - } - else if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) - { - $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - $align="right"; - } - else if (in_array($fieldlist[$field],array('recuperableonly'))) - { - $align="center"; - } - else if ($fieldlist[$field]=='accountancy_code' || $fieldlist[$field]=='accountancy_code_sell' || $fieldlist[$field]=='accountancy_code_buy') { - $valuetoshow = length_accountg($valuetoshow); - } // Show value for field if ($showfield) print ''.$valuetoshow.''; @@ -757,16 +545,6 @@ if ($id) // Can an entry be erased or disabled ? $iserasable=1;$isdisable=1; // true by default - if (isset($obj->code) && $id != 10) - { - if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) { $iserasable = 0; $isdisable = 0; } - else if ($obj->code == 'RECEP') { $iserasable = 0; $isdisable = 0; } - else if ($obj->code == 'EF0') { $iserasable = 0; $isdisable = 0; } - } - - if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { $iserasable=0; } - if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $isdisable=0; $isdisable = 0; } - $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; // Favorite @@ -823,7 +601,7 @@ $db->close(); * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldList($fieldlist, $obj='', $tabname='', $context='') +function fieldListWebsites($fieldlist, $obj='', $tabname='', $context='') { global $conf,$langs,$db; global $form; diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index a5020d4e112..bc5b4378c0c 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -167,6 +167,8 @@ class DolibarrApiInit extends DolibarrApi */ public function login($login, $password, $entity = 0) { + global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; + // Authentication mode if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 67f8c710bb7..bebf9a6667b 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -70,6 +70,7 @@ class DolibarrApiAccess implements iAuthenticate { global $db; + $login = ''; $stored_key = ''; $userClass = Defaults::$userIdentifierClass; @@ -95,11 +96,15 @@ class DolibarrApiAccess implements iAuthenticate throw new RestException(503, 'Error when fetching user api_key :'.$db->error_msg); } - if ( $stored_key != $_GET['api_key']) { + if ($stored_key != $_GET['api_key']) { $userClass::setCacheIdentifier($_GET['api_key']); return false; } + if (! $login) + { + throw new RestException(503, 'Error when searching logn user fro mapi key'); + } $fuser = new User($db); if(! $fuser->fetch('',$login)) { throw new RestException(503, 'Error when fetching user :'.$fuser->error); diff --git a/htdocs/categories/class/api_category.class.php b/htdocs/categories/class/api_category.class.php index e17bb273758..f5a5b1f037d 100644 --- a/htdocs/categories/class/api_category.class.php +++ b/htdocs/categories/class/api_category.class.php @@ -45,6 +45,7 @@ class CategoryApi extends DolibarrApi 2 => 'customer', 3 => 'member', 4 => 'contact', + 5 => 'account', ); /** diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 4cd38a693b6..b602bc0076d 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Philippe Grand * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2016 Charlie Benke * * 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 @@ -49,6 +49,8 @@ class Categorie extends CommonObject const TYPE_MEMBER = 3; const TYPE_CONTACT = 4; const TYPE_USER = 4; // categorie contact and user are same + // bank account + const TYPE_ACCOUNT = 5; /** * @var array ID mapping from type string @@ -62,6 +64,7 @@ class Categorie extends CommonObject 'member' => 3, 'contact' => 4, 'user' => 4, + 'account' => 5, ); /** * @var array Foreign keys mapping from type string @@ -75,6 +78,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'socpeople', 'user' => 'user', + 'account' => 'account', ); /** * @var array Category tables mapping from type string @@ -88,6 +92,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'contact', 'user' => 'user', + 'account' => 'account', ); /** * @var array Object class mapping from type string @@ -101,6 +106,7 @@ class Categorie extends CommonObject 'member' => 'Adherent', 'contact' => 'Contact', 'user' => 'User', + 'account' => 'Account', ); /** * @var array Object table mapping from type string @@ -114,6 +120,7 @@ class Categorie extends CommonObject 'member' => 'adherent', 'contact' => 'socpeople', 'user' => 'user', + 'account' => 'bank_account', ); public $element='category'; @@ -138,6 +145,8 @@ class Categorie extends CommonObject * @see Categorie::TYPE_CUSTOMER * @see Categorie::TYPE_MEMBER * @see Categorie::TYPE_CONTACT + * @see Categorie::TYPE_USER + * @see Categorie::TYPE_ACCOUNT */ var $type; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 02b83fcaef8..f7102bc44e2 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -53,6 +53,7 @@ elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCateg elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoriesArea"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoriesArea"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactsCategoriesArea"); +elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesArea"); else $title=$langs->trans("CategoriesArea"); $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 783326c1e4f..72c184af113 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -93,12 +93,13 @@ $form = new Form($db); if ($object->id) { - $title=$langs->trans("ProductsCategoryShort"); if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); + elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); + else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); dol_fiche_head($head, 'photos', $title, 0, 'category'); diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index f3969793ef0..9d88098e56b 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -149,6 +149,7 @@ elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCateg elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); +elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index a1486ff344f..284add47add 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -107,7 +107,14 @@ if ($id > 0 && $removeelem > 0) $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; - } + } + else if ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $tmpobject = new Account($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'account'; + } $result=$object->del_type($tmpobject,$elementtype); if ($result < 0) dol_print_error('',$object->error); @@ -169,6 +176,7 @@ elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCateg elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); +elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); @@ -580,6 +588,59 @@ if($object->type == Categorie::TYPE_CONTACT) } } +// List of accounts +if ($object->type == Categorie::TYPE_ACCOUNT) +{ + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $accounts = $object->getObjectsInCateg("account"); + if ($accounts < 0) + { + dol_print_error($db, $accounts->error, $accounts->errors); + } + else + { + print "
"; + print "\n"; + print '\n"; + + if (count($accounts) > 0) + { + $var=true; + foreach ($accounts as $key => $account) + { + $var=!$var; + print "\t\n"; + print '\n"; + print '\n"; + print '\n"; + // Link to delete from category + print '\n"; + } + } + else + { + print ""; + } + print "
'.$langs->trans("Account")."
'; + print $account->getNomUrl(1,0); + print "'.$account->bank."'.$account->number."'; + $typeid=$object->type; + $permission=0; + if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer; + if ($permission) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } + print "
'.$langs->trans("ThisCategoryHasNoAccount")."
\n"; + } +} llxFooter(); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 9734602c41d..7a2f231879d 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1173,7 +1173,7 @@ if ($id > 0) // Clone event if($action == 'clone') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . GETPOST('id'), $langs->trans('CloneAction'), $langs->trans('ConfirmCloneAction', $object->label), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . GETPOST('id'), $langs->trans('CloneAction'), $langs->trans('ConfirmCloneEvent', $object->label), 'confirm_clone', $formquestion, 'yes', 1); print $formconfirm; } diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index cfb3bc92333..31290318742 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -309,7 +309,7 @@ if ($resql) print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre(""); print "\n"; @@ -432,7 +432,7 @@ if ($resql) print ''; // Status/Percent - print ''.$actionstatic->LibStatut($obj->percent,6).''; + print ''.$actionstatic->LibStatut($obj->percent,6).''; print ''; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 9a7d0349f41..1a54340e7ce 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -948,7 +948,7 @@ else } } - print '

'; + print ''; } // Affichage formulaire de TEST @@ -1052,20 +1052,25 @@ else print ''; - // Ref - print ''; + $linkback = ''.$langs->trans("BackToList").''; + + print ''; + print ''; + // Topic - print ''; + print ''; // From - print ''; + print ''; // To - print ''; + print ''; // Status - print ''; + print ''; // Nb of distinct emails - print '
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'id', $linkback); + print '
'.$langs->trans("MailTitle").''.$object->titre.'
'.$langs->trans("MailTitle").''.$object->titre.'
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from,0,0,0,0,1).'
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from,0,0,0,0,1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto,0,0,0,0,1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto,0,0,0,0,1).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'; + print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail?$object->nbemail:img_warning('').' '.$langs->trans("NoTargetYet").''); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 1282aab5558..2ce7d5c110d 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2015 Laurent Destailleur + * Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2014 Florian Henry * @@ -227,7 +227,7 @@ if ($object->fetch($id) >= 0) // Show email selectors if ($allowaddtarget && $user->rights->mailing->creer) { - print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"),($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"),1):''),''); + print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"),1):''), 'title_generic'); print ''; print ''; @@ -398,12 +398,12 @@ if ($object->fetch($id) >= 0) print ''; print ''; + $cleartext=''; if ($allowaddtarget) { - $cleartext='
'.$langs->trans("ToClearAllRecipientsClickHere").': '.''; + $cleartext=$langs->trans("ToClearAllRecipientsClickHere").' '.''; } - - print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$nbtotalofrecords,'',0,'','',$limit); - + print_barre_liste($langs->trans("MailSelectedRecipients"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$cleartext,$num,$nbtotalofrecords,'title_generic',0,'','',$limit); + print ''; print "\n\n"; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 599173a1869..62cf5f2436f 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -17,15 +17,14 @@ */ /** - * \file class/advtargetemailing.class.php - * \ingroup advtargetemailing + * \file comm/mailing/class/advtargetemailing.class.php + * \ingroup mailing * \brief This file is an example CRUD class file (Create/Read/Update/Delete) - */ /** - * Put your class' description here + * Class to manage advanced emailing target selector */ class AdvanceTargetingMailing extends CommonObject { @@ -293,7 +292,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user=0, $notrigger=0) + function update($user, $notrigger=0) { global $conf, $langs; $error=0; @@ -737,9 +736,9 @@ class AdvanceTargetingMailing extends CommonObject * * @param string $column_to_test column to test * @param string $criteria Use %% as magic caracters. For exemple to find all item like jean, joe, jim, you can input j%%, you can also use ; as separator for value, - * and use ! for except this value. + * and use ! for except this value. * For exemple jean;joe;jim%%;!jimo;!jima%> will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima - * @return int <0 if KO, >0 if OK + * @return string Sql to use for the where condition */ public function transformToSQL($column_to_test,$criteria) { $return_sql_criteria = '('; diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index ac6b5727c58..69fb747f364 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -17,8 +17,9 @@ */ /** - * \file advtargetemailing/class/html.formadvtragetemaling.class.php - * \brief Fichier de la classe des fonctions predefinie de composants html advtargetemaling + * \file comm/mailing/class/html.formadvtragetemaling.class.php + * \ingroup mailing + * \brief Fichier de la classe des fonctions predefinie de composants html advtargetemaling */ /** @@ -38,8 +39,6 @@ class FormAdvTargetEmailing extends Form global $langs; $this->db = $db; - - return 1; } /** @@ -88,52 +87,53 @@ class FormAdvTargetEmailing extends Form function multiselectCountry($htmlname = 'country_id', $selected_array=array()) { global $conf, $langs; - $langs->load ( "dict" ); - + $langs->load("dict"); + $maxlength = 0; + $out = ''; - $countryArray = array (); + $countryArray = array(); $label = array (); - $options_array = array (); + $options_array = array(); $sql = "SELECT rowid, code as code_iso, label"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_country"; $sql .= " WHERE active = 1 AND code<>''"; $sql .= " ORDER BY code ASC"; - dol_syslog ( get_class ( $this ) . "::select_country sql=" . $sql ); - $resql = $this->db->query ( $sql ); + dol_syslog(get_class($this) . "::select_country sql=" . $sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows ( $resql ); + $num = $this->db->num_rows($resql); $i = 0; if ($num) { $foundselected = false; - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object ( $resql ); $countryArray [$i] ['rowid'] = $obj->rowid; $countryArray [$i] ['code_iso'] = $obj->code_iso; - $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv ( "Country" . $obj->code_iso ) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv ( "Country" . $obj->code_iso ) : ($obj->label != '-' ? $obj->label : '')); - $label [$i] = $countryArray [$i] ['label']; + $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso ) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv ( "Country" . $obj->code_iso ) : ($obj->label != '-' ? $obj->label : '')); + $label[$i] = $countryArray[$i]['label']; $i ++; } - array_multisort ( $label, SORT_ASC, $countryArray ); + array_multisort($label, SORT_ASC, $countryArray); - foreach ( $countryArray as $row ) { - $label = dol_trunc ( $row ['label'], $maxlength, 'middle' ); - if ($row ['code_iso']) - $label .= ' (' . $row ['code_iso'] . ')'; + foreach ($countryArray as $row) { + $label = dol_trunc($row['label'], $maxlength, 'middle'); + if ($row['code_iso']) + $label .= ' (' . $row['code_iso'] . ')'; - $options_array [$row ['rowid']] = $label; + $options_array[$row['rowid']] = $label; } } } else { - dol_print_error ( $this->db ); + dol_print_error($this->db); } - return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + return $this->advMultiselectarray($htmlname, $options_array, $selected_array); } /** @@ -150,7 +150,7 @@ class FormAdvTargetEmailing extends Form $options_array = array (); - + $sql_usr = ''; $sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; $sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")"; @@ -196,10 +196,10 @@ class FormAdvTargetEmailing extends Form foreach ($langs_available as $key => $value) { $label = $value; - $options_array [$key] = $label; + $options_array[$key] = $label; } asort($options_array); - return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + return $this->advMultiselectarray($htmlname, $options_array, $selected_array); } /** @@ -246,16 +246,18 @@ class FormAdvTargetEmailing extends Form $sql .= ' WHERE ' . $InfoFieldList [3]; } } - if (! empty ( $InfoFieldList [1] ) && $key == 'ts_payeur') { + if (! empty($InfoFieldList[1])) { $sql .= " ORDER BY nom"; } // $sql.= ' WHERE entity = '.$conf->entity; - dol_syslog ( get_class ( $this ) . "::".__METHOD__,LOG_DEBUG); - $resql = $this->db->query ( $sql ); + $options_array = array(); + + dol_syslog(get_class($this) . "::".__METHOD__,LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows ( $resql ); + $num = $this->db->num_rows($resql); $i = 0; if ($num) { while ( $i < $num ) { @@ -269,15 +271,15 @@ class FormAdvTargetEmailing extends Form } } - return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + return $this->advMultiselectarray($htmlname, $options_array, $selected_array); } /** * Return combo list with people title * - * @param string $htmlname Name of HTML select combo field - * @param array $selected_array array - * @return string HTML combo + * @param string $htmlname Name of HTML select combo field + * @param array $selected_array Array + * @return string HTML combo */ function multiselectCivility($htmlname='civilite_id',$selected_array = array()) { @@ -356,23 +358,21 @@ class FormAdvTargetEmailing extends Form // Find if keys is in selected array value if (is_array($selected_array) && count($selected_array)>0) { - $intersect_array = array_intersect_key ( $options_array, array_flip ( $selected_array ) ); + $intersect_array = array_intersect_key($options_array, array_flip($selected_array)); } else { $intersect_array=array(); } - if (count ( $options_array ) > 0) { - foreach ( $options_array as $keyoption => $valoption ) { + if (count($options_array) > 0) { + foreach ($options_array as $keyoption => $valoption) { // If key is in intersect table then it have to e selected - if (count ( $intersect_array ) > 0) { + $selected = ''; + if (count ( $intersect_array ) > 0) { if (array_key_exists ( $keyoption, $intersect_array )) { - $selected = ' selected="selected" '; - } else { - $selected = ''; + $selected = ' selected="selected"'; } } - - $return .= ''; + $return .= '' . $valoption . ''; } } @@ -455,8 +455,8 @@ class FormAdvTargetEmailing extends Form * selectAdvtargetemailingTemplate * * @param string $htmlname control name - * @param number $selected defaut selected - * @param number $showempty empty lines + * @param integer $selected defaut selected + * @param integer $showempty empty lines * * @return string HTML combo */ diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3d43d6b00f2..56c3839dcb6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -780,7 +780,7 @@ class Propal extends CommonObject */ function create($user, $notrigger=0) { - global $langs,$conf,$mysoc,$hookmanager; + global $conf,$hookmanager; $error=0; $now=dol_now(); @@ -1080,7 +1080,7 @@ class Propal extends CommonObject */ function createFromClone($socid=0) { - global $db, $user,$langs,$conf,$hookmanager; + global $user,$conf,$hookmanager; dol_include_once('/projet/class/project.class.php'); @@ -1214,7 +1214,6 @@ class Propal extends CommonObject */ function fetch($rowid,$ref='') { - global $conf; $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; @@ -1508,7 +1507,7 @@ class Propal extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - global $conf,$langs; + global $conf; $error=0; $now=dol_now(); @@ -1868,7 +1867,6 @@ class Propal extends CommonObject */ function reopen($user, $statut, $note='', $notrigger=0) { - global $langs,$conf; $this->statut = $statut; $error=0; @@ -1979,7 +1977,7 @@ class Propal extends CommonObject $outputlangs->setDefaultLang($newlang); } //$ret=$object->fetch($id); // Reload to get new records - $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $this->generateDocument($modelpdf, $outputlangs); } // Call trigger @@ -2082,7 +2080,7 @@ class Propal extends CommonObject */ function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC') { - global $conf,$user; + global $user; $ga = array(); @@ -2247,7 +2245,7 @@ class Propal extends CommonObject */ function delete($user, $notrigger=0) { - global $conf,$langs; + global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; @@ -2610,7 +2608,7 @@ class Propal extends CommonObject */ function initAsSpecimen() { - global $user,$langs,$conf; + global $langs; // Charge tableau des produits prodids $prodids = array(); @@ -2696,7 +2694,7 @@ class Propal extends CommonObject */ function load_state_board() { - global $conf, $user; + global $user; $this->nb=array(); $clause = "WHERE"; @@ -2741,7 +2739,7 @@ class Propal extends CommonObject */ function getNextNumRef($soc) { - global $conf, $db, $langs; + global $conf,$langs; $langs->load("propal"); if (! empty($conf->global->PROPALE_ADDON)) @@ -2942,7 +2940,7 @@ class Propal extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$user,$langs; + global $conf,$langs; $langs->load("propale"); @@ -3196,7 +3194,7 @@ class PropaleLigne extends CommonObjectLine */ function insert($notrigger=0) { - global $conf,$langs,$user; + global $conf,$user; $error=0; @@ -3332,7 +3330,7 @@ class PropaleLigne extends CommonObjectLine */ function delete() { - global $conf,$langs,$user; + global $conf,$user; $error=0; $this->db->begin(); @@ -3383,7 +3381,7 @@ class PropaleLigne extends CommonObjectLine */ function update($notrigger=0) { - global $conf,$langs,$user; + global $conf,$user; $error=0; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a0babc4d972..a22e937da87 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012 Cedric Salvador @@ -204,7 +204,7 @@ class Commande extends CommonOrder */ function getNextNumRef($soc) { - global $db, $langs, $conf; + global $langs, $conf; $langs->load("order"); if (! empty($conf->global->COMMANDE_ADDON)) @@ -239,7 +239,7 @@ class Commande extends CommonOrder } else { - dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); + dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } } @@ -500,7 +500,6 @@ class Commande extends CommonOrder */ function set_reopen($user) { - global $conf,$langs; $error=0; if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED) @@ -560,7 +559,7 @@ class Commande extends CommonOrder */ function cloture($user) { - global $conf, $langs; + global $conf; $error=0; @@ -697,7 +696,7 @@ class Commande extends CommonOrder */ function create($user, $notrigger=0) { - global $conf,$langs,$mysoc,$hookmanager; + global $conf,$langs; $error=0; // Clean parameters @@ -971,7 +970,7 @@ class Commande extends CommonOrder */ function createFromClone($socid=0) { - global $conf,$user,$langs,$hookmanager; + global $user,$hookmanager; $error=0; @@ -1061,7 +1060,7 @@ class Commande extends CommonOrder */ function createFromProposal($object) { - global $db, $conf,$user,$langs,$hookmanager; + global $conf,$user,$hookmanager; dol_include_once('/core/class/extrafields.class.php'); @@ -1134,7 +1133,7 @@ class Commande extends CommonOrder // get extrafields from original line $object->fetch_optionals($object->id); - $e = new ExtraFields($db); + $e = new ExtraFields($this->db); $element_extrafields = $e->fetch_name_optionals_label($this->element); foreach($object->array_options as $options_key => $value) { @@ -1495,7 +1494,6 @@ class Commande extends CommonOrder */ function fetch($id, $ref='', $ref_ext='', $ref_int='') { - global $conf; // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; @@ -1851,10 +1849,9 @@ class Commande extends CommonOrder * Note: For a dedicated shipment, the fetch_lines load the qty_asked and qty_shipped. This function return qty_shipped cuulated for order * * @param int $filtre_statut Filter on status - * @param int $fk_product Filter on a product * @return int <0 if KO, Nb of lines found if OK */ - function loadExpeditions($filtre_statut=-1, $fk_product=0) + function loadExpeditions($filtre_statut=-1) { $this->expeditions = array(); @@ -1983,7 +1980,6 @@ class Commande extends CommonOrder */ function deleteline($lineid) { - global $user; if ($this->statut == self::STATUS_DRAFT) { @@ -2262,7 +2258,7 @@ class Commande extends CommonOrder */ function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='c.date_commande', $sortorder='DESC') { - global $conf,$user; + global $user; $ga = array(); @@ -2430,7 +2426,7 @@ class Commande extends CommonOrder */ function classifyBilled(User $user) { - global $conf, $user, $langs; + global $user; $error = 0; $this->db->begin(); @@ -2698,7 +2694,6 @@ class Commande extends CommonOrder */ function update($user=null, $notrigger=0) { - global $conf, $langs; $error=0; // Clean parameters @@ -3205,7 +3200,7 @@ class Commande extends CommonOrder */ function initAsSpecimen() { - global $user,$langs,$conf; + global $langs; dol_syslog(get_class($this)."::initAsSpecimen"); @@ -3287,7 +3282,7 @@ class Commande extends CommonOrder */ function load_state_board() { - global $conf, $user; + global $user; $this->nb=array(); $clause = "WHERE"; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 811e7320385..5878b640dc7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent @@ -991,6 +991,7 @@ if ($resql) if (! empty($arrayfields['c.facture']['checked'])) { print '
'; + if (! $i) $totalarray['nbfield']++; } // Action column diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 102e6a6861a..e6043167b22 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; @@ -131,6 +132,10 @@ if ($_POST["action"] == 'add') $id = $account->create($user); if ($id > 0) { + // Category association + $categories = GETPOST('categories'); + $account->setCategories($categories); + $_GET["id"]=$id; // Force chargement page en mode visu } else { @@ -207,6 +212,10 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) $result = $account->update($user); if ($result >= 0) { + // Category association + $categories = GETPOST('categories'); + $account->setCategories($categories); + $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu } else @@ -337,6 +346,20 @@ if ($action == 'create') print ''; print ''; + // Tags-Categories + if ($conf->categorie->enabled) + { + print '"; + } + // Comment print ''; print '\n"; + // Categories + if($conf->categorie->enabled) { + print '"; + } + print ''; print ''; @@ -834,6 +864,20 @@ else print ''; + // Tags-Categories + if ($conf->categorie->enabled) + { + print '"; + } + // Comment print ''; print ''; + print ''; } print "
'.yn($obj->billed).'
'.$langs->trans("Web").'
'.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); + $c = new Categorie($db); + $cats = $c->containing($account->id,Categorie::TYPE_ACCOUNT); + foreach($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print "
'.$langs->trans("Comment").''; @@ -591,6 +614,13 @@ else if ($account->url) print ''; print "
'.$langs->trans("Categories").''; + print $form->showCategories($account->id,'account',1); + print "
'.$langs->trans("Comment").''.dol_htmlentitiesbr($account->comment).'
url).'">'; print '
'.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); + $c = new Categorie($db); + $cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT); + foreach($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print "
'.$langs->trans("Comment").''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 478633490f8..92c21742baa 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -893,6 +893,49 @@ class Account extends CommonObject } } + /** + * Sets object to supplied categories. + * + * Deletes object from existing categories not supplied. + * Adds it to non existing supplied categories. + * Existing categories are left untouch. + * + * @param int[]|int $categories Category or categories IDs + */ + public function setCategories($categories) { + // Handle single category + if (! is_array($categories)) { + $categories = array($categories); + } + + // Get current categories + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $c = new Categorie($this->db); + $existing = $c->containing($this->id, Categorie::TYPE_ACCOUNT, 'id'); + + // Diff + if (is_array($existing)) { + $to_del = array_diff($existing, $categories); + $to_add = array_diff($categories, $existing); + } else { + $to_del = array(); // Nothing to delete + $to_add = $categories; + } + + // Process + foreach($to_del as $del) { + if ($c->fetch($del) > 0) { + $c->del_type($this, 'account'); + } + } + foreach ($to_add as $add) { + if ($c->fetch($add) > 0) { + $c->add_type($this, 'account'); + } + } + + return; + } /** * Delete bank account from database diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8fee9cc5758..bea200f2656 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Cédric Salvador @@ -734,7 +734,7 @@ class Facture extends CommonInvoice */ function createFromClone($socid=0) { - global $conf,$user,$langs,$hookmanager; + global $user,$hookmanager; $error=0; @@ -849,7 +849,7 @@ class Facture extends CommonInvoice */ function createFromOrder($object) { - global $conf,$user,$langs,$hookmanager; + global $user,$hookmanager; $error=0; @@ -1289,7 +1289,6 @@ class Facture extends CommonInvoice */ function update($user=null, $notrigger=0) { - global $conf, $langs; $error=0; // Clean parameters @@ -1682,7 +1681,6 @@ class Facture extends CommonInvoice */ function set_paid($user,$close_code='',$close_note='') { - global $conf,$langs; $error=0; if ($this->paye != 1) @@ -1740,7 +1738,6 @@ class Facture extends CommonInvoice */ function set_unpaid($user) { - global $conf,$langs; $error=0; $this->db->begin(); @@ -1790,9 +1787,6 @@ class Facture extends CommonInvoice */ function set_canceled($user,$close_code='',$close_note='') { - global $conf,$langs; - - $error=0; dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); @@ -2463,6 +2457,7 @@ class Facture extends CommonInvoice */ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null) { + global $conf,$user; // Deprecation warning if ($label) { dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); @@ -2667,7 +2662,7 @@ class Facture extends CommonInvoice */ function update_percent($line, $percent) { - global $mysoc; + global $mysoc,$user; include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'); @@ -2693,7 +2688,6 @@ class Facture extends CommonInvoice */ function deleteline($rowid) { - global $langs, $conf; dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); @@ -2931,7 +2925,7 @@ class Facture extends CommonInvoice */ function getNextNumRef($soc,$mode='next') { - global $conf, $db, $langs; + global $conf, $langs; $langs->load("bills"); // Clean parameters (if not defined or using deprecated value) @@ -2993,7 +2987,7 @@ class Facture extends CommonInvoice * set up mask. */ if ($mode != 'last' && !$numref) { - dol_print_error($db,"Facture::getNextNumRef ".$obj->error); + dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); return ""; } @@ -3307,7 +3301,6 @@ class Facture extends CommonInvoice */ function demande_prelevement($fuser, $amount=0) { - global $langs; $error=0; @@ -3527,7 +3520,7 @@ class Facture extends CommonInvoice */ function initAsSpecimen($option='') { - global $user,$langs,$conf; + global $langs; $now=dol_now(); $arraynow=dol_getdate($now); @@ -3712,7 +3705,7 @@ class Facture extends CommonInvoice */ public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$user,$langs; + global $conf,$langs; $langs->load("bills"); @@ -3812,7 +3805,6 @@ class Facture extends CommonInvoice */ function setFinal() { - global $conf, $langs, $user; $this->db->begin(); @@ -4276,7 +4268,7 @@ class FactureLigne extends CommonInvoiceLine */ function update($user='',$notrigger=0) { - global $user,$langs,$conf; + global $user,$conf; $error=0; @@ -4402,9 +4394,7 @@ class FactureLigne extends CommonInvoiceLine */ function delete() { - global $conf,$langs,$user; - - $error=0; + global $user; $this->db->begin(); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index f962a9e82ae..18a60a3429d 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -273,7 +273,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) } else { - print '
'.$langs->trans("NoContracts").'
'.$langs->trans("NoContracts").'

"; $db->free($resql); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 14dbb304333..3ad080d8a55 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -229,12 +229,13 @@ abstract class CommonObject public $mode_reglement_id; /** - * @var string Payment terms ID + * @var int Payment terms ID * @see setPaymentTerms() */ public $cond_reglement_id; /** - * @deprecated + * @var int Payment terms ID + * @deprecated Kept for compatibility * @see cond_reglement_id; */ public $cond_reglement; @@ -4250,7 +4251,7 @@ abstract class CommonObject if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used - if (! empty($this->array_options) && !empty($this->array_options["options_$key"])) + if (! empty($this->array_options) && isset($this->array_options["options_".$key])) { // Check parameters $langs->load('admin'); @@ -4258,7 +4259,7 @@ abstract class CommonObject $extrafields = new ExtraFields($this->db); $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); - $value=$this->array_options["options_$key"]; + $value=$this->array_options["options_".$key]; $attributeType = $extrafields->attribute_type[$key]; $attributeLabel = $extrafields->attribute_label[$key]; $attributeParam = $extrafields->attribute_param[$key]; @@ -4272,17 +4273,17 @@ abstract class CommonObject } elseif ($value=='') { - $this->array_options["options_$key"] = null; + $this->array_options["options_".$key] = null; } break; case 'price': - $this->array_options["options_$key"] = price2num($this->array_options["options_$key"]); + $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]); break; case 'date': - $this->array_options["options_$key"]=$this->db->idate($this->array_options["options_$key"]); + $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); break; case 'datetime': - $this->array_options["options_$key"]=$this->db->idate($this->array_options["options_$key"]); + $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); break; case 'link': $param_list=array_keys($attributeParam ['options']); @@ -4294,13 +4295,13 @@ abstract class CommonObject if ($value) { $object->fetch(0,$value); - $this->array_options["options_$key"]=$object->id; + $this->array_options["options_".$key]=$object->id; } break; } $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET $key='".$this->db->escape($this->array_options["options_$key"])."'"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key."='".$this->db->escape($this->array_options["options_".$key])."'"; $sql .= " WHERE fk_object = ".$this->id; $resql = $this->db->query($sql); if (! $resql) diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 7d4dff8de44..ef990d8edf3 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -39,6 +39,7 @@ class Fiscalyear extends CommonObject var $label; var $date_start; var $date_end; + var $datec; var $statut; // 0=open, 1=closed var $entity; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c65fcb1bdc5..74cd27bc460 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5250,7 +5250,7 @@ class Form * * @param CommonObject $object Object we want to show links to * @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order') - * @return int <0 if KO, >0 if OK + * @return string <0 if KO, >0 if OK */ function showLinkToObjectBlock($object, $restrictlinksto=array()) { @@ -5468,7 +5468,7 @@ class Form * @param int $option 0 return yes/no, 1 return 1/0 * @param bool $disabled true or false * @param int $useempty 1=Add empty line - * @return mixed See option + * @return string See option */ function selectyesno($htmlname,$value='',$option=0,$disabled=false,$useempty='') { @@ -5810,7 +5810,7 @@ class Form * @param string $include Array list of groups id to include * @param int $enableonly Array list of groups id to be enabled. All other must be disabled * @param int $force_entity 0 or Id of environment to force - * @return void + * @return string * @see select_dolusers */ function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0634d4c6746..d4f1a38fbbb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2775,7 +2775,7 @@ function dol_print_error($db='',$error='',$errors=null) foreach($errors as $msg) { - $msg=$langs->trans($msg); + if (empty($msg)) continue; if ($_SERVER['DOCUMENT_ROOT']) // Mode web { $out.="".$langs->trans("Message").": ".$msg."
\n" ; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 28c1efe8a6c..c0fa6b9fad9 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -259,10 +259,13 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Bank insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled', __HANDLER__, 'left', 2600__+MAX_llx_menu__, 'accountancy', 'bank', 14__+MAX_llx_menu__, '/compta/bank/index.php?leftmenu=bank&mainmenu=bank', 'MenuBankCash', 0, 'banks', '$user->rights->banque->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2601__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/card.php?action=create&leftmenu=bank', 'MenuNewFinancialAccount', 1, 'banks', '$user->rights->banque->configurer', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2602__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/categ.php?leftmenu=bank', 'Rubriques', 1, 'categories', '$user->rights->banque->configurer', '', 0, 1, __ENTITY__); +-- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2602__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/categ.php?leftmenu=bank', 'Rubriques', 1, 'categories', '$user->rights->banque->configurer', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2603__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/search.php?leftmenu=bank', 'ListTransactions', 1, 'banks', '$user->rights->banque->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2604__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/budget.php?leftmenu=bank', 'ListTransactionsByCategory', 1, 'banks', '$user->rights->banque->lire', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2606__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/virement.php?leftmenu=bank', 'BankTransfers', 1, 'banks', '$user->rights->banque->transfer', '', 0, 5, __ENTITY__); +-- Account - Categories +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2700__+MAX_llx_menu__, 'accountancy', 'cat', 14__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=5', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2701__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/categories/card.php?action=create&type=5', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Project insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3600__+MAX_llx_menu__, 'project', 'projects', 7__+MAX_llx_menu__, '/projet/index.php?leftmenu=projects', 'Projects', 0, 'projects', '$user->rights->projet->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3601__+MAX_llx_menu__, 'project', '', 3600__+MAX_llx_menu__, '/projet/card.php?leftmenu=projects&action=create', 'NewProject', 1, 'projects', '$user->rights->projet->creer', '', 2, 1, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7cb2eb41200..67708eba5fe 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1049,14 +1049,19 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/bank/index.php?leftmenu=bank&mainmenu=bank",$langs->trans("MenuBankCash"),0,$user->rights->banque->lire, '', $mainmenu, 'bank'); $newmenu->add("/compta/bank/card.php?action=create",$langs->trans("MenuNewFinancialAccount"),1,$user->rights->banque->configurer); - $newmenu->add("/compta/bank/categ.php",$langs->trans("Rubriques"),1,$user->rights->banque->configurer); - $newmenu->add("/compta/bank/search.php",$langs->trans("ListTransactions"),1,$user->rights->banque->lire); $newmenu->add("/compta/bank/budget.php",$langs->trans("ListTransactionsByCategory"),1,$user->rights->banque->lire); $newmenu->add("/compta/bank/virement.php",$langs->trans("BankTransfers"),1,$user->rights->banque->transfer); } + if (! empty($conf->categorie->enabled)) { + $langs->load("categories"); + //$newmenu->add("/compta/bank/categ.php",$langs->trans("Rubriques"),1,$user->rights->banque->configurer); + $newmenu->add("/categories/index.php?type=5",$langs->trans("Rubriques"),0,$user->rights->categorie->creer, '', $mainmenu, 'tags'); + $newmenu->add("/categories/card.php?action=create&type=5",$langs->trans("NewCategory"),1,$user->rights->categorie->creer); + } + // Prelevements if (! empty($conf->prelevement->enabled)) { diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 9cb73a75d7a..cba8af72295 100755 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -52,7 +52,7 @@ class mailing_advthirdparties extends MailingTargets * * @param int $mailing_id Id of mailing. No need to use it. * @param array $socid Array of id soc to add - * @param int $type_of_target define in advtargetemailing.class.php + * @param int $type_of_target Defined in advtargetemailing.class.php * @param array $contactid Array of contact id to add * @return int <0 if error, number of emails added if ok */ @@ -73,47 +73,45 @@ class mailing_advthirdparties extends MailingTargets $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; $sql.= " AND s.rowid IN (".implode(',',$socid).")"; $sql.= " ORDER BY email"; - } - - dol_syslog(get_class($this)."::add_to_target societe sql=".$sql, LOG_DEBUG); - // Stock recipients emails into targets table - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - - dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found", LOG_DEBUG); - - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - - if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) { - if (!array_key_exists($obj->email, $cibles)) { - $cibles[$obj->email] = array( - 'email' => $obj->email, - 'fk_contact' => $obj->fk_contact, - 'name' => $obj->name, - 'firstname' => $obj->firstname, - 'other' => '', - 'source_url' => $this->url($obj->id,'thirdparty'), - 'source_id' => $obj->id, - 'source_type' => 'thirdparty' - ); - } - } - - $i++; - } - } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; + // Stock recipients emails into targets table + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found", LOG_DEBUG); + + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + + if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) { + if (!array_key_exists($obj->email, $cibles)) { + $cibles[$obj->email] = array( + 'email' => $obj->email, + 'fk_contact' => $obj->fk_contact, + 'name' => $obj->name, + 'firstname' => $obj->firstname, + 'other' => '', + 'source_url' => $this->url($obj->id,'thirdparty'), + 'source_id' => $obj->id, + 'source_type' => 'thirdparty' + ); + } + } + + $i++; + } + } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } } } @@ -131,47 +129,45 @@ class mailing_advthirdparties extends MailingTargets $sql.= " AND socp.fk_soc IN (".implode(',',$socid).")"; } $sql.= " ORDER BY email"; - } - - - dol_syslog(get_class($this)."::add_to_target contact sql=".$sql); - // Stock recipients emails into targets table - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - - dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); - - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - - if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) { - if (!array_key_exists($obj->email, $cibles)) { - $cibles[$obj->email] = array( - 'email' => $obj->email, - 'fk_contact' =>$obj->id, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'other' => '', - 'source_url' => $this->url($obj->id,'contact'), - 'source_id' => $obj->id, - 'source_type' => 'contact' - ); - } - } - - $i++; - } - } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; + + // Stock recipients emails into targets table + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); + + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + + if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) { + if (!array_key_exists($obj->email, $cibles)) { + $cibles[$obj->email] = array( + 'email' => $obj->email, + 'fk_contact' =>$obj->id, + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, + 'other' => '', + 'source_url' => $this->url($obj->id,'contact'), + 'source_id' => $obj->id, + 'source_type' => 'contact' + ); + } + } + + $i++; + } + } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 18b3d4d7ebc..35ef726be20 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2006-2012 Laurent Destailleur - * Copyright (C) 2011-2015 Juanjo Menent + * Copyright (C) 2011-2016 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014-2015 Marcos García @@ -90,6 +90,7 @@ class Expedition extends CommonObject var $date_creation; var $date_valid; + var $meths; var $listmeths; // List of carriers /** @@ -119,7 +120,7 @@ class Expedition extends CommonObject */ function getNextNumRef($soc) { - global $db, $langs, $conf; + global $langs, $conf; $langs->load("sendings"); if (!empty($conf->global->EXPEDITION_ADDON_NUMBER)) @@ -156,7 +157,7 @@ class Expedition extends CommonObject } else { - dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); + dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } } @@ -176,7 +177,7 @@ class Expedition extends CommonObject */ function create($user, $notrigger=0) { - global $conf, $langs, $hookmanager; + global $conf, $hookmanager; $now=dol_now(); @@ -978,7 +979,7 @@ class Expedition extends CommonObject */ function update($user=null, $notrigger=0) { - global $conf, $langs; + global $conf; $error=0; // Clean parameters @@ -1532,7 +1533,7 @@ class Expedition extends CommonObject */ function initAsSpecimen() { - global $user,$langs,$conf; + global $langs; $now=dol_now(); @@ -1644,7 +1645,7 @@ class Expedition extends CommonObject function fetch_delivery_methods() { global $langs; - $meths = array(); + $this->meths = array(); $sql = "SELECT em.rowid, em.code, em.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; @@ -1799,7 +1800,6 @@ class Expedition extends CommonObject */ function setClosed() { - global $conf; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1825,7 +1825,6 @@ class Expedition extends CommonObject */ function set_billed() { - global $conf; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1851,7 +1850,6 @@ class Expedition extends CommonObject */ function reOpen() { - global $conf; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1882,7 +1880,7 @@ class Expedition extends CommonObject */ public function generateDocument($modele, $outputlangs,$hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$user,$langs; + global $conf,$langs; $langs->load("sendings"); diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 895f2869b48..20c1c1d0de3 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -35,6 +35,7 @@ ALTER TABLE llx_product_customer_price ADD COLUMN localtax2_type varchar(10) NO ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0' after localtax1_tx; ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; +ALTER TABLE llx_opensurvey_sondage ADD COLUMN status integer DEFAULT 1 after date_fin; ALTER TABLE llx_expedition ADD COLUMN billed smallint DEFAULT 0; @@ -406,6 +407,20 @@ ALTER TABLE llx_product_fournisseur_price ADD supplier_reputation varchar(10) NU ALTER TABLE llx_product ADD COLUMN default_vat_code varchar(10) after cost_price; +CREATE TABLE llx_categorie_account +( + fk_categorie integer NOT NULL, + fk_account integer NOT NULL, + import_key varchar(14) +) ENGINE=innodb; + +ALTER TABLE llx_categorie_account ADD PRIMARY KEY pk_categorie_account (fk_categorie, fk_account); +ALTER TABLE llx_categorie_account ADD INDEX idx_categorie_account_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_account ADD INDEX idx_categorie_account_fk_account (fk_account); + +ALTER TABLE llx_categorie_account ADD CONSTRAINT fk_categorie_account_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_account ADD CONSTRAINT fk_categorie_account_fk_account FOREIGN KEY (fk_account) REFERENCES llx_bank_account (rowid); + -- Delete old deprecated field ALTER TABLE llx_product_stock DROP COLUMN pmp; diff --git a/htdocs/install/mysql/tables/llx_categorie_account.key.sql b/htdocs/install/mysql/tables/llx_categorie_account.key.sql new file mode 100644 index 00000000000..ccf33bcac09 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categorie_account.key.sql @@ -0,0 +1,26 @@ +-- ============================================================================ +-- Copyright (C) 2016 Charlie Benke +-- Copyright (C) 2016 Frederic France +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +ALTER TABLE llx_categorie_account ADD PRIMARY KEY pk_categorie_account (fk_categorie, fk_account); +ALTER TABLE llx_categorie_account ADD INDEX idx_categorie_account_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_account ADD INDEX idx_categorie_account_fk_account (fk_account); + +ALTER TABLE llx_categorie_account ADD CONSTRAINT fk_categorie_account_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_account ADD CONSTRAINT fk_categorie_account_fk_account FOREIGN KEY (fk_account) REFERENCES llx_bank_account (rowid); + diff --git a/htdocs/install/mysql/tables/llx_categorie_account.sql b/htdocs/install/mysql/tables/llx_categorie_account.sql new file mode 100644 index 00000000000..8bee67b1b40 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categorie_account.sql @@ -0,0 +1,25 @@ +-- ============================================================================ +-- Copyright (C) 2016 Charlie Benke +-- Copyright (C) 2016 Frederic France +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =========================================================================== + +CREATE TABLE llx_categorie_account +( + fk_categorie integer NOT NULL, + fk_account integer NOT NULL, + import_key varchar(14) +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql index b728702db79..5ea2183758a 100644 --- a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql +++ b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql @@ -24,6 +24,7 @@ CREATE TABLE llx_opensurvey_sondage ( fk_user_creat integer NOT NULL, titre TEXT NOT NULL, date_fin DATETIME NOT NULL, + status integer DEFAULT 1, format VARCHAR(2) NOT NULL, -- 'A' = Text choice (choices are saved into sujet field), 'D' = Date choice (choices are saved into sujet field), 'F' = Form survey mailsonde tinyint NOT NULL DEFAULT 0, allow_comments tinyint NOT NULL DEFAULT 1, diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index ccf22bb5003..0235b51ccb3 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -15,6 +15,7 @@ CustomersCategoriesArea=Customers tags/categories area ThirdPartyCategoriesArea=Third parties tags/categories area MembersCategoriesArea=Members tags/categories area ContactsCategoriesArea=Contacts tags/categories area +AccountsCategoriesArea=Accounts tags/categories area MainCats=Main tags/categories SubCats=Subcategories CatStatistics=Statistics @@ -54,6 +55,8 @@ SupplierHasNoCategory=This supplier is not in any tags/categories CompanyHasNoCategory=This thirdparty is not in any tags/categories MemberHasNoCategory=This member is not in any tags/categories ContactHasNoCategory=This contact is not in any tags/categories +ContactHasNoCategory=This contact is not in any tags/categories +AccountHasNoCategory=This account is not in any tags/categories ClassifyInCategory=Add to tag/category NoneCategory=None NotCategorized=Without tag/category @@ -81,11 +84,13 @@ CustomersProspectsCategoriesShort=Custo./Prosp. categories ProductsCategoriesShort=Products tags/categories MembersCategoriesShort=Members tags/categories ContactCategoriesShort=Contacts tags/categories +AccountsCategoriesShort=Accounts tags/categories ThisCategoryHasNoProduct=This category does not contain any product. ThisCategoryHasNoSupplier=This category does not contain any supplier. ThisCategoryHasNoCustomer=This category does not contain any customer. ThisCategoryHasNoMember=This category does not contain any member. ThisCategoryHasNoContact=This category does not contain any contact. +ThisCategoryHasNoAccount=This category does not contain any account. AssignedToCustomer=Assigned to a customer AssignedToTheCustomer=Assigned to the customer InternalCategory=Internal category diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index ff87db130b5..01ff6c7b486 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -169,3 +169,5 @@ AdvTgtDeleteFilter=Delete filter AdvTgtSaveFilter=Save filter AdvTgtCreateFilter=Create filter AdvTgtOrCreateNewFilter=Name of new filter +NoContactWithCategoryFound=No contact/address with a category found +NoContactLinkedToThirdpartieWithCategoryFound=No contact/address with a category found \ No newline at end of file diff --git a/htdocs/langs/en_US/opensurvey.lang b/htdocs/langs/en_US/opensurvey.lang index 4ae116d4c33..bc90d1488e3 100644 --- a/htdocs/langs/en_US/opensurvey.lang +++ b/htdocs/langs/en_US/opensurvey.lang @@ -62,5 +62,5 @@ ErrorOpenSurveyOneChoice=Enter at least one choice ErrorOpenSurveyDateFormat=Date must have the format YYYY-MM-DD ErrorInsertingComment=There was an error while inserting your comment MoreChoices=Enter more choices for the voters -SurveyExpiredInfo=The voting time of this poll has expired. +SurveyExpiredInfo=The poll has been closed or voting delay has expired. EmailSomeoneVoted=%s has filled a line.\nYou can find your poll at the link: \n%s diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index b481a7e1f60..96bf0da9bfa 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -325,3 +325,6 @@ ProductVolume=Volume for 1 product WeightUnits=Weight unit VolumeUnits=Volume unit SizeUnits=Size unit +DeleteProductBuyPrice=Delete buying price +ConfirmDeleteProductBuyPrice=Are you sure you want to delete this buying price? + diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index d94ac13cd05..9ce7cfb09a3 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -16,7 +16,10 @@ Website=Web site AddPage=Add page Page=Page PreviewOfSiteNotYetAvailable=Preview of your website %s not yet available. You must first add a page. -PageDeleted=Page %s of website %s deleted +RequestedPageHasNoContentYet=Requested page with id %s has not content yet or cache file .tpl.php was removed. Edit content of page to solve this. +PageDeleted=Page '%s' of website %s deleted +PageAdded=Page '%s' added ViewSiteInNewTab=View site in new tab ViewPageInNewTab=View page in new tab -SetAsHomePage=Set as Home page \ No newline at end of file +SetAsHomePage=Set as Home page +RealURL=Real URL \ No newline at end of file diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index c419a804210..ce941a680c7 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -35,6 +35,8 @@ if (!$user->rights->opensurvey->read) accessforbidden(); // Initialisation des variables $action=GETPOST('action'); +$cancel=GETPOST('cancel'); + $numsondage = ''; if (GETPOST('id')) { @@ -58,98 +60,119 @@ $expiredate=dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GE * Actions */ +$parameters = array('id' => $numsondage); +$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'); -// Delete -if ($action == 'delete_confirm') +if (empty($reshook)) { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + if ($cancel) $action=''; + + // Delete + if ($action == 'delete_confirm') + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + + $result=$object->delete($user,'',$numsondage); + + header('Location: '.dol_buildpath('/opensurvey/list.php',1)); + exit(); + } + + // Close + if ($action == 'close') + { + $object->status = Opensurveysondage::STATUS_CLOSED; + $object->update(); + } + + // Reopend + if ($action == 'reopen') + { + $object->status = Opensurveysondage::STATUS_VALIDATED; + $object->update(); + } + + // Update + if ($action == 'update') + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + + $error=0; + + if (! GETPOST('nouveautitre')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); + $error++; + $action = 'edit'; + } + + if (! $error) + { + $object->titre = GETPOST('nouveautitre'); + $object->commentaires = GETPOST('nouveauxcommentaires'); + $object->mail_admin = GETPOST('nouvelleadresse'); + $object->date_fin = $expiredate; + $object->allow_comments = GETPOST('cancomment') == 'on' ? true : false; + $object->allow_spy = GETPOST('canseeothersvote') == 'on' ? true : false; + $object->mailsonde = GETPOST('mailsonde') == 'on' ? true : false; + + $res=$object->update($user); + if ($res < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action='edit'; + } + } + } - $result=$object->delete($user,'',$numsondage); - - header('Location: '.dol_buildpath('/opensurvey/list.php',1)); - exit(); -} - -// Update -if ($action == 'update') -{ - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); - - $error=0; - - if (! GETPOST('nouveautitre')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); - $error++; - $action = 'edit'; - } - - if (! $error) - { - $object->titre = GETPOST('nouveautitre'); - $object->commentaires = GETPOST('nouveauxcommentaires'); - $object->mail_admin = GETPOST('nouvelleadresse'); - $object->date_fin = $expiredate; - $object->allow_comments = GETPOST('cancomment') == 'on' ? true : false; - $object->allow_spy = GETPOST('canseeothersvote') == 'on' ? true : false; - $object->mailsonde = GETPOST('mailsonde') == 'on' ? true : false; - - $res=$object->update($user); - if ($res < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action='edit'; - } - } -} - - -// Add comment -if (GETPOST('ajoutcomment')) -{ - $error=0; - - if (! GETPOST('comment')) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); - } - if (! GETPOST('commentuser')) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); - } - - if (! $error) - { - $comment = GETPOST("comment"); - $comment_user = GETPOST('commentuser'); - - $resql = $object->addComment($comment, $comment_user); - - if (! $resql) - { - setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); - } - } -} - -// Delete comment -$idcomment=GETPOST('deletecomment','int'); -if ($idcomment) -{ - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); - - $resql = $object->deleteComment($idcomment); -} - -if ($action == 'edit') { - - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); + // Add comment + if (GETPOST('ajoutcomment')) + { + $error=0; + + if (! GETPOST('comment')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); + } + if (! GETPOST('commentuser')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); + } + + if (! $error) + { + $comment = GETPOST("comment"); + $comment_user = GETPOST('commentuser'); + + $resql = $object->addComment($comment, $comment_user); + + if (! $resql) + { + setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); + } + } + } + + // Delete comment + $idcomment=GETPOST('deletecomment','int'); + if ($idcomment) + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + + $resql = $object->deleteComment($idcomment); + } + + if ($action == 'edit') { + + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + } } @@ -196,7 +219,7 @@ print ''; $linkback = ''.$langs->trans("BackToList").''; // Ref -print ''; +print ''; print ''; @@ -219,6 +242,12 @@ if ($action == 'edit') else print dol_htmlentities($object->titre); print ''; +// Status +print ''; + // Description print ''."\n"; @@ -107,13 +110,14 @@ print ''; print ''; $arraystatus=array(''=>' ','expired'=>$langs->trans("Expired"),'opened'=>$langs->trans("Opened")); print ''; +print ''; print ''; print ''."\n"; -$sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.titre, p.nom_admin,"; +$sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre, p.nom_admin,"; $sql.= " u.login, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; @@ -150,6 +154,9 @@ while ($i < min($num,$limit)) } else dol_print_error($db); + $opensurvey_static->id=$obj->id_sondage; + $opensurvey_static->status=$obj->status; + $var=!$var; print ''; print ''; print''."\n"; - + print ''; + print''."\n"; + print''."\n"; print ''."\n"; diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 5c14a20de23..93ccd93729b 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -432,7 +432,7 @@ print '
'.$langs->trans('Ref').'
'.$langs->trans('Ref').''; print $form->showrefnav($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage'); print '
'; +print $langs->trans("Status") .''; +print $object->getLibStatut(4); +print '
'.$langs->trans("Description") .''; if ($action == 'edit') @@ -326,7 +355,11 @@ dol_fiche_end(); if ($action == 'edit') { - print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; } print ''."\n"; @@ -340,9 +373,20 @@ print '
'; if ($action != 'edit' && $user->rights->opensurvey->write) { - //Modify button - print ''.$langs->trans("Modify") . ''; + //Modify button + print ''.$langs->trans("Modify") . ''; + if ($object->status == Opensurveysondage::STATUS_VALIDATED) + { + //Close button + print ''.$langs->trans("Close") . ''; + } + if ($object->status == Opensurveysondage::STATUS_CLOSED) + { + //Opened button + print ''.$langs->trans("ReOpen") . ''; + } + //Delete button print ''.$langs->trans('Delete').''; } diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index c3be8fc4793..fecb7904a9c 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -56,6 +56,7 @@ class Opensurveysondage extends CommonObject var $titre; var $date_fin=''; + var $status=1; var $format; var $mailsonde; @@ -73,6 +74,22 @@ class Opensurveysondage extends CommonObject */ public $allow_spy; + + /** + * Draft status (not used) + */ + const STATUS_DRAFT = 0; + /** + * Validated/Opened status + */ + const STATUS_VALIDATED = 1; + /** + * Closed + */ + const STATUS_CLOSED = 2; + + + /** * Constructor * @@ -115,6 +132,7 @@ class Opensurveysondage extends CommonObject $sql.= "fk_user_creat,"; $sql.= "titre,"; $sql.= "date_fin,"; + $sql.= "status,"; $sql.= "format,"; $sql.= "mailsonde,"; $sql.= "allow_comments,"; @@ -127,6 +145,7 @@ class Opensurveysondage extends CommonObject $sql.= " ".$user->id.","; $sql.= " '".$this->db->escape($this->titre)."',"; $sql.= " '".$this->db->idate($this->date_fin)."',"; + $sql.= " ".$this->status.","; $sql.= " '".$this->db->escape($this->format)."',"; $sql.= " ".$this->db->escape($this->mailsonde).","; $sql.= " ".$this->db->escape($this->allow_comments).","; @@ -190,6 +209,7 @@ class Opensurveysondage extends CommonObject $sql.= " t.fk_user_creat,"; $sql.= " t.titre,"; $sql.= " t.date_fin,"; + $sql.= " t.status,"; $sql.= " t.format,"; $sql.= " t.mailsonde,"; $sql.= " t.allow_comments,"; @@ -217,6 +237,7 @@ class Opensurveysondage extends CommonObject $this->nom_admin = $obj->nom_admin; $this->titre = $obj->titre; $this->date_fin = $this->db->jdate($obj->date_fin); + $this->status = $obj->status; $this->format = $obj->format; $this->mailsonde = $obj->mailsonde; $this->allow_comments = $obj->allow_comments; @@ -274,6 +295,7 @@ class Opensurveysondage extends CommonObject $sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").","; $sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").","; $sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; + $sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").","; $sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").","; $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").","; $sql.= " allow_comments=".$this->db->escape($this->allow_comments).","; @@ -291,15 +313,12 @@ class Opensurveysondage extends CommonObject { if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers + // Call triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('OPENSURVEY_MODIFY',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // End call triggers } } @@ -321,17 +340,16 @@ class Opensurveysondage extends CommonObject } } - - /** - * Delete object in database - * + /** + * Delete object in database + * * @param User $user User that deletes * @param int $notrigger 0=launch triggers after, 1=disable triggers * @param string $numsondage Num sondage admin to delete - * @return int <0 if KO, >0 if OK - */ - function delete($user, $notrigger, $numsondage) - { + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger, $numsondage) + { global $conf, $langs; $error=0; @@ -428,12 +446,13 @@ class Opensurveysondage extends CommonObject $this->id=0; $this->id_sondage=''; - $this->commentaires=''; + $this->commentaires='Comment of the specimen survey'; $this->mail_admin=''; $this->nom_admin=''; - $this->titre=''; - $this->date_fin=''; - $this->format=''; + $this->titre='This is a specimen survey'; + $this->date_fin=dol_now()+3600*24*10; + $this->status=1; + $this->format='classic'; $this->mailsonde=''; } @@ -518,10 +537,74 @@ class Opensurveysondage extends CommonObject $this->mail_admin = trim($this->mail_admin); $this->nom_admin = trim($this->nom_admin); $this->titre = trim($this->titre); + $this->status = trim($this->status); $this->format = trim($this->format); $this->mailsonde = ($this->mailsonde ? 1 : 0); $this->allow_comments = ($this->allow_comments ? 1 : 0); $this->allow_spy = ($this->allow_spy ? 1 : 0); $this->sujet = trim($this->sujet); } + + + /** + * Return status label of Order + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + function getLibStatut($mode) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Return label of status + * + * @param int $status Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function LibStatut($status,$mode) + { + global $langs, $conf; + + //print 'x'.$status.'-'.$billed; + if ($mode == 0) + { + if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); + if ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); + if ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); + } + elseif ($mode == 1) + { + if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); + if ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); + if ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); + } + elseif ($mode == 2) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft'); + if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'),'statut1').' '.$langs->trans('Opened'); + if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'),'statut6').' '.$langs->trans('Closed'); + } + elseif ($mode == 3) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'),'statut0'); + if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'),'statut1'); + if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'),'statut6'); + } + elseif ($mode == 4) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft'); + if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened').$billedtext,'statut1').' '.$langs->trans('Opened'); + if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'),'statut6').' '.$langs->trans('Closed'); + } + elseif ($mode == 5) + { + if ($status==self::STATUS_DRAFT) return ''.$langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); + if ($status==self::STATUS_VALIDATED) return ''.$langs->trans('Opened').' '.img_picto($langs->trans('Opened'),'statut1'); + if ($status==self::STATUS_CLOSED) return ''.$langs->trans('Closed').' '.img_picto($langs->trans('Closed'),'statut6'); + } + } + } diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index b440b5ee43e..aed5610bee0 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -25,6 +25,7 @@ require_once('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"); // Security check if (!$user->rights->opensurvey->read) accessforbidden(); @@ -68,6 +69,7 @@ if (GETPOST('button_removefilter')) */ $form=new Form($db); +$opensurvey_static = new Opensurveysondage($db); $now = dol_now(); @@ -96,6 +98,7 @@ print_liste_field_titre($langs->trans("Type")); print_liste_field_titre($langs->trans("Author"), $_SERVER["PHP_SELF"], "u.".$fieldtosortuser,$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("NbOfVoters")); print_liste_field_titre($langs->trans("ExpireDate"), $_SERVER["PHP_SELF"], "p.date_fin",$param,"",'align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "p.status",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); print '
'. $form->selectarray('status', $arraystatus, $status).''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; print '
'; @@ -176,11 +183,13 @@ while ($i < min($num,$limit)) print ''.$nbuser.''.dol_print_date($db->jdate($obj->date_fin),'day'); if ($db->jdate($obj->date_fin) < time()) { print ' ('.$langs->trans("Expired").')'; } print ''.$opensurvey_static->getLibStatut(5).'
'; $linkback = ''.$langs->trans("BackToList").''; // Ref -print ''; +print ''; print ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 68dfea68be7..86a11f57541 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3041,6 +3041,7 @@ class Product extends CommonObject function get_sousproduits_arbo() { //$parent = $this->getParent(); + $parent=array(); $parent[$this->label]=array(0 => $this->id); foreach($parent as $key => $value) // key=label, value[0]=id diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index ce6815911e1..6a76055d3fc 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -115,7 +115,7 @@ if (empty($reshook)) } } - if ($action == 'remove_pf') + if ($action == 'confirm_remove_pf') { if ($rowid) // id of product supplier price to remove { @@ -285,6 +285,12 @@ if ($id > 0 || $ref) if ($result) { + if ($action == 'ask_remove_pf') { + $form = new Form($db); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id . '&rowid=' . $rowid, $langs->trans('DeleteProductBuyPrice'), $langs->trans('ConfirmDeleteProductBuyPrice'), 'confirm_remove_pf', '', 0, 1); + echo $formconfirm; + } + if ($action <> 'edit' && $action <> 're-edit') { $head=product_prepare_head($object); @@ -680,7 +686,7 @@ if ($id > 0 || $ref) if ($user->rights->produit->creer || $user->rights->service->creer) { print ''.img_edit().""; - print ''.img_picto($langs->trans("Remove"),'disable.png').''; + print ''.img_picto($langs->trans("Remove"),'disable.png').''; } print ''; diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 33bd1ba1373..834f17b8b2c 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -46,7 +46,7 @@ if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage); $nblignes=$object->fetch_lines(); //If the survey has not yet finished, then it can be modified -$canbemodified = (empty($object->date_fin) || $object->date_fin > dol_now()); +$canbemodified = ((empty($object->date_fin) || $object->date_fin > dol_now()) && $object->status != Opensurveysondage::STATUS_CLOSED); /* diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index b54a69e90f9..4625bc1573a 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -48,8 +48,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; $website=GETPOST('website', 'alpha'); -$page=GETPOST('page', 'alpha'); -$pageid=GETPOST('pageid', 'alpha'); +$pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha'); $accessallowed = 1; $type=''; @@ -81,13 +80,23 @@ if (empty($pageid)) $pageid=$firstrep->id; } } - +if (empty($pageid)) +{ + $langs->load("website"); + print $langs->trans("PreviewOfSiteNotYetAvailable"); + exit; +} // Security: Delete string ../ into $original_file global $dolibarr_main_data_root; if ($pageid == 'css') { + header('Content-type: text/css'); + // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. + //if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); + //else + header('Cache-Control: no-cache'); $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css'; } else @@ -127,7 +136,9 @@ $original_file_osencoded=dol_osencode($original_file); // New file name encoded // This test if file exists should be useless. We keep it to find bug more easily if (! file_exists($original_file_osencoded)) { - dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); + $langs->load("website"); + print $langs->trans("RequestedPageHasNoContentYet", $pageid); + //dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); exit; } diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 74a05cba39d..95d5b33e162 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -23,8 +23,7 @@ */ /** - * \class ActionsCardCommon - * \brief Classe permettant la gestion des tiers par defaut + * Classe permettant la gestion des tiers par defaut */ abstract class ActionsCardCommon { diff --git a/htdocs/societe/class/api_thirdparty.class.php b/htdocs/societe/class/api_thirdparty.class.php index 9c65d08ac43..507d95639e6 100644 --- a/htdocs/societe/class/api_thirdparty.class.php +++ b/htdocs/societe/class/api_thirdparty.class.php @@ -370,7 +370,7 @@ class ThirdpartyApi extends DolibarrApi * Delete thirdparty * * @param int $id Thirparty ID - * @return type + * @return integer * * @url DELETE thirdparty/{id} * @url DELETE customer/{id} diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index b352e25a724..94212594eb2 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -212,6 +212,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_town=""; $search_zip=""; $search_state=""; + $search_country=''; $search_idprof1=''; $search_idprof2=''; $search_idprof3=''; @@ -219,7 +220,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_idprof5=''; $search_idprof6=''; $search_type=''; - $search_country=''; $search_type_thirdparty=''; $search_status=''; $search_stcomm=''; @@ -384,6 +384,7 @@ if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fourniss if ($search_town) $sql.= natural_search("s.town",$search_town); if ($search_zip) $sql.= natural_search("s.zip",$search_zip); if ($search_state) $sql.= natural_search("state.nom",$search_state); +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_idprof1) $sql.= natural_search("s.siren",$search_idprof1); if ($search_idprof2) $sql.= natural_search("s.siret",$search_idprof2); if ($search_idprof3) $sql.= natural_search("s.ape",$search_idprof3); @@ -396,7 +397,6 @@ if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; if ($search_status!='') $sql .= " AND s.status = ".$db->escape($search_status); if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= " AND s.barcode LIKE '%".$db->escape($search_barcode)."%'"; -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; 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); diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index a82a0833aba..e87e830bb77 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -54,16 +54,37 @@ class Website extends CommonObject public $lines = array(); /** + * @var int */ - public $entity; + /** + * @var string + */ public $ref; + /** + * @var string + */ public $description; + /** + * @var int + */ public $status; - public $date_creation = ''; - public $date_modification = ''; + /** + * @var mixed + */ + public $date_creation; + /** + * @var mixed + */ + public $date_modification; + /** + * @var mixed + */ public $tms = ''; - public $fk_default_home; + /** + * @var integer + */ + public $fk_default_home; public $records; /** @@ -625,20 +646,36 @@ class WebsiteLine */ public $id; /** - * @var mixed Sample line property 1 + * @var int */ - public $entity; - public $ref; - public $description; - public $status; - public $fk_default_home; - public $date_creation = ''; - public $date_modification = ''; - public $tms = ''; - /** - * @var mixed Sample line property 2 + * @var string */ + public $ref; + /** + * @var string + */ + public $description; + /** + * @var int + */ + public $status; + /** + * @var int + */ + public $fk_default_home; + /** + * @var mixed + */ + public $date_creation; + /** + * @var mixed + */ + public $date_modification; + /** + * @var mixed + */ + public $tms = ''; } diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index aa0063f9a2b..65e56e030a1 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -253,15 +253,16 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK + * @param string $websiteid Web site + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK */ - public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') + public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -280,14 +281,15 @@ class WebsitePage extends CommonObject $sql .= " t.date_modification,"; $sql .= " t.tms"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' WHERE t.fk_website = '.$websiteid; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key=='t.rowid' || $key=='t.fk_website') { - $sqlwhere [] = $key . '='. $value; + $sqlwhere[] = $key . '='. $value; } else { - $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } } } diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 73581307c83..ae29dab196b 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -126,6 +126,11 @@ $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website; $filecss=$pathofwebsite.'/styles.css'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + /* @@ -162,7 +167,7 @@ if ($action == 'add') if (! $error) { $db->commit(); - setEventMessages($langs->trans("PageAdded"), null, 'mesgs'); + setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); $action=''; } else @@ -475,6 +480,9 @@ if (count($object->records) > 0) if ($website) { + print ' - '.$langs->trans("RealURL").' '; + $realurl=$urlwithroot.'/public/websites/index.php?website='.$website; + print ' '; print ''.$langs->trans("ViewSiteInNewTab").''; } print ''; @@ -508,8 +516,10 @@ if (count($object->records) > 0) { print ''; - $array=$objectpage->fetchAll('','',0,0,array('t.fk_website'=>$object->id)); - + $array=$objectpage->fetchAll($object->id); + if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); + $atleastonepage=(is_array($array) && count($array) > 0); + print '
'; print '
'; print $langs->trans("Page").': '; @@ -517,30 +527,33 @@ if (count($object->records) > 0) print '
'; $out=''; $out.=''; print $out; - print ''; - print ''; + print ''; + print ''; //print $form->selectarray('page', $array); if ($website && $pageid > 0) { - print ''.$langs->trans("ViewPageInNewTab").''; + print ' - '.$langs->trans("RealURL").' '; + $realurl=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; + print ' '; + print ''.$langs->trans("ViewPageInNewTab").''; } print '
';
'.$langs->trans('Ref').'
'.$langs->trans('Ref').''; print $form->showrefnav($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage'); print '