Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2011-12-14 23:03:21 +01:00
commit 6a8787d3a8
10 changed files with 409 additions and 263 deletions

View File

@ -22,7 +22,7 @@ PHPExcel 1.7.6 LGPL 2.1 Yes Read/Write XLS files, read ODS files
TCPDF 5.9.098 LGPL 3.0 Yes PDF generation
JS libraries:
jQuery 1.6.4 GPL and MIT Licence Yes JS library
jQuery 1.7.1 GPL and MIT Licence Yes JS library
jQuery UI 1.8.16 GPL and MIT Licence Yes JS library plugin UI
jQuery Colorpicker 1.1 MIT Licence Yes JS library for color picker for a defined list of colors
jQuery DataTable 1.8.1 BSD Yes JS library for tables output

View File

@ -198,7 +198,7 @@ if ($_SESSION['dol_dst']>0)
print ($_SESSION['dol_dst']>0?'+':'').($_SESSION['dol_dst']).' ('.($_SESSION['dol_dst']>0?'+':'').($_SESSION['dol_dst']*60*60).')';
}
else print yn(0);
if (isset($_SESSION['dol_dst_first'])) print '     ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']),'dayhour','gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']),'dayhour','gmt').')';
if (! empty($_SESSION['dol_dst_first'])) print '     ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']),'dayhour','gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']),'dayhour','gmt').')';
print '</td></tr>'."\n";
$var=!$var;
print '<tr '.$bc[$var].'><td width="300">&nbsp; => '.$langs->trans("ClientHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzuser').'</td></tr>'."\n";

View File

@ -609,11 +609,11 @@ if ($id)
{
if ($error)
{
print '<div class="error">'.$error.'</div><br>';
dol_htmloutput_errors($error);
}
if ($mesg)
{
print $mesg.'<br>';
dol_htmloutput_mesg($mesg);
}
$act = new ActionComm($db);

View File

@ -116,10 +116,11 @@ class Propal extends CommonObject
/**
* \brief Constructeur
* \param DB Database handler
* \param socid Id third party
* \param propalid Id proposal
* Class Constructor
*
* @param DoliDB $DB Database handler
* @param int $socid Id third party
* @param int $propalid Id proposal
*/
function Propal($DB, $socid="", $propalid=0)
{
@ -152,9 +153,11 @@ class Propal extends CommonObject
/**
* Add line into array products
* $this->client doit etre charge
* @param idproduct Id du produit a ajouter
* @param qty Quantity
* @param remise_percent Remise relative effectuee sur le produit
*
* @param int $idproduct Product Id to add
* @param int $qty Quantity
* @param int $remise_percent Discount effected on Product
*
* TODO Remplacer les appels a cette fonction par generation objet Ligne
* insere dans tableau $this->products
*/
@ -201,9 +204,10 @@ class Propal extends CommonObject
}
/**
* \brief Ajout d'une ligne remise fixe dans la proposition, en base
* \param idremise Id de la remise fixe
* \return int >0 si ok, <0 si ko
* Adding line of fixed discount in the proposal in DB
*
* @param int @idremise Id of fixed discount
* @return int >0 si ok, <0 si ko
*/
function insert_discount($idremise)
{
@ -282,23 +286,24 @@ class Propal extends CommonObject
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*
* @param propalid Id de la propale
* @param desc Description de la ligne
* @param pu_ht Prix unitaire
* @param qty Quantite
* @param txtva Taux de tva
* @param txlocaltax1 Local tax 1 rate
* @param txlocaltax2 Local tax 2 rate
* @param fk_product Id du produit/service predefini
* @param remise_percent Pourcentage de remise de la ligne
* @param price_base_type HT or TTC
* @param pu_ttc Prix unitaire TTC
* @param info_bits Bits de type de lignes
* @param type Type of line (product, service)
* @param rang Position of line
* @param special_code Special code
* @param fk_parent_line Id of parent line
* @return int >0 if OK, <0 if KO
* @param int $propalid Id de la propale
* @param string $desc Description de la ligne
* @param double $pu_ht Prix unitaire
* @param double $qty Quantite
* @param double $txtva Taux de tva
* @param double $txlocaltax1 Local tax 1 rate
* @param double $txlocaltax2 Local tax 2 rate
* @param int $fk_product Id du produit/service predefini
* @param double $remise_percent Pourcentage de remise de la ligne
* @param double $price_base_type HT or TTC
* @param dobule $pu_ttc Prix unitaire TTC
* @param int $info_bits Bits de type de lignes
* @param int $type Type of line (product, service)
* @param int $rang Position of line
* @param int $special_code Special code
* @param int $fk_parent_line Id of parent line
* @return int >0 if OK, <0 if KO
*
* @see add_product
*/
function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0)
@ -432,20 +437,20 @@ class Propal extends CommonObject
/**
* Update a proposal line
*
* @param rowid Id de la ligne
* @param pu Prix unitaire (HT ou TTC selon price_base_type)
* @param qty Quantity
* @param remise_percent Remise effectuee sur le produit
* @param txtva Taux de TVA
* @param txlocaltax1 Local tax 1 rate
* @param txlocaltax2 Local tax 2 rate
* @param desc Description
* @param price_base_type HT ou TTC
* @param info_bits Miscellanous informations
* @param special_code Set special code ('' = we don't change it)
* @param fk_parent_line Id of line parent
* @param skip_update_total Skip update total
* @return int 0 if OK, <0 if KO
* @param int $rowid Id de la ligne
* @param double $pu Prix unitaire (HT ou TTC selon price_base_type)
* @param double $qty Quantity
* @param double $remise_percent Remise effectuee sur le produit
* @param double $txtva Taux de TVA
* @param double $txlocaltax1 Local tax 1 rate
* @param double $txlocaltax2 Local tax 2 rate
* @param string $desc Description
* @param double $price_base_type HT ou TTC
* @param int $info_bits Miscellanous informations
* @param int $special_code Set special code ('' = we don't change it)
* @param int $fk_parent_line Id of line parent
* @param int $skip_update_total Skip update total
* @return int 0 if OK, <0 if KO
*/
function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0)
{
@ -555,7 +560,7 @@ class Propal extends CommonObject
/**
* Supprime une ligne de detail
* Delete detail line
*
* @param int $lineid Id of line to delete
* @return int >0 if OK, <0 if KO
@ -592,7 +597,7 @@ class Propal extends CommonObject
* this->ref can be set or empty. If empty, we will use "(PROVid)"
*
* @param User $user User that create
* @param int $notrigger Disable trigger
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >=0 if OK
*/
function create($user='', $notrigger=0)
@ -822,9 +827,10 @@ class Propal extends CommonObject
/**
* \brief Insert en base un objet propal completement definie par ses donnees membres (resultant d'une copie par exemple).
* \return int l'id du nouvel objet propal en base si ok, <0 si ko
* \see create
* Insert into DB a proposal object completely defined by its data members (ex, results from copy).
* @param User $user User that create
* @return int Id of the new object if ok, <0 if ko
* @see create
*/
function create_from($user)
{
@ -933,10 +939,11 @@ class Propal extends CommonObject
}
/**
* \brief Load a proposal from database and its ligne array
* \param rowid id of object to load
* \param ref Ref of proposal
* \return int >0 if OK, <0 if KO
* Load a proposal from database and its ligne array
*
* @param int $rowid id of object to load
* @param string $ref Ref of proposal
* @return int >0 if OK, <0 if KO
*/
function fetch($rowid,$ref='')
{
@ -1128,6 +1135,7 @@ class Propal extends CommonObject
* Set status to validated
*
* @param User $user Object user that validate
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >=0 if OK
*/
function valid($user, $notrigger=0)
@ -1213,10 +1221,11 @@ class Propal extends CommonObject
}
/**
* \brief Define end validity date
* \param user Object user that modify
* \param date_fin_validite End of validity date
* \return int <0 if KO, >0 if OK
* Define end validity date
*
* @param User $user Object user that modify
* @param timestamp $date_fin_validite End of validity date
* @return int <0 if KO, >0 if OK
*/
function set_echeance($user, $date_fin_validite)
{
@ -1239,10 +1248,11 @@ class Propal extends CommonObject
}
/**
* \brief Set delivery date
* \param user Objet utilisateur qui modifie
* \param date_livraison date de livraison
* \return int <0 si ko, >0 si ok
* Set delivery date
*
* @param User $user Object user that modify
* @param timestamp $date_livraison Delivery date
* @return int <0 if ko, >0 if ok
*/
function set_date_livraison($user, $date_livraison)
{
@ -1267,10 +1277,11 @@ class Propal extends CommonObject
}
/**
* \brief Define delivery address
* \param user Objet utilisateur qui modifie
* \param fk_address Delivery address id
* \return int <0 si ko, >0 si ok
* Define delivery address
*
* @param User $user Object user that modify
* @param int $fk_address Delivery address id
* @return int <0 si ko, >0 si ok
*/
function set_adresse_livraison($user, $fk_address)
{
@ -1296,7 +1307,7 @@ class Propal extends CommonObject
/**
* Set delivery
*
* @param User $user Objet utilisateur qui modifie
* @param User $user Object user that modify
* @param int $id Availability id
* @return int <0 if KO, >0 if OK
*/
@ -1325,7 +1336,7 @@ class Propal extends CommonObject
/**
* Set source of demand
*
* @param User $user Objet utilisateur qui modifie
* @param User $user Object user that modify
* @param int $id Input reason id
* @return int <0 if KO, >0 if OK
*/
@ -1352,11 +1363,11 @@ class Propal extends CommonObject
}
/**
* Positionne numero reference client
* Set customer reference number
*
* @param user Utilisateur qui modifie
* @param ref_client Reference client
* @return int <0 si ko, >0 si ok
* @param User $user Object user that modify
* @param string $ref_client Customer reference
* @return int <0 if ko, >0 if ok
*/
function set_ref_client($user, $ref_client)
{
@ -1385,10 +1396,11 @@ class Propal extends CommonObject
}
/**
* \brief Definit une remise globale relative sur la proposition
* \param user Objet utilisateur qui modifie
* \param remise Montant remise
* \return int <0 si ko, >0 si ok
* Set an overall discount on the proposal
*
* @param User $user Object user that modify
* @param double $remise Amount discount
* @return int <0 if ko, >0 if ok
*/
function set_remise_percent($user, $remise)
{
@ -1418,10 +1430,11 @@ class Propal extends CommonObject
/**
* \brief Definit une remise globale absolue sur la proposition
* \param user Objet utilisateur qui modifie
* \param remise Montant remise
* \return int <0 si ko, >0 si ok
* Set an absolute overall discount on the proposal
*
* @param User $user Object user that modify
* @param double $remise Amount discount
* @return int <0 if ko, >0 if ok
*/
function set_remise_absolue($user, $remise)
{
@ -1452,11 +1465,11 @@ class Propal extends CommonObject
/**
* \brief Cloture de la proposition commerciale
* \param user Utilisateur qui cloture
* \param statut Statut
* \param note Commentaire
* \return int <0 si ko, >0 si ok
* Closure of the commercial proposal
* @param User $user Object user that closure
* @param int $statut Statut
* @param text $note Commentaire
* @return int <0 si ko, >0 si ok
*/
function cloture($user, $statut, $note)
{
@ -1517,8 +1530,9 @@ class Propal extends CommonObject
}
/**
* \brief Classe la propale comme facturee
* \return int <0 si ko, >0 si ok
* Class invoiced the Propal
*
* @return int <0 si ko, >0 si ok
*/
function classer_facturee()
{
@ -1535,10 +1549,10 @@ class Propal extends CommonObject
}
/**
* Set draft status
* Set draft status
*
* @param User $user Object user that modify
* @return int <0 if KO, >0 if OK
* @param User $user Object user that modify
* @return int <0 if KO, >0 if OK
*/
function set_draft($user)
{
@ -1561,15 +1575,15 @@ class Propal extends CommonObject
/**
* Return list of proposal (eventually filtered on user) into an array
*
* @param shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref)
* @param draft 0=not draft, 1=draft
* @param notcurrentuser 0=current user, 1=not current user
* @param socid Id third pary
* @param limit For pagination
* @param offset For pagination
* @param sortfield Sort criteria
* @param sortorder Sort order
* @return int -1 if KO, array with result if OK
* @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref)
* @param int $draft 0=not draft, 1=draft
* @param int $notcurrentuser 0=current user, 1=not current user
* @param int $socid Id third pary
* @param int $limit For pagination
* @param int $offset For pagination
* @param string $sortfield Sort criteria
* @param string $sortorder Sort order
* @return int -1 if KO, array with result if OK
*/
function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC')
{
@ -1623,9 +1637,9 @@ class Propal extends CommonObject
}
/**
* Renvoie un tableau contenant les numeros de factures associees
* Returns an array with the numbers of related invoices
*
* @return array Tableau des id de factures
* @return array Array of invoices
*/
function getInvoiceArrayList()
{
@ -1633,7 +1647,7 @@ class Propal extends CommonObject
}
/**
* Renvoie un tableau contenant les id et ref des factures associees
* Returns an array with id and ref of related invoices
*
* @param int $id Id propal
* @return array Array of invoices id
@ -1715,8 +1729,11 @@ class Propal extends CommonObject
}
/**
* \brief Efface propal
* \param user Objet du user qui efface
* Delete proposal
*
* @param User $user Object user that delete
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int 1 if ok, otherwise if error
*/
function delete($user, $notrigger=0)
{
@ -1808,10 +1825,10 @@ class Propal extends CommonObject
/**
* Change les conditions de reglement de la facture
* Change the payments conditions of the invoice
*
* @param cond_reglement_id Id de la nouvelle condition de reglement
* @return int >0 if OK, <0 if KO
* @param int $cond_reglement_id Id of new payment condition
* @return int >0 if OK, <0 if KO
*/
function cond_reglement($cond_reglement_id)
{
@ -1843,10 +1860,10 @@ class Propal extends CommonObject
/**
* Change le mode de reglement
* Change the payment mode
*
* @param mode_reglement_id Id du nouveau mode
* @return int >0 if OK, <0 if KO
* @param int $mode_reglement_id Id of new payment mode
* @return int >0 if OK, <0 if KO
*/
function mode_reglement($mode_reglement_id)
{
@ -1877,10 +1894,10 @@ class Propal extends CommonObject
}
/**
* Change le delai de livraison
* Change the delivery time
*
* @param availability_id Id du nouveau delai de livraison
* @return int >0 if OK, <0 if KO
* @param int $availability_id Id of new delivery time
* @return int >0 if OK, <0 if KO
*/
function availability($availability_id)
{
@ -1911,9 +1928,10 @@ class Propal extends CommonObject
}
/**
* \brief Change l'origine de la demande
* \param demand_reason_id Id de la nouvelle origine de demande
* \return int >0 si ok, <0 si ko
* Change source demand
*
* @param int $demand_reason_id Id of new source demand
* @return int >0 si ok, <0 si ko
*/
function demand_reason($demand_reason_id)
{
@ -1945,8 +1963,9 @@ class Propal extends CommonObject
/**
* \brief Information sur l'objet propal
* \param id id de la propale
* Object Proposal Information
*
* @param int $id Proposal id
*/
function info($id)
{
@ -2002,7 +2021,8 @@ class Propal extends CommonObject
/**
* Return label of status of proposal (draft, validated, ...)
* @param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Label
*/
function getLibStatut($mode=0)
@ -2012,8 +2032,9 @@ class Propal extends CommonObject
/**
* Return label of a status (draft, validated, ...)
* @param statut id statut
* @param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
*
* @param int $statut id statut
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Label
*/
function LibStatut($statut,$mode=1)
@ -2066,9 +2087,10 @@ class Propal extends CommonObject
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* @param user Objet user
* @param mode "opened" pour propal a fermer, "signed" pour propale a facturer
* @return int <0 if KO, >0 if OK
*
* @param User $user Object user
* @param int $mode "opened" for proposal to close, "signed" for proposal to invoice
* @return int <0 if KO, >0 if OK
*/
function load_board($user,$mode)
{
@ -2213,7 +2235,7 @@ class Propal extends CommonObject
/**
* Charge indicateurs this->nb de tableau de bord
*
* @return int <0 si ko, >0 si ok
* @return int <0 if ko, >0 if ok
*/
function load_state_board()
{
@ -2251,9 +2273,9 @@ class Propal extends CommonObject
}
/**
* Renvoie la reference de propale suivante non utilisee en fonction du module
* de numerotation actif defini dans PROPALE_ADDON
/**
* Returns the reference to the following non used Proposal used depending on the active numbering module
* defined into PROPALE_ADDON
*
* @param Societe $soc Object thirdparty
* @return string Reference libre pour la propale
@ -2298,11 +2320,12 @@ class Propal extends CommonObject
}
/**
* Return clicable link of object (with eventually picto)
* @param withpicto Add picto into link
* @param option Where point the link
* @param get_params Parametres added to url
* @return string String with URL
* Return clicable link of object (with eventually picto)
*
* @param int $withpicto Add picto into link
* @param string $option Where point the link
* @param string $get_params Parametres added to url
* @return string String with URL
*/
function getNomUrl($withpicto=0,$option='', $get_params='')
{
@ -2333,7 +2356,9 @@ class Propal extends CommonObject
}
/**
* Return an array of propal lines
* Retrieve an array of propal lines
*
* @return int <0 if ko, >0 if ok
*/
function getLinesArray()
{
@ -2459,8 +2484,9 @@ class PropaleLigne
var $skip_update_total; // Skip update price total for special lines
/**
* \brief Constructeur d'objets ligne de propal
* \param DB handler d'acces base de donnee
* Class line Contructor
*
* @param DoliDB $DB Database handler
*/
function PropaleLigne($DB)
{
@ -2468,8 +2494,9 @@ class PropaleLigne
}
/**
* \brief Recupere l'objet ligne de propal
* \param rowid id de la ligne de propal
* Retrieve the propal line object
*
* @param int $rowid propal line id
*/
function fetch($rowid)
{
@ -2525,7 +2552,7 @@ class PropaleLigne
/**
* Insert object line propal in database
*
* @param int $notrigger 1=no trigger ran
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/
function insert($notrigger=0)
@ -2615,7 +2642,7 @@ class PropaleLigne
/**
* Delete line in database
* @return int <0 si ko, >0 si ok
* @return int <0 if ko, >0 if ok
*/
function delete()
{
@ -2649,9 +2676,10 @@ class PropaleLigne
}
/**
* Mise a jour de l'objet ligne de propale en base
* Update propal line object into DB
*
* @return int <0 si ko, >0 si ok
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if ko, >0 if ok
*/
function update($notrigger=0)
{
@ -2728,9 +2756,10 @@ class PropaleLigne
}
/**
* \brief Mise a jour en base des champs total_xxx de ligne
* \remarks Utilise par migration
* \return int <0 si ko, >0 si ok
* Update DB line fields total_xxx
* Used by migration
*
* @return int <0 if ko, >0 if ok
*/
function update_total()
{

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (c) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -46,10 +47,9 @@ class PropaleStats extends Stats
/**
* Constructor
*
* @param $DB Database handler
* @param $socid Id third party
* @param $userid Id user for filter
* @return PropaleStats
* @param DoliDB $DB Database handler
* @param int $socid Id third party
* @param int $userid Id user for filter
*/
function PropaleStats($DB, $socid=0, $userid=0)
{
@ -78,8 +78,10 @@ class PropaleStats extends Stats
/**
* Renvoie le nombre de proposition par mois pour une ann<EFBFBD>e donn<EFBFBD>e
*
* Return propals number by month for a year
*
* @param int $year year for stats
* @return array array with number by month
*/
function getNbByMonth($year)
{
@ -97,7 +99,9 @@ class PropaleStats extends Stats
}
/**
* Renvoie le nombre de propale par annee
* Return propals number by year
*
* @return array array with number by year
*
*/
function getNbByYear()
@ -113,9 +117,12 @@ class PropaleStats extends Stats
return $this->_getNbByYear($sql);
}
/**
* Renvoie le nombre de propale par mois pour une annee donnee
* Return the propals amount by month for a year
*
* @param int $year year for stats
* @return array array with number by month
*/
function getAmountByMonth($year)
{
@ -131,9 +138,12 @@ class PropaleStats extends Stats
return $this->_getAmountByMonth($year, $sql);
}
/**
* Return the propals amount average by month for a year
*
*
* @param int $year year for stats
* @return array array with number by month
*/
function getAverageByMonth($year)
{
@ -150,10 +160,10 @@ class PropaleStats extends Stats
return $this->_getAverageByMonth($year, $sql);
}
/**
* \brief Return nb, total and average
* \return array Array of values
* Return nb, total and average
*
* @return array Array of values
*/
function getAllByYear()
{

View File

@ -639,11 +639,11 @@ if ($account || $_GET["ref"])
// Amount
if ($objp->amount < 0)
{
print '<td align="right" nowrap>'.price($objp->amount * -1).'</td><td>&nbsp;</td>'."\n";
print '<td align="right" nowrap="nowrap">'.price($objp->amount * -1).'</td><td>&nbsp;</td>'."\n";
}
else
{
print '<td>&nbsp;</td><td align="right" nowrap>&nbsp;'.price($objp->amount).'</td>'."\n";
print '<td>&nbsp;</td><td align="right" nowrap="nowrap">&nbsp;'.price($objp->amount).'</td>'."\n";
}
// Balance

View File

@ -154,99 +154,96 @@ function task_prepare_head($object)
*/
function select_projects($socid=-1, $selected='', $htmlname='projectid')
{
global $db,$user,$conf,$langs;
$hideunselectables = false;
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
$projectstatic=new Project($db);
$projectsListId = '';
if (empty($user->rights->projet->all->lire))
{
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1);
}
// On recherche les projets
$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public';
$sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p';
$sql.= " WHERE p.entity = ".$conf->entity;
if ($projectsListId) $sql.= " AND p.rowid in (".$projectsListId.")";
if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
//if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc='0' OR p.fk_soc IS NULL)"; // We will filter later
$sql.= " ORDER BY p.title ASC";
//print $sql;
//var_dump($user->rights);
dol_syslog("project.lib::select_projects sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
print '<select class="flat" name="'.$htmlname.'">';
print '<option value="0">&nbsp;</option>';
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
{
// Do nothing
}
else
{
$labeltoshow=dol_trunc($obj->ref,16);
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0)
{
print '<option value="'.$obj->rowid.'" selected="selected">'.$labeltoshow.'</option>';
}
else
{
$disabled=0;
if (! $obj->fk_statut > 0)
{
$disabled=1;
$labeltoshow.=' - '.$langs->trans("Draft");
}
if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
{
$disabled=1;
$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
}
if ($hideunselectables && $disabled)
{
$resultat='';
}
else
{
$resultat='<option value="'.$obj->rowid.'"';
if ($disabled) $resultat.=' disabled="disabled"';
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$resultat.='>'.$labeltoshow;
if (! $disabled) $resultat.=' - '.dol_trunc($obj->title,12);
$resultat.='</option>';
}
print $resultat;
}
}
$i++;
}
}
print '</select>';
$db->free($resql);
return $num;
}
else
{
dol_print_error($db);
return -1;
}
global $db,$user,$conf,$langs;
$hideunselectables = false;
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
$projectsListId = false;
if (empty($user->rights->projet->all->lire))
{
$projectstatic=new Project($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1);
}
// On recherche les projets
$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public';
$sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p';
$sql.= " WHERE p.entity = ".$conf->entity;
if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
$sql.= " ORDER BY p.title ASC";
dol_syslog("project.lib::select_projects sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
print '<select class="flat" name="'.$htmlname.'">';
print '<option value="0">&nbsp;</option>';
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
{
// Do nothing
}
else
{
$labeltoshow=dol_trunc($obj->ref,16);
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0)
{
print '<option value="'.$obj->rowid.'" selected="selected">'.$labeltoshow.'</option>';
}
else
{
$disabled=0;
if (! $obj->fk_statut > 0)
{
$disabled=1;
$labeltoshow.=' - '.$langs->trans("Draft");
}
if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
{
$disabled=1;
$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
}
if ($hideunselectables && $disabled)
{
$resultat='';
}
else
{
$resultat='<option value="'.$obj->rowid.'"';
if ($disabled) $resultat.=' disabled="disabled"';
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$resultat.='>'.$labeltoshow;
if (! $disabled) $resultat.=' - '.dol_trunc($obj->title,12);
$resultat.='</option>';
}
print $resultat;
}
}
$i++;
}
}
print '</select>';
$db->free($resql);
return $num;
}
else
{
dol_print_error($db);
return -1;
}
}

File diff suppressed because one or more lines are too long

View File

@ -35,17 +35,120 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
<title><?php echo $langs->trans('Login'); ?></title>
<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/includes/jquery/js/jquery-latest.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $conf_css; ?>" />
<?php echo $conf->global->MAIN_HTML_HEADER ?>
<?php
$favicon=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/favicon.ico';
?>
<link rel="shortcut icon" type="image/x-icon" href="<?php echo $favicon; ?>" />
<link rel="shortcut icon" type="image/x-icon" href="<?php echo DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/favicon.ico'; ?>" />
<?php if (! empty($conf->global->MAIN_HTML_HEADER)) print $conf->global->MAIN_HTML_HEADER; ?>
<!-- HTTP_USER_AGENT = <?php echo $_SERVER['HTTP_USER_AGENT']; ?> -->
</head>
<body class="body">
<!-- Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second -->
<script type="text/javascript">
function DisplayDstSwitchDates(firstsecond)
{
var year = new Date().getYear();
if (year < 1000) year += 1900;
var firstSwitch = 0;
var secondSwitch = 0;
var lastOffset = 99;
// Loop through every month of the current year
for (i = 0; i < 12; i++)
{
// Fetch the timezone value for the month
var newDate = new Date(Date.UTC(year, i, 0, 0, 0, 0, 0));
var tz = -1 * newDate.getTimezoneOffset() / 60;
// Capture when a timzezone change occurs
if (tz > lastOffset)
firstSwitch = i-1;
else if (tz < lastOffset)
secondSwitch = i-1;
lastOffset = tz;
}
// Go figure out date/time occurences a minute before
// a DST adjustment occurs
var secondDstDate = FindDstSwitchDate(year, secondSwitch);
var firstDstDate = FindDstSwitchDate(year, firstSwitch);
if (firstsecond == 'first') return firstDstDate;
if (firstsecond == 'second') return secondDstDate;
if (firstDstDate == null && secondDstDate == null)
return 'Daylight Savings is not observed in your timezone.';
else
return 'Last minute before DST change occurs in ' +
year + ': ' + firstDstDate + ' and ' + secondDstDate;
}
function FindDstSwitchDate(year, month)
{
// Set the starting date
var baseDate = new Date(Date.UTC(year, month, 0, 0, 0, 0, 0));
var changeDay = 0;
var changeMinute = -1;
var baseOffset = -1 * baseDate.getTimezoneOffset() / 60;
var dstDate;
// Loop to find the exact day a timezone adjust occurs
for (day = 0; day < 50; day++)
{
var tmpDate = new Date(Date.UTC(year, month, day, 0, 0, 0, 0));
var tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
// Check if the timezone changed from one day to the next
if (tmpOffset != baseOffset)
{
var minutes = 0;
changeDay = day;
// Back-up one day and grap the offset
tmpDate = new Date(Date.UTC(year, month, day-1, 0, 0, 0, 0));
tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
// Count the minutes until a timezone chnage occurs
while (changeMinute == -1)
{
tmpDate = new Date(Date.UTC(year, month, day-1, 0, minutes, 0, 0));
tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;
// Determine the exact minute a timezone change
// occurs
if (tmpOffset != baseOffset)
{
// Back-up a minute to get the date/time just
// before a timezone change occurs
tmpOffset = new Date(Date.UTC(year, month,
day-1, 0, minutes-1, 0, 0));
changeMinute = minutes;
break;
}
else
minutes++;
}
// Add a month (for display) since JavaScript counts
// months from 0 to 11
dstDate = tmpOffset.getMonth() + 1;
// Pad the month as needed
if (dstDate < 10) dstDate = "0" + dstDate;
// Add the day and year
dstDate = year + '-' + dstDate + '-' + tmpOffset.getDate() + 'T';
// Capture the time stamp
tmpDate = new Date(Date.UTC(year, month,
day-1, 0, minutes-1, 0, 0));
dstDate += tmpDate.toTimeString().split(' ')[0] + 'Z';
return dstDate;
}
}
}
jQuery(document).ready(function () {
// Set focus on correct field
<?php if ($focus_element) { ?>jQuery('#<?php echo $focus_element; ?>').focus(); <?php } ?> // Warning to use this only on visible element
@ -65,8 +168,13 @@ jQuery(document).ready(function () {
} else {
dst = "1"; // daylight savings time is observed
}
var dst_first=DisplayDstSwitchDates('first');
var dst_second=DisplayDstSwitchDates('second');
//alert(dst);
jQuery('#tz').val(std_time_offset); // returns TZ
jQuery('#dst').val(dst); // returns DST
jQuery('#dst_observed').val(dst); // returns if DST is observed on summer
jQuery('#dst_first').val(dst_first); // returns DST first switch in year
jQuery('#dst_second').val(dst_second); // returns DST second switch in year
// Detect and save screen resolution
jQuery('#screenwidth').val(jQuery(window).width()); // returns width of browser viewport
jQuery('#screenheight').val(jQuery(window).height()); // returns width of browser viewport
@ -78,7 +186,9 @@ jQuery(document).ready(function () {
<input type="hidden" name="loginfunction" value="loginfunction" />
<!-- Add fields to send local user information -->
<input type="hidden" name="tz" id="tz" value="" />
<input type="hidden" name="dst" id="dst" value="" />
<input type="hidden" name="dst_observed" id="dst_observed" value="" />
<input type="hidden" name="dst_first" id="dst_first" value="" />
<input type="hidden" name="dst_second" id="dst_second" value="" />
<input type="hidden" name="screenwidth" id="screenwidth" value="" />
<input type="hidden" name="screenheight" id="screenheight" value="" />