diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php
index 2abee28066e..bd3b96977c1 100644
--- a/htdocs/comm/fiche.php
+++ b/htdocs/comm/fiche.php
@@ -493,14 +493,29 @@ if ($id > 0)
if ($num > 0)
{
- print '
';
+ // Check if there are orders billable
+ $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,';
+ $sql2.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee';
+ $sql2.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
+ $sql2.= ', '.MAIN_DB_PREFIX.'commande as c';
+ $sql2.= ' WHERE c.fk_soc = s.rowid';
+ $sql2.= ' AND s.rowid = '.$object->id;
+ // Show orders with status validated, shipping started and delivered (well any order we can bill)
+ $sql2.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))";
+
+ $resql2=$db->query($sql2);
+ $num2 = $db->num_rows($resql2);
+ $db->free($resql2);
+
+ print '
';
}
$i = 0;
diff --git a/htdocs/comm/propal/propalstoorder.php b/htdocs/comm/propal/propalstoorder.php
new file mode 100755
index 00000000000..77905ed3170
--- /dev/null
+++ b/htdocs/comm/propal/propalstoorder.php
@@ -0,0 +1,688 @@
+
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2012 Andreu Bisquerra Gaya
+ * Copyright (C) 2012 David Rodriguez Martinez
+ * Copyright (C) 2012 Juanjo Menent
+ * Copyright (C) 2012 Maxime Kohlhaas
+ *
+ * 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/comm/propal/propalstoorder.php
+ * \ingroup propal
+ * \brief Page to order multiple propals
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
+if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
+
+$langs->load('orders');
+$langs->load('deliveries');
+$langs->load('companies');
+
+if (! $user->rights->commande->creer)
+ accessforbidden();
+
+$id = (GETPOST('id')?GETPOST("id"):GETPOST("facid")); // For backward compatibility
+$ref = GETPOST('ref','alpha');
+$action = GETPOST('action','alpha');
+$confirm = GETPOST('confirm','alpha');
+$sref = GETPOST('sref');
+$sref_client = GETPOST('sref_client');
+$sall = GETPOST('sall');
+$socid = GETPOST('socid','int');
+
+
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+if (! $sortfield) $sortfield='p.rowid';
+if (! $sortorder) $sortorder='DESC';
+
+$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server
+$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
+$date_starty=dol_mktime(0,0,0,$_REQUEST["date_start_delymonth"],$_REQUEST["date_start_delyday"],$_REQUEST["date_start_delyyear"]); // Date for local PHP server
+$date_endy=dol_mktime(23,59,59,$_REQUEST["date_end_delymonth"],$_REQUEST["date_end_delyday"],$_REQUEST["date_end_delyyear"]);
+$selected=GETPOST('propals_to_order');
+$action=GETPOST('action','alpha');
+if ($action == 'create')
+{
+ if (! is_array($selected))
+ {
+ $mesgs[]='