function _liste()
{
    global $langs, $db, $user, $conf;
    $langs->load('asset@asset');
    llxHeader('', $langs->trans('ListControl'), '', '');
    getStandartJS();
    if (isset($_SESSION['AssetMsg'])) {
        print_r('<div class="info">' . $langs->trans($_SESSION['AssetMsg']) . '</div>');
        unset($_SESSION['AssetMsg']);
    }
    $form = new TFormCore();
    $assetControl = new TAssetControl();
    $r = new TSSRenderControler($assetControl);
    $sql = 'SELECT rowid as id, libelle, type, question, "" as action FROM ' . MAIN_DB_PREFIX . 'asset_control';
    $THide = array('id');
    $form = new TFormCore($_SERVER['PHP_SELF'], 'form', 'GET');
    $ATMdb = new TPDOdb();
    $r->liste($ATMdb, $sql, array('limit' => array('nbLine' => '30'), 'subQuery' => array(), 'link' => array('libelle' => '<a href="' . DOL_URL_ROOT . '/custom/asset/control.php?id=@id@">' . img_picto('', 'object_generic.png', '', 0) . '@val@</a>', 'question' => '<a href="' . DOL_URL_ROOT . '/custom/asset/control.php?id=@id@">@val@</a>', 'action' => '<a title="Modifier" href="control.php?id=@id@&action=edit">' . img_picto('', 'edit.png', '', 0) . '</a>&nbsp;&nbsp;&nbsp;<a title="Supprimer" onclick="if (!window.confirm(\'Confirmez-vous la suppression ?\')) return false;" href="control.php?id=@id@&action=delete">' . img_picto('', 'delete.png', '', 0) . "</a>"), 'search' => array('libelle' => array('recherche' => true, 'table' => '')), 'translate' => array(), 'hide' => $THide, 'liste' => array('titre' => $langs->trans('ListControl'), 'image' => img_picto('', 'title.png', '', 0), 'picto_precedent' => img_picto('', 'back.png', '', 0), 'picto_suivant' => img_picto('', 'next.png', '', 0), 'noheader' => 0, 'messageNothing' => $langs->trans('AssetEmptyControl'), 'picto_search' => img_picto('', 'search.png', '', 0)), 'title' => array('libelle' => 'Libelle', 'type' => 'Type', 'nb_value' => 'Nombre de valeurs associés', 'question' => 'Question', 'action' => 'Action'), 'eval' => array('type' => 'TAssetControl::$TType["@val@"]')));
    $form->end();
    echo '<div class="tabsAction">';
    echo '<a class="butAction" href="control.php?action=new">' . $langs->trans('AssetCreateControl') . '</a>';
    echo '</div>';
    $ATMdb->close();
    llxFooter('');
}
Esempio n. 2
0
function _fiche(&$PDOdb, &$hero, $action = 'view')
{
    global $db;
    // création du template
    $form = new TFormCore($_SERVER['PHP_SELF'], 'form', 'POST');
    //affiche un formulaire qui définit les actions
    print $form->hidden('action', 'save');
    print $form->hidden('id', $hero->getId());
    //définit le type d'action du formulaire en fonction de la variable $action récupérée par le GETPOST
    $form->Set_typeaff($action);
    //instanciationb de l'objet template
    $TBS = new TTemplateTBS();
    $buttons = '';
    //si l'action passée en paramètre est à view :
    //on affiche les boutons modifier et supprimer
    if ($action == 'view') {
        //si l'id du héro est égal à 1 :
        //on ne peut qu'ajouter un héro (on ne peut pas supprimer un héro inexistant)
        if ($hero->getId() > 0) {
            $buttons .= "<input type=\"button\" id=\"action-delete\" value=\"Supprimer\" name=\"cancel\" class=\"butActionDelete\" onclick=\"if(confirm('Supprimer ce hero ?'))document.location.href='?action=delete&id=" . $hero->rowid . "'\" />";
        }
        $buttons .= '<a class="butAction" href="?action=edit&id=' . $hero->getId() . '">Modifier</a>';
    } else {
        $buttons .= $form->btsubmit('Valider', 'save');
    }
    /*$btSave = $form->btsubmit('Valider', 'save');
        $btCancel = $form->btsubmit('Annuler', 'cancel');
    	
    	$btDelete = ;
    	*/
    $THero = $hero->get_tab();
    //création de la zone de texte (tirée du template) qui permet d'ajouter le ,nom du héro
    $THero['name'] = $form->texte('', 'name', $hero->name, 30, 255);
    //création de la zone de texte (tirée du template) qui permet d'ajouter la description
    $THero['description'] = $form->zonetexte('', 'description', $hero->description, 80, 5);
    //récupération des pouvoirs dans TPower (tableau de pouvoirs)
    $TPower = $hero->getPower();
    $THero['powers'] = '';
    if (empty($TPower) && $action == 'view') {
        $THero['powers'] .= 'pas de chocolat';
    } else {
        foreach ($TPower as $idp => $pName) {
            if (!empty($THero['powers'])) {
                $THero['powers'] .= ', ';
            }
            $THero['powers'] .= $pName;
            if ($action == 'edit') {
                $THero['powers'] .= ' <a href="?action=delete-power&id=' . $hero->getId() . '&idPower=' . $idp . '">X</a>';
            }
        }
    }
    if ($action == 'edit') {
        $THero['powers'] .= $form->texte(' - Nouveau pouvoir', 'power', '', 30);
    }
    print $TBS->render('./tpl/hero.tpl.php', array(), array('hero' => $THero, 'view' => array('mode' => $mode), 'buttons' => array('buttons' => $buttons)));
    $form->end_form();
}
function _fiche(&$PDOdb, &$idea, $mode = 'view', $editValue = false)
{
    global $db, $langs, $user;
    llxHeader('', $langs->trans('IdeaboxAddItem'), '', '');
    /******/
    $TBS = new TTemplateTBS();
    $TBS->TBS->protect = false;
    $TBS->TBS->noerr = true;
    $form = new TFormCore($_SERVER['PHP_SELF'], 'form', 'POST');
    $form->Set_typeaff($mode);
    echo $form->hidden('id', $idea->getId());
    echo $form->hidden('action', 'save');
    $TIdeaboxItem = _fiche_ligne_ideabox_item($PDOdb, $idea->getId(), $mode);
    $formDoli = new Form($db);
    print $TBS->render('tpl/ideabox.tpl.php', array('TIdeaboxItem' => $TIdeaboxItem), array('TIdeabox' => array('id' => (int) $idea->getId(), 'label' => $form->texte('', 'label', $idea->label, 80, 150, '', '', 'à saisir'), 'usergroup' => $mode == 'view' ? $idea->getNameUserGroup($db) : $formDoli->select_dolgroups($idea->fk_usergroup, 'fk_usergroup', 1)), 'view' => array('type' => 'showficheideabox', 'mode' => $mode, 'user_right' => $user->rights->ideabox->create, 'url' => dol_buildpath('/ideabox/ideabox.php', 2))));
    $form->end();
    llxFooter();
}
    /**
     * Overloading the doActions function : replacing the parent's function with the one below
     *
     * @param   array()         $parameters     Hook metadatas (context, etc...)
     * @param   CommonObject    &$object        The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
     * @param   string          &$action        Current action (if set). Generally create or edit or null
     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
     * @return  int                             < 0 on error, 0 on success, 1 to replace standard code
     */
    function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
    {
        if (in_array('propalcard', explode(':', $parameters['context'])) || in_array('ordercard', explode(':', $parameters['context']))) {
            global $langs, $conf;
            $langs->load('free2product@free2product');
            global $addButtonToConvertAll;
            $base_new_ref = !empty($conf->global->FREE2PRODUCT_BASE_NEWREF) ? $conf->global->FREE2PRODUCT_BASE_NEWREF : 'FREELINE-';
            if ($addButtonToConvertAll) {
                // On ajoute l'inclusion d'abricot
                define('INC_FROM_DOLIBARR', true);
                dol_include_once('/free2product/config.php');
                ?>
				<div class="inline-block divButAction">
					<a class="butAction" href="javascript:convertAllFreeLine();">
						<?php 
                echo $langs->trans('convertAllFreeLine');
                ?>
					</a>
					
				</div>

				<div id="convertAllFreeLine_popup" style="display:none">
					<?php 
                $formCore = new TFormCore();
                ?>
					<table class="border" width="100%">
						<?php 
                foreach ($object->lines as &$line) {
                    if ($line->product_type <= 1 && $line->fk_product == 0) {
                        $lineid = !empty($line->id) ? $line->id : $line->rowid;
                        // compatibilité 3.6
                        $desc = !empty($line->desc) ? $line->desc : $line->description;
                        // compatibilité 3.6
                        echo '<tr>
										<td>' . $formCore->texte('', 'TFreeProduct[' . $line->id . '][ref]', $base_new_ref . $lineid, 15, 255, ' lineid="' . $lineid . '" label="' . htmlentities(addslashes($desc)) . '" qty="' . $line->qty . '" price="' . $line->subprice . '" product_type="' . $line->product_type . '" tva="' . $line->tva_tx . '" ') . '</td>
										<td>' . $line->desc . '</td>
										<td align="right">' . price($line->subprice) . '</td>
										<td align="right">' . price($line->qty) . '</td>
									</tr>';
                    }
                }
                ?>
					</table>
					
				</div>
					<?php 
            }
        }
    }
function _printFormConfirm(&$user, &$db, &$conf, &$langs, &$TPayment)
{
    global $bc;
    $form = new Form($db);
    $TFormCore = new TFormCore();
    print load_fiche_titre($langs->trans('Payments'));
    print '<div class="tabBar">';
    print '<form name="import_confirm" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    print '<input type="hidden" name="action" value="import_confirm">';
    print '<p>';
    print '<label><b>' . $langs->trans('paymentimport_typepayment') . '</b></label>&nbsp;';
    $form->select_types_paiements($conf->global->PAYMENTIMPORT_DEFAULT_REGLEMENT_CODE, 'paiementcode', '', 2);
    print '</p>';
    print '<p>';
    print '<label><b>' . $langs->trans('paymentimport_bankaccount') . '</b></label>&nbsp;';
    print $form->select_comptes($conf->global->PAYMENTIMPORT_DEFAULT_BANK_ACOUNT, 'fk_bank', 0);
    print '</p>';
    print '<table class="border" width="100%">';
    print '<tr class="liste_titre">';
    print '<td>' . $langs->trans("RefFacture") . '</td>';
    print '<td>' . $langs->trans("Company") . '</td>';
    print '<td>' . $langs->trans("CodeClient") . '</td>';
    print '<td>' . $langs->trans("Rib") . '</td>';
    print '<td>' . $langs->trans("AmountPayment") . '</td>';
    print '<td>' . $langs->trans("DatePayment") . '</td>';
    print '<td>' . $langs->trans("Num") . '</td>';
    print '<td>' . $langs->trans("Note") . '</td>';
    print '</tr>';
    $var = false;
    $i = 0;
    foreach ($TPayment as $TInfo) {
        $var = !$var;
        print '<tr ' . $bc[$var] . '>';
        print '<td><input type="text" name="payment[' . $i . '][facture_ref]" value="' . $TInfo['facture_ref'] . '" /> - <a target="_blank" href="' . dol_buildpath('/compta/facture.php?ref=' . $TInfo['facture_ref'], 1) . '">v</a></td>';
        print '<td>' . $TInfo['company_name'] . '</td>';
        print '<td>' . $TInfo['code_client'] . '</td>';
        print '<td>' . $TInfo['rib'] . '</td>';
        print '<td><input type="text" name="payment[' . $i . '][amount]" value="' . $TInfo['amount'] . '" /></td>';
        print '<td>' . $TFormCore->calendrier('', "payment[" . $i . "][date_creation]", $TInfo['date_creation']) . '</td>';
        print '<td><input type="text" name="payment[' . $i . '][num_payment]" value="' . $TInfo['num_payment'] . '" /></td>';
        print '<td><input type="text" name="payment[' . $i . '][note]" value="' . $TInfo['note'] . '" /></td>';
        print '</tr>';
        $i++;
    }
    print '</table>';
    print '<div class="tabsAction"><div class="center divButAction"><input class="button" type="submit" value="' . $langs->trans('CreatePayment') . '" /></div></div>';
    print '</form>';
}
function fiche_preview(&$object, &$TData)
{
    global $langs, $user, $db, $conf;
    //var_dump($_REQUEST);exit;
    $origin = GETPOST('origin');
    $head = null;
    if ($object->element == 'propal') {
        $head = propal_prepare_head($object);
    } else {
        $head = commande_prepare_head($object);
    }
    if (empty($user->rights->importdevis->myactions)) {
        accessforbidden();
        exit;
    }
    $form = new Form($db);
    llxHeader();
    $title = $langs->trans('Import');
    if ($origin == 'propal') {
        dol_fiche_head($head, 'importdevis', $title, 0, 'propal');
    } else {
        dol_fiche_head($head, 'importdevis', $title, 0, 'commande');
    }
    ?>
		<style type="text/css">
			#table_before_import tr.title_line td.for_line > * {
				display:none;
			}
			
			#table_before_import tr.line_line td.for_title > * {
				display:none;
			}
			
			.for_line select{
				white-space:normal;
				width:300px;
			}
			.ui-dialog {
			    overflow: visible !important;  /* or 'visible' whatever */
			}
		</style>
		
		<script type="text/javascript">
			$(function() {
				var old_type;
				
				$('#to_parse .type select').unbind().click(function() { old_type = $(this).val(); }).change(function() {
					switchClass($(this));
				});
				
				$( "#pop-edit-product-link" ).dialog({
			      modal: true,
			      autoOpen: false,
			      title:"Lier un produit à cette ligne",
			      buttons: {
			        "Lier ce produit": function() {
			        	
			          var fk_product = $('#fk_product_to_link').val() ;
			          var k = $(this).attr('k');	
			          $input = $('tr[k='+k+'] input[rel=fk_product]');
			         //console.log($input);
			         
			          $.ajax({
			          	url:"<?php 
    echo dol_buildpath('/product/ajax/products.php', 1);
    ?>
?action=fetch&id="+fk_product
			          	,dataType:'json'
			          }).done(function(product) {
			          	
			          	$('span[rel="ref-product"][k='+k+']').html(product.ref);
			          	$input.val(fk_product);
			          	console.log(product);
			          	
			          });
			        		
			          $( this ).dialog( "close" );
			        }
			      }
			    });
				
				function switchClass(element)
				{
					var type_value = $(element).val();
	
					if (type_value == 'title') 
					{
						$(element).parent().parent().addClass('liste_titre title_line');
						$(element).parent().parent().removeClass('line_line');
					}
					else 
					{
						$(element).parent().parent().addClass('line_line');
						$(element).parent().parent().removeClass('liste_titre title_line');
						
						if (old_type == 'title' && type_value == 'line')
						{
							while (element.length > 0)
							{
								element = $(element).parent().parent().next().find('td.type').children('select');
								
								if (element.val() == 'title') break;
								
								element.children('option[value=nomenclature]').attr('selected', true);
							}
							
						}
					}
				}
			});
			
			var imp_is_all_check = true;
			function checkAndUncheckAllImport()
			{
				if (imp_is_all_check)
				{
					imp_is_all_check = false;
					$("#to_parse tr .check_imp").attr('checked', false).prop('checked', false);
				}
				else
				{
					imp_is_all_check = true;
					$("#to_parse tr .check_imp").attr('checked', true).prop('checked', true);
				}
			}
			
			function edit_product_link(k) {
				$div = $('#pop-edit-product-link');
				$div.attr('k', k);
				
				$div.dialog('open');
			}
			
		</script>
		<div id="pop-edit-product-link" class="ui-dialog"  >
			<?php 
    $form->select_produits('', 'fk_product_to_link');
    ?>
		</div>
		<table id="table_before_import" width="100%" class="border">
			<tr>
				<td width="25%"><?php 
    echo $langs->trans('Ref');
    ?>
</td>
				<td colspan="3"><div style="vertical-align: middle"><div class="inline-block floatleft refid"><?php 
    echo $object->ref;
    ?>
</div></div></td>
			</tr>
			<tr>
				<td><?php 
    echo $langs->trans('Company');
    ?>
</td>MO-1
				<td colspan="3"><?php 
    echo $object->thirdparty->getNomUrl(1);
    ?>
</td>
			</tr>
			<tr>
				<td colspan="4">
					
						<?php 
    $PDOdb = new TPDOdb();
    $formCore = new TFormCore('auto', 'to_parse', 'post');
    echo $formCore->hidden('action', 'import_data');
    echo $formCore->hidden('id', $object->id);
    echo $formCore->hidden('origin', $origin);
    echo $formCore->hidden('token', $_SESSION['newtoken']);
    echo $formCore->hidden('data', base64_encode(serialize($TData)));
    ?>
							<table class="border" width="100%">
								<tr class="liste_titre">
									<th onclick="javascript:checkAndUncheckAllImport();" style="cursor:pointer;" title="sélectionner/désélectionner tous">Imp.</th>
									<th>Type</th>
									<?php 
    if ($conf->subtotal->enabled) {
        ?>
<th>Niveau</th><?php 
    }
    ?>
									<th>Produit</th>
									<th>Label</th>
									<th>Qté</th>
									<?php 
    if (!empty($conf->global->PRODUCT_USE_UNITS)) {
        ?>
<th>Unité</th><?php 
    }
    ?>
									<th>Prix Achat</th>
									<th>Prix</th>
									<?php 
    if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
        ?>
									<th>Ligne d'origine</th>
									<?php 
    }
    ?>
								</tr>
							<?php 
    if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
        $TPropalDet = array();
        foreach ($object->lines as $line) {
            $label = !empty($line->label) ? $line->label : $line->desc;
            $label .= ' (qté : ' . $line->qty . ', total HT : ' . $line->total_ht . ')';
            $TPropalDet[$line->id] = $label;
        }
    }
    $class = '';
    //var_dump($TData);
    $TWorkstation = TWorkstation::getWorstations($PDOdb);
    foreach ($TData as $k => &$row) {
        //var_dump($row);MO-1
        $workstation = new TWorkstation();
        //var_dump($workstation->loadBy($PDOdb, $row['workstation'], 'code'));
        //var_dump($workstation);exit;
        if (!empty($row['ref'])) {
            $res = $workstation->loadBy($PDOdb, $row['ref'], 'code');
            if ($res > 0) {
                $row['type'] = 'workstation';
                $id_workstation = $workstation->getId();
                //var_dump($workstation);
            }
        }
        $type = $row['type'];
        if ($type == 'title') {
            $class = '';
            print '<tr class="' . $class . ' liste_titre title_line">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            print '<td class="for_title">' . $form->selectarray('TData[' . $k . '][level]', getLevelTitle(), $row['level']) . '</td>';
            print '<td class="for_line">';
            //$form->select_produits(0, 'TData['.$k.'][fk_product]');
            print '</td>';
            print '<td>' . $formCore->texte('', 'TData[' . $k . '][label]', $row['label'], 50, 255) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line"></td>';
            }
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
        } elseif ($type == 'workstation') {
            //var_dump($type);
            $class = '';
            print '<tr class="' . $class . ' workstation_line">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            print '<td></td>';
            print '<td class="for_line">';
            echo $formCore->combo('', 'TData[' . $k . '][fk_workstation]', $TWorkstation, $id_workstation);
            print '</td>';
            print '<td>' . $row['workstation'] . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line"></td>';
            }
            print '<td></td>';
            print '<td></td>';
        } else {
            $class = $class == 'impair' ? 'pair' : 'impair';
            print '<tr class="line_line ' . $class . '" k="' . $k . '">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            if ($conf->subtotal->enabled) {
                print '<td class="for_title">' . $form->selectarray('TData[' . $k . '][level]', getLevelTitle(), $row['level']) . '</td>';
            }
            print '<td class="for_line">';
            if (!empty($row['product_ref'])) {
                $p = new Product($db);
                $p->fetch(null, $row['product_ref']);
                $fk_product = $p->id;
            } else {
                $fk_product = 0;
            }
            print '<span rel="ref-product" k="' . $k . '">' . ($fk_product > 0 ? $p->getNomUrl(1) : 'N/A') . '</span> <a href="javascript:edit_product_link(' . $k . ')">' . img_edit('Changer le produit de destination') . '</a>';
            //$form->select_produits($fk_product, 'TData['.$k.'][fk_product]');
            echo $formCore->hidden('TData[' . $k . '][fk_product]', $fk_product, ' rel="fk_product" ');
            echo $formCore->hidden('TData[' . $k . '][product_ref]', $row['product_ref'], ' rel="product_ref" ');
            print '</td>';
            print '<td>' . $formCore->texte('', 'TData[' . $k . '][label]', $row['label'], 80, 255);
            print '<table>';
            print '<tr>';
            print '<td>Longueur : ' . $formCore->texte('', 'TData[' . $k . '][length]', $row['length'], 15, 255) . '</td>';
            print '<td>Largeur : ' . $formCore->texte('', 'TData[' . $k . '][width]', $row['width'], 15, 255) . '</td>';
            print '<td>Hauteur : ' . $formCore->texte('', 'TData[' . $k . '][height]', $row['height'], 15, 255) . '</td>';
            print '<td>Poids : ' . $formCore->texte('', 'TData[' . $k . '][weight]', $row['weight'], 15, 255) . '</td>';
            print '</tr>';
            print '</table>';
            print '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line">' . $form->selectUnits($row['fk_unit'], 'TData[' . $k . '][fk_unit]', 1) . '</td>';
            }
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][buy_price]', $row['buy_price'], 10, 20) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
        }
        if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
            print '<td class="for_line">' . $form->selectarray('TData[' . $k . '][fk_propaldet]', $TPropalDet, '', 1) . '</td>';
        }
        print '</tr>';
    }
    //exit;
    ?>
							</table>
							<div class="tabsAction">
								<?php 
    echo $langs->trans('DeleteLinesBeforeImport');
    ?>
 <input id="delete_lines_before_import" name="delete_lines_before_import" type="checkbox" value="1" />
								<input class="button" type="submit" value="<?php 
    echo $langs->trans('Import');
    ?>
" />
							</div>
							<?php 
    $formCore->end();
    ?>
				</td>
			</tr>
		</table>
	<?php 
    dol_fiche_end();
    llxFooter();
}
    //TODO je présume qu'ils veulent un recalcule des prix en fonction de la période ?
    $sql = "SELECT l.fk_product, ROUND(SUM(l.qty_used),3) as qty,l.fk_nomenclature";
    if (!empty($conf->global->NOMENCLATURE_ACTIVATE_DETAILS_COSTS)) {
        $sql .= ", n.totalPRCMO_PMP,n.totalPRCMO_OF,n.totalPRCMO";
    }
    $sql .= " FROM " . MAIN_DB_PREFIX . "assetOf_line l\n\t\tINNER JOIN " . MAIN_DB_PREFIX . "nomenclature n ON (n.rowid=l.fk_nomenclature)\n\t\tWHERE l.type='TO_MAKE' \n\t\tGROUP BY l.fk_product,l.fk_nomenclature";
    $listeview = new TListviewTBS('graphCost2');
    //$PDOdb->debug=true;
    print $listeview->render($PDOdb, $sql, array('liste' => array('titre' => $langs->transnoentitiesnoconv('RapportAnalyseCoutProductPF')), 'link' => array('fk_nomenclature' => '<a href="' . dol_buildpath('/nomenclature/nomenclature.php?fk_product=@fk_product@', 1) . '">' . img_picto($langs->trans('Nomenclature'), 'object_list') . ' @val@</a>'), 'eval' => array('fk_product' => '_product_link(@fk_product@)'), 'type' => array('qty' => 'number', 'totalPRCMO' => 'number', 'totalPRCMO_PMP' => 'number', 'totalPRCMO_OF' => 'number', 'date_maj' => 'date'), 'title' => array('fk_product' => $langs->trans('Product'), 'qty' => $langs->trans('Qty'), 'totalPRCMO' => $langs->trans('PricePA'), 'totalPRCMO_PMP' => $langs->trans('PricePMP'), 'totalPRCMO_OF' => $langs->trans('PriceOF'), 'date_maj' => $langs->trans('Date'), 'fk_nomenclature' => $langs->trans('Nomenclature')), 'search' => array('date_maj' => array('recherche' => 'calendars', 'table' => 'l'))));
    $formCore->end();
}
if (!empty($conf->quality->enabled)) {
    echo '<hr />';
    dol_include_once('/quality/class/quality.class.php');
    $sql = "SELECT l.fk_product, q.code, q.qty, q.date_cre, q.comment\n\t\tFROM " . MAIN_DB_PREFIX . "assetOf_line l \n\t\t\tINNER JOIN " . MAIN_DB_PREFIX . "quality q ON (q.fk_object = l.rowid AND q.type_object = 'TAssetOFLine') \n\t\tWHERE l.type='NEEDED' AND q.code!='NORMAL' AND q.qty!=0\n\t\t";
    $formCore = new TFormCore('auto', 'formGraph3');
    $listeview = new TListviewTBS('graphCost3');
    //$PDOdb->debug=true;
    print $listeview->render($PDOdb, $sql, array('liste' => array('titre' => $langs->transnoentitiesnoconv('RapportAnalyseMotifRebus')), 'eval' => array('fk_product' => '_product_link(@fk_product@)'), 'translate' => array('code' => TC_quality::getAll($PDOdb, true)), 'type' => array('qty' => 'number', 'date_cre' => 'date'), 'title' => array('fk_product' => $langs->trans('Product'), 'qty' => $langs->trans('Qty'), 'comment' => $langs->trans('Comment'), 'code' => $langs->trans('Code'), 'date_cre' => $langs->trans('Date')), 'search' => array('date_cre' => array('recherche' => 'calendars', 'table' => 'l'))));
    $formCore->end();
}
dol_fiche_end();
// End of page
llxFooter();
function _get_percent($qty, $qty_used)
{
    $percent = ($qty_used - $qty) / $qty * 100;
    $color = '';
    if ($percent > 0.5) {
        $color = 'red';
    } else {
function _create(&$PDOdb, &$db, &$user, &$conf, &$langs, $df = false, $ds = false, $de = false, $amount = 0, $label = '')
{
    unset($_SESSION['SENDTOINVOICETOADHERENT_ERRORS']);
    _list($PDOdb, $db, $user, $conf, $langs, 0);
    if (!$user->rights->sendinvoicetoadherent->create) {
        accessforbidden();
    } else {
        $form = new TFormCore();
        print_fiche_titre($langs->trans("sendinvoicetoadherentTitleCreate"));
        echo '<script type="text/javascript">
			$(function() {
				displayDateCotisation();
			});
			
			function displayDateCotisation(obj) {
				if ($(obj).attr("checked") == "checked") {
					$(".cotisation_create").show()
				} else {
					$(".cotisation_create").hide()
				}
			}
		</script>';
        echo '<form style="padding-top:15px;" name="formsoc" action="' . $_SERVER["PHP_SELF"] . '" method="post" enctype="multipart/form-data">';
        echo '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
        echo '<input type="hidden" name="action" value="createConfirm">';
        echo '<table class="border" width="100%">';
        $date_fac = $df === false ? date('d/m/Y') : $df;
        $date_start = $ds === false ? date('d/m/Y') : $ds;
        $date_end = $de === false ? date('d/m/Y', strtotime('+1 year -1 day')) : $de;
        $label = empty($label) ? $langs->trans("Subscription") . ' ' . ($ds ? substr($date_start, -4, 4) : dol_print_date(time(), '%Y')) : $label;
        echo '<tr><td width="20%" class="fieldrequired">' . $langs->trans("sendinvoicetoadherentDateFacture") . '</td><td width="80%">' . $form->calendrier('', 'date_fac', $date_fac) . '</td></tr>';
        echo '<tr><td width="20%">' . $langs->trans("sendinvoicetoadherentCreateCotisation") . '</td><td width="80%"><input type="checkbox" name="create_cotisation" value="1" onclick="javascript:displayDateCotisation(this);" /></td></tr>';
        echo '<tr class="cotisation_create" style="display:none;"><td width="20%" class="fieldrequired">' . $langs->trans("sendinvoicetoadherentDateStartAdhesion") . '</td><td width="80%">' . $form->calendrier('', 'date_start', $date_start) . '</td></tr>';
        echo '<tr class="cotisation_create" style="display:none;"><td width="20%">' . $langs->trans("sendinvoicetoadherentDateEndAdhesion") . '</td><td width="80%">' . $form->calendrier('', 'date_end', $date_end) . '</td></tr>';
        echo '<tr class="cotisation_create" style="display:none;"><td width="20%" class="fieldrequired">' . $langs->trans("sendinvoicetoadherentAmountAdhesion") . '</td><td width="80%">' . $form->texte('', 'amount_cotisation', $amount, 6, 15) . ' ' . $langs->trans("Currency" . $conf->currency) . '</td></tr>';
        echo '<tr class="cotisation_create" style="display:none;"><td width="20%">' . $langs->trans("sendinvoicetoadherentLabelAdhesion") . '</td><td width="80%">' . $form->texte('', 'label', $label, 32, 255) . '</td></tr>';
        echo '</table>';
        if ($user->rights->sendinvoicetoadherent->create) {
            echo '<br /><center>';
            echo '<input type="submit" class="button" value="' . $langs->trans('sendinvoicetoadherentActionCreateConfirm') . '" />&nbsp;&nbsp;&nbsp;&nbsp;';
            echo '<a href="' . dol_buildpath('/sendinvoicetoadherent/sendinvoicetoadherent.php?action=list', 2) . '" class="button" style="text-decoration:none;font-weight:normal;cusor:pointer;height:15px;padding-top:5px;">' . $langs->trans('Cancel') . '</a>';
            echo '</center>';
        }
        echo '</form>';
    }
    $PDOdb->close();
    llxFooter('');
}
function fiche(&$query)
{
    global $langs, $conf, $user;
    llxHeader('', 'Query', '', '', 0, 0, array('/query/js/query.js'), array('/query/css/query.css'));
    dol_fiche_head($query->title);
    if ($query->expert == 1) {
        if (!empty($query->sql_fields)) {
            $TField = explode_brackets($query->sql_fields);
            $query->TField = $TField;
        }
    }
    ?>
	<script type="text/javascript">
		var MODQUERY_INTERFACE = "<?php 
    echo dol_buildpath('/query/script/interface.php', 1);
    ?>
";
		var MODQUERY_QUERYID = <?php 
    echo $query->getId();
    ?>
;
		var MODQUERY_EXPERT = <?php 
    echo (int) $query->expert;
    ?>
;
		var MODQUERY_PREFIX = "<?php 
    echo MAIN_DB_PREFIX;
    ?>
";
		
		var select_equal = '<select sql-act="operator"> '
					+ '<option value=""> </option>'
					
					+ '<option value="LIKE">LIKE</option>'
					/*+ '<option value="=">=</option>'*/
					+ '<option value="!=">!=</option>'
					+ '<option value="&lt;">&lt;</option>'
					+ '<option value="&lt;=">&lt;=</option>'
					+ '<option value="&gt;">&gt;</option>'
					+ '<option value="&gt;=">&gt;=</option>'
					+ '<option value="IN">IN</option>'
					+ '</select>';
					
		var select_mode	= '<select sql-act="mode"> '
					+ '<option value="value">valeur</option>'
					+ '<option value="var">variable</option>'
					+ '<option value="function">fonction</option>'
					+ '</select> <input type="text" value="" sql-act="value" />';
			
		var select_null	= '<select sql-act="null"> '
					+ '<option value=""></option>'
					+ '<option value="1"><?php 
    echo $langs->transnoentities('YesAllowTestOnNull');
    ?>
</option>'
					+ '</select>';
			
		var select_order	= '<select sql-act="order"> '
					+ '<option value=""> </option>'
					+ '<option value="ASC">Ascendant</option>'
					+ '<option value="DESC">Descendant</option>'
					+ '</select>';
			
		var select_filter	= '<select sql-act="filter"> '
					+ '<option value="">Libre</option>'
					+ '<option value="calendar">Date</option>'
					+ '<option value="calendars">Dates</option>'
					+ '</select>';
			
		
			
		var select_hide	= '<select sql-act="hide"> '
					+ '<option value=""> </option>'
					+ '<option value="1"><?php 
    echo $langs->trans('Hidden');
    ?>
</option>'
					+ '</select>';
			
		var select_group	= '<select sql-act="group"> '
					+ '<option value=""> </option>'
					+ '<option value="1">Groupé</option>'
					+ '</select>';
		
		var select_total	= '<select sql-act="total"> '
					+ '<option value=""> </option>'
					+ '<option value="sum"><?php 
    echo $langs->trans('Total');
    ?>
</option>'
					+ '<option value="groupsum"><?php 
    echo $langs->trans('TotalGroup');
    ?>
</option>'
					+ '<option value="average"><?php 
    echo $langs->trans('Average');
    ?>
</option>'
					+ '<option value="count"><?php 
    echo $langs->trans('CountOf');
    ?>
</option>'
					+ '</select>';
					
		var select_total_group_field = '<select sql-act="field-total-group">'
						<?php 
    foreach ($query->TField as $field) {
        echo ' + \'<option value="' . _getFieldName($field) . '">' . _getFieldName($field) . '</option>\' ';
    }
    ?>
						+'</select>';
			
		var select_type	= '<select sql-act="type"> '
					+ '<option value=""> </option>'
					+ '<option value="number">Nombre</option>'
					+ '<option value="integer">Entier</option>'
					+ '<option value="datetime">Date/Heure</option>'
					+ '<option value="date">Date</option>'
					+ '<option value="hour">Heure</option>'
					+ '</select>';
					
		var select_function	= '<input type="text" size="10" sql-act="function" value="" placeholder="<?php 
    echo $langs->trans('FunctionToApply');
    ?>
" /><select sql-act="function-select"> '
					+ '<option value=""> </option>'
					+ '<option value="SUM(@field@)"><?php 
    echo $langs->trans('Sum');
    ?>
</option>'
					+ '<option value="ROUND(@field@,2)"><?php 
    echo $langs->trans('Round2dec');
    ?>
</option>'
					+ '<option value="COUNT(@field@)"><?php 
    echo $langs->trans('CountOf');
    ?>
</option>'
					+ '<option value="MIN(@field@)"><?php 
    echo $langs->trans('Minimum');
    ?>
</option>'
					+ '<option value="MAX(@field@)"><?php 
    echo $langs->trans('Maximum');
    ?>
</option>'
					+ '<option value="MONTH(@field@)"><?php 
    echo $langs->trans('Month');
    ?>
</option>'
					+ '<option value="YEAR"><?php 
    echo $langs->trans('Year');
    ?>
</option>'
					+ '<option value="DATE_FORMAT(@field@, \'%m/%Y\')"><?php 
    echo $langs->trans('YearMonth');
    ?>
</option>'
					//+ '<option value="FROM_UNIXTIME(@field@,\'%H:%i\')">Timestamp</option>'
					+ '<option value="SEC_TO_TIME(@field@)"><?php 
    echo $langs->trans('Timestamp');
    ?>
</option>'
					//+ '<option value="(@field@ / 3600)">/ 3600</option>'
					+ '</select>';
		
		var select_class = '<input type="text" size="10" sql-act="class" value="" placeholder="<?php 
    echo $langs->trans('Classname');
    ?>
" /><select sql-act="class-select"> '
						+ '<option value=""> </option>'

			<?php 
    foreach ($query->TClassName as $class => $label) {
        echo ' +\'<option value="' . $class . '">' . $label . '</option>\'';
    }
    ?>
			+ '</select>';

		var select_method = '<input type="text" size="10" sql-act="class-method" value="" placeholder="<?php 
    echo $langs->trans('Method');
    ?>
" /><select sql-act="class-method-select"> '
						+ '<option value=""> </option>'

			<?php 
    if (!empty($query->TMethodName)) {
        foreach ($query->TMethodName as $method => $label) {
            echo ' +\'<option value="' . $method . '">' . $label . '</option>\'';
        }
    }
    ?>
			+ '</select>';
		
		function _init_query() {
			
			<?php 
    if ($query->getId() > 0) {
        if ($query->expert == 2) {
            echo 'showQueryPreview(' . $query->getId() . ');';
            init_js($query);
        } else {
            if ($query->expert == 1) {
                echo 'showQueryPreview(' . $query->getId() . ');';
                if (!empty($query->TField)) {
                    foreach ($query->TField as $field) {
                        list($f, $t) = _getFieldAndTableName($field);
                        if (!empty($t)) {
                            $field = $t . '.' . $f;
                        } else {
                            $field = $f;
                        }
                        echo ' refresh_field_param("' . $field . '","' . $t . '"); ';
                    }
                }
                init_js($query);
            } else {
                foreach ($query->TTable as $table) {
                    echo 'addTable("' . $table . '"); ';
                }
                if (empty($query->TField) && !empty($query->sql_fields)) {
                    $query->TField = explode(',', $query->sql_fields);
                }
                //$TField =
                if (!empty($query->TField)) {
                    foreach ($query->TField as $field) {
                        echo ' checkField("' . $field . '"); ';
                    }
                    echo 'showQueryPreview(' . $query->getId() . ');';
                }
                init_js($query);
                if (!empty($query->TJoin)) {
                    foreach ($query->TJoin as $t => $join) {
                        ?>
							$("td[rel=from] select[jointure='<?php 
                        echo $t;
                        ?>
']").val("<?php 
                        echo $join[0];
                        ?>
");
							$("td[rel=to] select[jointure-to='<?php 
                        echo $t;
                        ?>
']").val("<?php 
                        echo $join[1];
                        ?>
");
							
							TJoin['<?php 
                        echo $t;
                        ?>
'] = ["<?php 
                        echo $join[0];
                        ?>
", "<?php 
                        echo $join[1];
                        ?>
"]; 
							<?php 
                    }
                }
                ?>
					refresh_sql();
					<?php 
            }
        }
    }
    ?>
		}
		
	</script>
	
	<form name="formQuery" id="formQuery">
		<input type="hidden" name="id" value="<?php 
    echo $query->getId();
    ?>
" />
		
	<div>
		<?php 
    if ($query->getId() > 0 && !empty($user->rights->query->all->expert)) {
        ?>
<div style="float:right;z-index:999; position:relative; top:40px;"><?php 
        if ($query->expert == 0) {
            ?>
<a class="butAction" href="?action=set-expert&id=<?php 
            echo $query->getId();
            ?>
"><?php 
            echo $langs->trans('setExpertMode');
            ?>
</a><?php 
        } else {
            if ($query->expert == 2) {
                ?>
<a class="butAction" href="?action=set-expert&id=<?php 
                echo $query->getId();
                ?>
"><?php 
                echo $langs->trans('setExpertMode');
                ?>
</a><?php 
                ?>
<br /><br /><a class="butAction" href="?action=unset-expert&id=<?php 
                echo $query->getId();
                ?>
"><?php 
                echo $langs->trans('unsetExpertMode');
                ?>
</a><?php 
            } else {
                ?>
<a class="butAction" href="?action=set-free&id=<?php 
                echo $query->getId();
                ?>
"><?php 
                echo $langs->trans('setExpertFreeMode');
                ?>
</a><?php 
                ?>
<br /><br /><a class="butAction" href="?action=unset-expert&id=<?php 
                echo $query->getId();
                ?>
"><?php 
                echo $langs->trans('unsetExpertMode');
                ?>
</a><?php 
            }
        }
        ?>
<br /><br /><a class="butAction" href="?action=clone&id=<?php 
        echo $query->getId();
        ?>
"><?php 
        echo $langs->trans('cloneQuery');
        ?>
</a><?php 
        ?>
<br /><br /><a class="butAction" href="?action=export&id=<?php 
        echo $query->getId();
        ?>
"><?php 
        echo $langs->trans('ExportQuery');
        ?>
</a><?php 
        ?>
</div><?php 
    }
    ?>
		<div id="query_header" style="padding: 0 20px 20px 0; background-color: #fff;z-index:1;">
			<?php 
    echo $langs->trans('Title');
    ?>
 : 
			<input type="text" name="title" size="80" value="<?php 
    echo $query->title;
    ?>
" />
			<?php 
    $form = new TFormCore();
    if (!empty($user->rights->query->bdd->use_other_db)) {
        dol_include_once('/query/class/bddconnector.class.php');
        $PDOdb = new TPDOdb();
        $formCoreBDD = new TFormCore();
        if ($query->getId() > 0) {
            $formCoreBDD->Set_typeaff('view');
        }
        echo $formCoreBDD->combo(' - ' . $langs->trans('BDD'), 'fk_bdd', TBDDConnector::getCombo($PDOdb, true), $query->fk_bdd);
    }
    echo $form->combo('- ' . $langs->trans('Type') . ' : ', 'type', $query->TGraphiqueType, $query->type);
    echo '- ' . $langs->trans('XAxis') . ' : <select name="xaxis" initValue="' . $query->xaxis . '"></select>';
    ?>
			<input class="button" type="button" id="save_query" value="<?php 
    echo $langs->trans('SaveQuery');
    ?>
" />
		</div>
		<?php 
    if ($query->getId() > 0 && !$query->expert) {
        ?>
		<div>
			<?php 
        echo $langs->trans('AddOneOfThisTables');
        ?>
 : <select id="tables"></select>
			<input class="button" type="button" id="add_this_table" value="<?php 
        echo $langs->trans('AddThisTable');
        ?>
" />
		</div>
		
		<div id="selected_tables">
			
		</div>
		<?php 
    }
    ?>
	</div>
	<?php 
    if ($query->getId() > 0 && $query->expert != 2) {
        ?>
			<div class="selected_fields">
				<div class="border" id="fields"><div class="liste_titre"><?php 
        echo $langs->trans('FieldsOrder');
        ?>
</div></div>
			</div>
			<?php 
    }
    if ($query->getId() > 0) {
        ?>
	<div id="results" style="display:<?php 
        echo $query->expert > 0 ? 'block' : 'none';
        ?>
;">
		<div>
		<?php 
        echo $langs->trans('Fields');
        ?>
<br />
		<textarea id="sql_query_fields" name="sql_fields" <?php 
        echo $query->expert == 2 ? ' style="width:700px;height:100px;" ' : '';
        ?>
><?php 
        echo htmlentities($query->sql_fields, 0, ini_get("default_charset"));
        ?>
</textarea>
		</div>
		
		<div>
		<?php 
        echo $langs->trans('From');
        ?>
<br />
		<textarea id="sql_query_from" name="sql_from" <?php 
        echo $query->expert == 2 ? 'style="width:700px;height:100px;"' : '';
        ?>
><?php 
        echo htmlentities($query->sql_from, 0, ini_get("default_charset"));
        ?>
</textarea>
		</div>
		
		<div>
		<?php 
        echo $langs->trans('Where');
        ?>
<br />
		<textarea id="sql_query_where" name="sql_where" <?php 
        echo $query->expert == 2 ? 'style="width:700px;height:200px;"' : '';
        ?>
><?php 
        echo htmlentities($query->sql_where, 0, ini_get("default_charset"));
        ?>
</textarea>
		
		<?php 
        if ($query->expert > 0) {
            echo $langs->trans('AfterWhere');
            ?>
<br /><textarea id="sql_query_afterwhere" name="sql_afterwhere" <?php 
            echo $query->expert == 2 ? 'style="width:700px;height:100px;"' : '';
            ?>
><?php 
            echo htmlentities($query->sql_afterwhere, 0, ini_get("default_charset"));
            ?>
</textarea><?php 
        } else {
            ?>
<input type="hidden" id="sql_query_afterwhere" name="sql_afterwhere" value="" /><?php 
        }
        ?>
		
		</div>
	</div>
	
	<div style="clear:both; border-top:1px solid #000;"></div>
	<?php 
        if ($query->getId() > 0 && $query->expert != 2) {
            ?>
		<div class="selected_fields_view">
			<div class="border" id="fieldsview"><div class="liste_titre"><?php 
            echo $langs->trans('FieldsView');
            ?>
</div></div>
		</div>
		<?php 
        }
        ?>
	<div id="previewRequete" style="display: none;">
		<iframe src="#" width="100%" bgcolor="#fff" frameborder="0" onload="this.height = this.contentWindow.document.body.scrollHeight + 'px'"></iframe>
	</div>
	
	<?php 
    }
    ?>
	</form>
	
	
	
	<?php 
    dol_fiche_end();
    llxFooter();
}
Esempio n. 10
0
function _card(&$PDOdb, &$object)
{
    global $langs, $conf, $user, $db;
    if (empty($user->rights->query->bdd->use_other_db)) {
        return '';
    }
    llxHeader();
    dol_fiche_head(array(), 'bdd', 'BDD');
    $tbs = new TTemplateTBS();
    $object->connect();
    $formCore = new TFormCore('auto', 'formBDD', 'post');
    echo $formCore->hidden('action', 'save');
    echo $formCore->hidden('id', $object->getId());
    echo $tbs->render('tpl/bdd.html', array(), array('object' => array('host' => $formCore->texte('', 'host', $object->host, 30, 128), 'db_name' => $formCore->texte('', 'db_name', $object->db_name, 30, 128), 'login' => $formCore->texte('', 'login', $object->login, 30, 128), 'password' => $formCore->texte('', 'password', $object->password, 30, 128), 'port' => $formCore->texte('', 'port', $object->port, 5, 5), 'charset' => $formCore->texte('', 'charset', $object->charset, 10, 128), 'db_type' => $formCore->combo('', 'db_type', $object->TDBType, $object->db_type)), 'view' => array('langs' => $langs, 'buttons' => $formCore->btsubmit($langs->trans('Delete'), 'bt_delete', '', 'butActionDelete') . ' &nbsp; ' . $formCore->btsubmit($langs->trans('Save'), 'bt_save'))));
    $formCore->end();
    dol_fiche_end();
    llxFooter();
}
/*
 * View
 * Sélection d'un fournisseur et ajout de la mention de subrogation ainsi que du compte à mettre par défaut sur la facture au factor
 */
$page_name = "FactorSetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = factorAdminPrepareHead();
dol_fiche_head($head, 'settings', $langs->trans("Module104905Name"), 0, "factor@factor");
$form = new Form($db);
$TFactor = TFactor::getAll($PDOdb);
// Setup page goes here
$formCore = new TFormCore('auto', 'form1', 'post');
echo $formCore->hidden('action', 'save');
$var = false;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Supplier/BankAccount") . '</td>' . "\n";
print '<td>' . $langs->trans("Mention") . '</td>' . "\n";
print '<td>&nbsp;</td>' . "\n";
print '</tr>';
foreach ($TFactor as $idFactor) {
    $factor = new TFactor();
    $factor->load($PDOdb, $idFactor);
    // Example with a yes / no select
    $var = !$var;
    print '<tr ' . $bc[$var] . '>';
    ob_start();
    }
}
/*
 * View
 */
$page_name = "RoutingSetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = routingAdminPrepareHead();
dol_fiche_head($head, 'settings', $langs->trans("Module104760Name"), 0, "rememberme@rememberme");
// Setup page goes here
$form = new Form($db);
$formCore = new TFormCore('auto', 'formSave', 'post');
echo $formCore->hidden('action', 'save');
dol_include_once('/product/class/html.formproduct.class.php');
$formProduct = new FormProduct($db);
$var = false;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Trigger") . '</td>' . "\n";
print '<td>' . $langs->trans("QtyField") . '</td>' . "\n";
print '<td>' . $langs->trans("Condition") . '</td>' . "\n";
print '<td>' . $langs->trans("Warehouse") . '</td>' . "\n";
print '<td>' . $langs->trans("Action") . '</td>' . "\n";
print '</tr>';
$TRoute = TRouting::getAll($PDOdb);
foreach ($TRoute as &$r) {
    $class = $class == 'impair' ? 'pair' : 'impair';
function tabImport(&$TImport, &$expedition)
{
    global $langs, $db;
    $form = new TFormCore();
    $formDoli = new Form($db);
    $formproduct = new FormProduct($db);
    $PDOdb = new TPDOdb();
    print count($TImport) . ' équipement(s) dans votre expédition';
    ?>
	<table width="100%" class="border">
		<tr class="liste_titre">
			<td>Produit</td>
			<td>Numéro de série</td>
			<td>Numéro de Lot</td>
			<td>Quantité</td>
			<td>&nbsp;</td>
		</tr>
		
	<?php 
    $prod = new Product($db);
    $form->Set_typeaff('view');
    if (is_array($TImport)) {
        foreach ($TImport as $k => $line) {
            if ($prod->id == 0 || $line['ref'] != $prod->ref) {
                if (!empty($line['fk_product'])) {
                    $prod->fetch($line['fk_product']);
                } else {
                    $prod->fetch('', $line['ref']);
                }
            }
            $asset = new TAsset();
            $asset->loadBy($PDOdb, $line['numserie'], 'serial_number');
            $asset->load_asset_type($PDOdb);
            $assetLot = new TAssetLot();
            $assetLot->loadBy($PDOdb, $line['lot_number'], 'lot_number');
            $Trowid = TRequeteCore::get_id_from_what_you_want($PDOdb, MAIN_DB_PREFIX . "expeditiondet_asset", array('fk_asset' => $asset->rowid, 'fk_expeditiondet' => $line['fk_expeditiondet']));
            ?>
<tr>
					<td><?php 
            echo $prod->getNomUrl(1) . $form->hidden('TLine[' . $k . '][fk_product]', $prod->id) . $form->hidden('TLine[' . $k . '][ref]', $prod->ref);
            ?>
</td>
					<td><a href="<?php 
            echo dol_buildpath('/asset/fiche.php?id=' . $asset->rowid, 1);
            ?>
"><?php 
            echo $form->texte('', 'TLine[' . $k . '][numserie]', $line['numserie'], 30);
            ?>
</a></td>
					<td><a href="<?php 
            echo dol_buildpath('/asset/fiche_lot.php?id=' . $assetLot->rowid, 1);
            ?>
"><?php 
            echo $form->texte('', 'TLine[' . $k . '][lot_number]', $line['lot_number'], 30);
            ?>
</a></td>
					<td><?php 
            echo $line['quantity'] . " " . ($asset->assetType->measuring_units == 'unit' ? 'unité(s)' : measuring_units_string($line['quantity_unit'], $asset->assetType->measuring_units));
            ?>
</td>
					<td>
						<?php 
            if ($expedition->statut != 1) {
                echo '<a href="?action=DELETE_LINE&k=' . $k . '&id=' . $expedition->id . '&rowid=' . $Trowid[0] . '">' . img_delete() . '</a>';
            }
            ?>
					</td>
				</tr>
				
				<?php 
        }
    }
    ?>
			
		
	</table>
	<br>
	<?php 
}
function _liste(&$PDOdb)
{
    global $langs, $db, $user, $conf;
    llxHeader('', $langs->trans('ListOFAsset'), '', '');
    //getStandartJS();
    if (isset($_REQUEST['delete_ok'])) {
        ?>
		<br><div class="error"><?php 
        echo $langs->trans('OFAssetDeleted');
        ?>
</div><br>
		<?php 
    }
    $fk_soc = __get('fk_soc', 0, 'integer');
    $fk_product = __get('fk_product', 0, 'integer');
    $fk_commande = __get('fk_commande', 0, 'integer');
    if ($fk_product > 0) {
        dol_include_once('/core/lib/product.lib.php');
        $product = new Product($db);
        $result = $product->fetch($fk_product);
        $head = product_prepare_head($product, $user);
        $titre = $langs->trans("CardProduct" . $product->type);
        $picto = $product->type == 1 ? 'service' : 'product';
        dol_fiche_head($head, 'tabOF2', $titre, 0, $picto);
    } elseif ($fk_commande > 0) {
        dol_include_once("/core/lib/order.lib.php");
        $commande = new Commande($db);
        $result = $commande->fetch($fk_commande);
        $head = commande_prepare_head($commande, $user);
        $titre = $langs->trans("CustomerOrder" . $product->type);
        dol_fiche_head($head, 'tabOF3', $titre, 0, "order");
    }
    $form = new TFormCore();
    $assetOf = new TAssetOF();
    $r = new TSSRenderControler($assetOf);
    $sql = "SELECT ofe.rowid, ofe.numero, ofe.fk_soc, s.nom as client, SUM(ofel.qty) as nb_product_to_make\n\t\t, GROUP_CONCAT(DISTINCT ofel.fk_product SEPARATOR ',') as fk_product, p.label as product, ofe.ordre, ofe.date_lancement , ofe.date_besoin, ofe.fk_commande,ofe.fk_project\n\t\t, ofe.status, ofe.fk_user,ofe.total_estimated_cost, ofe.total_cost, '' AS printTicket\n\t\t  FROM " . MAIN_DB_PREFIX . "assetOf as ofe \n\t\t  LEFT JOIN " . MAIN_DB_PREFIX . "assetOf_line ofel ON (ofel.fk_assetOf=ofe.rowid AND ofel.type = 'TO_MAKE')\n\t\t  LEFT JOIN " . MAIN_DB_PREFIX . "product p ON (p.rowid = ofel.fk_product)\n\t\t  LEFT JOIN " . MAIN_DB_PREFIX . "societe s ON (s.rowid = ofe.fk_soc)\n\t\t  WHERE ofe.entity=" . $conf->entity;
    if ($fk_soc > 0) {
        $sql .= " AND ofe.fk_soc=" . $fk_soc;
    }
    if ($fk_product > 0) {
        $sql .= " AND ofel.fk_product=" . $fk_product;
    }
    if ($fk_commande > 0) {
        $sql .= " AND ofe.fk_commande=" . $fk_commande;
    }
    $sql .= " GROUP BY ofe.rowid ";
    // TODO je me rappelle plus pourquoi j'ai fait cette merde mais ça fait planter le tri, donc à virer.
    /*if($conf->global->ASSET_OF_LIST_BY_ROWID_DESC) $orderBy['ofe.rowid']='DESC';
    	else $orderBy['ofe.date_cre']='DESC';*/
    $TMath = array();
    $THide = array('rowid', 'fk_user', 'fk_product', 'fk_soc');
    if ($fk_commande > 0) {
        $THide[] = 'fk_commande';
    }
    if ($conf->global->OF_NB_TICKET_PER_PAGE == -1) {
        $THide[] = 'printTicket';
    }
    if (empty($user->rights->of->of->price)) {
        $THide[] = 'total_cost';
        $THide[] = 'total_estimated_cost';
    } else {
        $TMath['total_estimated_cost'] = 'sum';
        $TMath['total_cost'] = 'sum';
    }
    if (!empty($fk_product)) {
        $TMath['nb_product_to_make'] = 'sum';
    }
    $form = new TFormCore($_SERVER['PHP_SELF'], 'form', 'GET');
    echo $form->hidden('action', '');
    if ($fk_commande > 0) {
        echo $form->hidden('fk_commande', $fk_commande);
    }
    if ($fk_product > 0) {
        echo $form->hidden('fk_product', $fk_product);
    }
    // permet de garder le filtre produit quand on est sur l'onglet OF d'une fiche produit
    $r->liste($PDOdb, $sql, array('limit' => array('nbLine' => $conf->liste_limit), 'orderBy' => $orderBy, 'subQuery' => array(), 'link' => array('Utilisateur en charge' => '<a href="' . dol_buildpath('/user/card.php?id=@fk_user@', 2) . '">' . img_picto('', 'object_user.png', '', 0) . ' @val@</a>', 'numero' => '<a href="' . dol_buildpath('/of/fiche_of.php?id=@rowid@"', 2) . '>' . img_picto('', 'object_list.png', '', 0) . ' @val@</a>', 'printTicket' => '<input style=width:40px;"" type="number" value="' . (int) $conf->global->OF_NB_TICKET_PER_PAGE . '" name="printTicket[@rowid@]" min="0" />'), 'translate' => array(), 'hide' => $THide, 'type' => array('date_lancement' => 'date', 'date_besoin' => 'date', 'total_cost' => 'money', 'total_estimated_cost' => 'money', 'nb_product_to_make' => 'number'), 'math' => $TMath, 'liste' => array('titre' => $langs->trans('ListOFAsset'), 'image' => img_picto('', 'title.png', '', 0), 'picto_precedent' => img_picto('', 'back.png', '', 0), 'picto_suivant' => img_picto('', 'next.png', '', 0), 'noheader' => (int) isset($_REQUEST['fk_soc']) | (int) isset($_REQUEST['fk_product']), 'messageNothing' => "Il n'y a aucun " . $langs->trans('OFAsset') . " à afficher", 'picto_search' => img_picto('', 'search.png', '', 0)), 'title' => array('numero' => 'Numéro', 'fk_commande' => 'Commande client', 'ordre' => 'Priorité', 'date_lancement' => 'Date du lancement', 'date_besoin' => 'Date du besoin', 'status' => 'Status', 'login' => 'Utilisateur en charge', 'product' => 'Produit', 'client' => 'Client', 'nb_product_to_make' => 'Nb produits à fabriquer', 'total_cost' => 'Coût réel', 'total_estimated_cost' => 'Coût prévu', 'printTicket' => 'impression<br />étiquette', 'fk_project' => 'Projet'), 'orderBy' => array('rowid' => 'DESC'), 'eval' => array('ordre' => 'TAssetOF::ordre(@val@)', 'status' => 'TAssetOF::status(@val@)', 'product' => 'get_format_libelle_produit("@fk_product@")', 'client' => 'get_format_libelle_societe(@fk_soc@)', 'fk_commande' => 'get_format_libelle_commande(@fk_commande@)', 'fk_project' => 'get_format_libelle_projet(@fk_project@)'), 'search' => array('numero' => array('recherche' => true, 'table' => 'ofe'), 'date_lancement' => array('recherche' => 'calendars', 'table' => 'ofe'), 'date_besoin' => array('recherche' => 'calendars', 'table' => 'ofe'), 'status' => array('recherche' => TAssetOF::$TStatus, 'table' => 'ofe'))));
    if ($conf->global->OF_NB_TICKET_PER_PAGE != -1) {
        echo '<p align="right"><input class="button" type="button" onclick="$(this).closest(\'form\').find(\'input[name=action]\').val(\'printTicket\');  $(this).closest(\'form\').submit(); " name="print" value="' . $langs->trans('ofPrintTicket') . '" /></p>';
    }
    $form->end();
    // On n'affiche pas le bouton de création d'OF si on est sur la liste OF depuis l'onglet "OF" de la fiche commande
    if ($fk_commande) {
        $commande = new Commande($db);
        $commande->fetch($fk_commande);
        $r2 = new TSSRenderControler($assetOf);
        $sql = "SELECT c.rowid as fk_commandedet, p.rowid as rowid, p.ref as refProd, p.label as nomProd, c.qty as qteCommandee, c.description, c.product_type";
        $sql .= " FROM " . MAIN_DB_PREFIX . "commandedet c LEFT JOIN " . MAIN_DB_PREFIX . "product p";
        $sql .= " ON (c.fk_product = p.rowid)";
        $sql .= " WHERE c.product_type IN (0,9) AND  c.fk_commande = " . $fk_commande;
        $resql = $db->query($sql);
        //var_dump($db);
        $num = $db->num_rows($resql);
        print_barre_liste($langs->trans('ListOrderProducts'), $page, "liste.php", $param, $sortfield, $sortorder, '', $num);
        $i = 0;
        $form = new TFormCore($_SERVER['PHP_SELF'], 'formMakeOk', 'post');
        echo $form->hidden('fk_commande', __get('fk_commande', 0, 'int'));
        echo $form->hidden('action', 'createOFCommande');
        echo $form->hidden('fk_soc', $commande->socid);
        echo $form->hidden('token', $_SESSION['newtoken']);
        print '<table class="noborder" width="100%">';
        print '<tr class="liste_titre">';
        print_liste_field_titre("#");
        print_liste_field_titre($langs->trans("Ref"), "liste_of.php", "ref", "", $param, '', $sortfield, $sortorder);
        print_liste_field_titre($langs->trans("Label"), "liste_of.php", "label", "", $param, 'align="left"', $sortfield, $sortorder);
        print_liste_field_titre($langs->trans("Quantité à produire"), "liste_of.php", "", "", $param, '', $sortfield, $sortorder);
        print_liste_field_titre($langs->trans("Produits à ajouter à un OF"), "liste_of.php", "", "", $param, '', $sortfield, $sortorder);
        print "</tr>\n";
        $var = 1;
        $bc = array(1 => 'class="pair"', -1 => 'class="impair"');
        while ($prod = $db->fetch_object($resql)) {
            $var = !$var;
            //print "<tr ".$bc[$var].">";
            if ($prod->product_type == 9) {
                print "<tr>";
                print "<td>&nbsp;</td>";
                print "<td colspan=\"4\"><strong>";
                print $prod->description;
                print '</strong></td>';
            } else {
                if (empty($prod->rowid)) {
                    // ligne libre
                    print "<tr>";
                    print "<td>&nbsp;</td>";
                    print "<td colspan=\"4\">";
                    print $prod->description;
                    print '</td>';
                } else {
                    print "<tr " . $bc[$var] . ">";
                    print "<td>" . ($i + 1) . "</td>";
                    print "<td>";
                    $p_static = new Product($db);
                    $p_static->ref = $prod->refProd;
                    $p_static->id = $prod->rowid;
                    print $p_static->getNomUrl(1);
                    print "</td>\n";
                    print '<td>';
                    print $prod->nomProd;
                    print '</td>';
                    print "<td>";
                    print $form->texte('', 'TQuantites[' . $prod->fk_commandedet . ']', $prod->qteCommandee, 3, 255);
                    print "</td>";
                    print "<td>" . $form->checkbox1('', 'TProducts[' . $prod->fk_commandedet . '][' . (int) $prod->rowid . ']', false, true, '', 'checkOF');
                    print "</td>";
                    print "</tr>\n";
                    $i++;
                }
            }
        }
        print '<tr class="liste_titre">';
        echo '<th class="liste_titre" colspan="2">&nbsp;</th><th class="liste_titre">&nbsp;</th><th class="liste_titre">&nbsp;</th>
		<th class="liste_titre"><input type="checkbox" id="checkall" checked="checked" value="1"></th>
		';
        print '</tr>';
        print "</table>";
        ?>
<script type="text/javascript">
			$('input#checkall').change(function() {
				
				$('input.checkOF').prop('checked',$(this).is(':checked'));	
				
			});
			
		</script>
		
		<?php 
        echo '<p align="right">' . $form->btsubmit('Créer OFs', 'subForm') . ' ' . $form->btsubmit('Créer un seul OF', 'subFormAlone') . '</p>';
        $form->end();
        echo '</div>';
        $db->free($resql);
    } else {
        if (!empty($fk_product)) {
            $sql = "SELECT ofe.rowid, ofe.numero, ofe.fk_soc, s.nom as client, SUM(IF(ofel.qty>0,ofel.qty,ofel.qty_needed) ) as nb_product_needed, ofel.fk_product, p.label as product, ofe.ordre, ofe.date_lancement , ofe.date_besoin\n            , ofe.status, ofe.fk_user, ofe.total_cost\n              FROM " . MAIN_DB_PREFIX . "assetOf as ofe \n              LEFT JOIN " . MAIN_DB_PREFIX . "assetOf_line ofel ON (ofel.fk_assetOf=ofe.rowid AND ofel.type = 'NEEDED')\n              LEFT JOIN " . MAIN_DB_PREFIX . "product p ON p.rowid = ofel.fk_product\n              LEFT JOIN " . MAIN_DB_PREFIX . "societe s ON s.rowid = ofe.fk_soc\n              WHERE ofe.entity=" . $conf->entity . " AND ofel.fk_product=" . $fk_product . " AND ofe.status!='CLOSE'";
            $sql .= " GROUP BY ofe.rowid ";
            if ($conf->global->ASSET_OF_LIST_BY_ROWID_DESC) {
                $orderBy['ofe.rowid'] = 'DESC';
            } else {
                $orderBy['ofe.date_cre'] = 'DESC';
            }
            $TMath = array();
            $THide = array('rowid', 'fk_user', 'fk_product', 'fk_soc');
            if (empty($user->rights->asset->of->price)) {
                $THide[] = 'total_cost';
            } else {
                $TMath['total_cost'] = 'sum';
            }
            $TMath['nb_product_needed'] = 'sum';
            $l = new TListviewTBS('listeofproductneeded');
            echo $langs->trans('ofListProductNeeded');
            echo $l->render($PDOdb, $sql, array('limit' => array('nbLine' => $conf->liste_limit), 'orderBy' => $orderBy, 'subQuery' => array(), 'link' => array('Utilisateur en charge' => '<a href="' . dol_buildpath('/user/card.php?id=@fk_user@', 2) . '">' . img_picto('', 'object_user.png', '', 0) . ' @val@</a>', 'numero' => '<a href="' . dol_buildpath('/of/fiche_of.php?id=@rowid@', 2) . '">' . img_picto('', 'object_list.png', '', 0) . ' @val@</a>', 'product' => '<a href="' . dol_buildpath('/product/card.php?id=@fk_product@', 2) . '">' . img_picto('', 'object_product.png', '', 0) . ' @val@</a>', 'client' => '<a href="' . dol_buildpath('/societe/soc.php?id=@fk_soc@', 2) . '">' . img_picto('', 'object_company.png', '', 0) . ' @val@</a>'), 'translate' => array(), 'hide' => $THide, 'type' => array('date_lancement' => 'date', 'date_besoin' => 'date', 'total_cost' => 'money', 'nb_product_needed' => 'number'), 'math' => $TMath, 'liste' => array('titre' => $langs->trans('ListOFAsset'), 'image' => img_picto('', 'title.png', '', 0), 'picto_precedent' => img_picto('', 'back.png', '', 0), 'picto_suivant' => img_picto('', 'next.png', '', 0), 'noheader' => (int) isset($_REQUEST['fk_soc']) | (int) isset($_REQUEST['fk_product']), 'messa geNothing' => "Il n'y a aucun " . $langs->trans('OFAsset') . " à afficher", 'picto_search' => img_picto('', 'search.png', '', 0)), 'title' => array('numero' => 'Numéro', 'ordre' => 'Priorité', 'date_lancement' => 'Date du lancement', 'date_besoin' => 'Date du besoin', 'status' => 'Status', 'login' => 'Utilisateur en charge', 'product' => 'Produit', 'client' => 'Client', 'nb_product_needed' => 'Nb produits nécessaire', 'total_cost' => 'Coût'), 'eval' => array('ordre' => 'TAssetOF::ordre(@val@)', 'status' => 'TAssetOF::status(@val@)', 'product' => 'get_format_libelle_produit(@fk_product@)', 'client' => 'get_format_libelle_societe(@fk_soc@)')));
        }
        echo '<div class="tabsAction">';
        echo '<a id="bt_createOf" class="butAction" href="fiche_of.php?action=new' . (!empty($fk_product) ? '&fk_product=' . $fk_product : '') . '">' . $langs->trans('CreateOFAsset') . '</a>';
        if ($conf->nomenclature->enabled && !empty($fk_product)) {
            dol_include_once('/core/class/html.form.class.php');
            dol_include_once('/asset/lib/asset.lib.php');
            dol_include_once('/nomenclature/class/nomenclature.class.php');
            $doliForm = new Form($db);
            echo $doliForm->selectarray('fk_nomenclature', TNomenclature::get($PDOdb, $fk_product, true));
            echo '<script type="text/javascript">

				    var url_create_of = $("#bt_createOf").attr("href");
	                   	    $("#bt_createOf").attr("href","#");  
                        
					$("#bt_createOf").click(function() {
						var fk_nomenclature = $("select[name=fk_nomenclature]").val();
						var href = url_create_of + "&fk_nomenclature=" + fk_nomenclature;
						$(this).attr("href", href);
					});
			</script>';
        }
        echo '</div>';
    }
    $PDOdb->close();
    llxFooter('');
}
                $o->palier = $data[1] > 0 ? $data[1] : $data[2];
                $o->fdp = price2num($data[3], 5);
                $o->save($PDOdb);
            }
        }
    }
}
$page_name = "RemiseImport";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = remiseAdminPrepareHead();
dol_fiche_head($head, 'import', $langs->trans("Module104921Name"), 0, "remise@remise");
$form = new TFormCore('auto', 'formImport', 'post', true);
echo $form->hidden('action', 'import');
print_titre('Etape 1');
echo $form->fichier('Fichier à importer', 'f1', '', 50);
echo $form->btsubmit('Prévisualiser', 'bt_preview');
?>
<br /><small>(Colonnes : n° département,poids,palier,montant - séparateur : ';')</small>
<?php 
if ($etape > 1) {
    print_titre('Etape 2');
    echo $form->zonetexte('', 'data', serialize($TData), 80, 5, ' style="display:none;" ');
    ?>
	<table class="liste">
		<tr class="liste_titre">
			<td>Département</td>
			<td>Poids</td>
function fiche(&$dashboard, $action = 'edit', $withHeader = true)
{
    global $langs, $conf, $user, $db;
    $PDOdb = new TPDOdb();
    $form = new TFormCore();
    $cell_height = 200;
    $tab_object = GETPOST('tab_object');
    $table_element = GETPOST('table_element');
    $fk_object = GETPOST('fk_object');
    if (empty($table_element)) {
        if ($tab_object == 'thirdparty') {
            $table_element = 'societe';
        } else {
            if ($tab_object == 'project') {
                $table_element = 'projet';
            } else {
                $table_element = $tab_object;
            }
        }
    }
    if ($withHeader) {
        llxHeader('', 'Query DashBoard', '', '', 0, 0, array('/query/js/dashboard.js', '/query/js/jquery.gridster.min.js'), array('/query/css/dashboard.css', '/query/css/jquery.gridster.min.css'));
        $head = TQueryMenu::getHeadForObject($tab_object, $fk_object);
        dol_fiche_head($head, 'tabQuery' . GETPOST('menuId'), 'Query');
        print_fiche_titre($dashboard->title);
    } else {
        if (GETPOST('for_incusion') > 0) {
            ?>
		<div class="querydashboard">
			<link rel="stylesheet" type="text/css" title="default" href="<?php 
            echo dol_buildpath('/query/css/dashboard.css', 1);
            ?>
">
			<link rel="stylesheet" type="text/css" title="default" href="<?php 
            echo dol_buildpath('/query/css/jquery.gridster.min.css', 1);
            ?>
">
			<script type="text/javascript" src="<?php 
            echo dol_buildpath('/query/js/dashboard.js', 1);
            ?>
"></script>
			<script type="text/javascript" src="<?php 
            echo dol_buildpath('/query/js/jquery.gridster.min.js', 1);
            ?>
"></script>

		<?php 
        } else {
            ?>
<html>
			<head>
				<meta charset="UTF-8">
				<link rel="stylesheet" type="text/css" href="<?php 
            echo dol_buildpath('/theme/eldy/style.css.php?lang=fr_FR&theme=eldy', 1);
            ?>
">
				<link rel="stylesheet" type="text/css" title="default" href="<?php 
            echo dol_buildpath('/query/css/dashboard.css', 1);
            ?>
">
				<link rel="stylesheet" type="text/css" title="default" href="<?php 
            echo dol_buildpath('/query/css/jquery.gridster.min.css', 1);
            ?>
">

				<script type="text/javascript" src="<?php 
            echo dol_buildpath('/includes/jquery/js/jquery.min.js', 1);
            ?>
"></script>
				<script type="text/javascript" src="<?php 
            echo dol_buildpath('/query/js/dashboard.js', 1);
            ?>
"></script>
				<script type="text/javascript" src="<?php 
            echo dol_buildpath('/query/js/jquery.gridster.min.js', 1);
            ?>
"></script>
				<style type="text/css">
					.pagination { display : none; }
					<?php 
            if ((int) GETPOST('allow_gen') != 1) {
                echo '.notInGeneration { display : none; }';
            }
            ?>

					table.liste tr.impair,table.liste tr.pair,table.liste tr.liste_titre,div.titre {
						font-size: 12px;
					}
				</style>
			</head>
		<body >
		<?php 
        }
    }
    ?>
	<script type="text/javascript">
		var MODQUERY_INTERFACE = "<?php 
    echo dol_buildpath('/query/script/interface.php', 1);
    ?>
";
		
		$(document).ready(function(){ //DOM Ready
			
			gridster_width = Math.round($('.gridster').innerWidth() / 5);
			if(gridster_width<50) gridster_width = 240;
			
		    $(".gridster ul").gridster({
		        widget_margins: [10, 10]
		        ,widget_base_dimensions: [gridster_width, <?php 
    echo $cell_height;
    ?>
]
		        ,min_cols:3
		        ,min_rows:5
		        ,serialize_params: function($w, wgd) { 
		        	return { posx: wgd.col, posy: wgd.row, width: wgd.size_x, height: wgd.size_y, k : $w.attr('data-k') } 
		        }
		        <?php 
    if ($action == 'edit') {
        ?>
,resize: {
		            enabled: true
		            ,max_size: [4, 4]
		            ,min_size: [1, 1]
		        }
		        
		       
		       <?php 
    }
    ?>
		    })<?php 
    if ($action == 'view') {
        echo '.data(\'gridster\').disable()';
    }
    ?>
;
		
			var gridster = $(".gridster ul").gridster().data('gridster');
		
			$('#addQuery').click(function() {
				
				var fk_query = $('select[name=fk_query]').val();
				
				$.ajax({
					url: MODQUERY_INTERFACE
					,data: {
						put:'dashboard-query'
						,fk_query : fk_query
						,fk_qdashboard:<?php 
    echo $dashboard->getId();
    ?>
					}
					,dataType:'json'
					
				}).done(function(data) {
					
					var title = $('select[name=fk_query] option:selected').text();
					
					gridster.add_widget('<li data-k="'+data+'">'+title+'</li>',1,1,1,1);	
				});
				
			});
			
			$('#saveDashboard').click(function() {
				
				var $button = $(this);
				
				$button.hide();
				
				$.ajax({
					url: MODQUERY_INTERFACE
					,data: {
						put:'dashboard'
						,id:<?php 
    echo $dashboard->getId();
    ?>
						,title:$('input[name=title]').val()
						,fk_usergroup:$('select[name=fk_usergroup]').val()
						,send_by_mail:$('select[name=send_by_mail]').val()
						,hook:$('select[name=hook]').val()
						,use_as_landing_page:$('select[name=use_as_landing_page]').val()
						,refresh_dashboard:$('input[name=refresh_dashboard]').val()
					}
					
				}).done(function(data) {
				   <?php 
    if ($dashboard->getId() > 0) {
        ?>
$.ajax({
							url: MODQUERY_INTERFACE
							,data: {
								put:'dashboard-query-link'
								,TCoord:gridster.serialize( )
								,fk_qdashboard:<?php 
        echo $dashboard->getId();
        ?>
							}
							,dataType:'json'
							
					  }).done(function(data) {
					  	$button.show();
					  });
						
						<?php 
    } else {
        echo 'document.location.href="?action=view&id="+data;';
    }
    ?>
					  	
		              
				});
				
			});
		
		});
		
		function delTile(idTile) {
			$('li[tile-id='+idTile+']').css('opacity',.5);
			
			$.ajax({
				url: MODQUERY_INTERFACE
				,data: {
					put:'dashboard-query-remove'
					,id : idTile
				}
				,dataType:'json'
				
			}).done(function(data) {
				$('li[tile-id='+idTile+']').toggle();
				//document.location.hre
			});
			
		}
			
	</script>
	<?php 
    if ($action == 'edit') {
        ?>
<div><?php 
        $TQuery = TQuery::getQueries($PDOdb);
        echo $form->texte($langs->trans('Title'), 'title', $dashboard->title, 50, 255);
        $formDoli = new Form($db);
        echo ' - ' . $langs->trans('LimitAccessToThisGroup') . ' : ' . $formDoli->select_dolgroups($dashboard->fk_usergroup, 'fk_usergroup', 1) . '/' . $langs->trans('UseAsLandingPage') . $formDoli->selectarray('use_as_landing_page', array($langs->trans('No'), $langs->trans('Yes')), $dashboard->use_as_landing_page);
        echo $form->combo(' - ' . $langs->trans('SendByMailToThisGroup'), 'send_by_mail', $dashboard->TSendByMail, $dashboard->send_by_mail);
        echo $form->combo(' - ' . $langs->trans('ShowThisInCard'), 'hook', $dashboard->THook, $dashboard->hook);
        echo $form->number('<br />' . $langs->trans('RefreshDashboard'), 'refresh_dashboard', $dashboard->refresh_dashboard, 20, 1, 0);
        ?>
			<a href="#" class="butAction" id="saveDashboard"><?php 
        echo $langs->trans('SaveDashboard');
        ?>
</a>
		</div>
		<?php 
        if ($dashboard->getId() > 0) {
            ?>
		<div>
			<?php 
            $TQuery = TQuery::getQueries($PDOdb);
            echo $form->combo('', 'fk_query', $TQuery, 0);
            ?>
			<a href="#" class="butAction" id="addQuery"><?php 
            echo $langs->trans('AddThisQuery');
            ?>
</a>
		</div>
		
		<?php 
        }
    } else {
        if (!empty($conf->global->QUERY_SHOW_PDF_TRANSFORM)) {
            echo '<div style="text-align:right" class="notInGeneration"><a class="butAction" style=";z-index:999;" href="download-dashboard.php?uid=' . $dashboard->uid . '">' . $langs->trans('Download') . '</a></div>';
        }
    }
    ?>
		
	
	<div class="gridster">
	    <ul>
	    	<?php 
    foreach ($dashboard->TQDashBoardQuery as $k => &$cell) {
        echo '<li tile-id="' . $cell->getId() . '" data-k="' . $k . '" data-row="' . $cell->posy . '" data-col="' . $cell->posx . '" data-sizex="' . $cell->width . '" data-sizey="' . $cell->height . '" ' . ($withHeader ? '' : 'style="overflow:hidden;"') . '>';
        if ($action == 'edit') {
            echo '<a style="position:absolute; top:3px; right:3px; z-index:999;" href="javascript:delTile(' . $cell->getId() . ')">' . img_delete('DeleteThisTile') . '</a>';
        } else {
            echo '<a style="position:absolute; top:3px; right:3px; z-index:999;" href="' . dol_buildpath('/query/query.php?action=run-in&id=' . $cell->query->getId(), 1) . '">' . img_picto($langs->trans('Run'), 'object_cron.png') . '</a>';
        }
        if ($cell->query->type == 'LIST') {
            $cell->query->type = 'SIMPLELIST';
        }
        if (!empty($cell->query)) {
            if (!$withHeader) {
                echo $cell->query->run(false, $cell->height * $cell_height, $table_element, $fk_object, 0);
            } else {
                echo $cell->query->run(false, $cell->height * $cell_height, $table_element, $fk_object);
            }
        }
        echo '</li>';
    }
    ?>
	        
	
	    </ul>
	</div>
	
	<div style="clear:both"></div>

	<?php 
    if ($dashboard->refresh_dashboard > 0 && !$withHeader) {
        echo "<script type=\"text/javascript\">\n";
        echo "   // Automatically refresh\n";
        echo "   setInterval(\"window.location.reload()\"," . 60000 * $dashboard->refresh_dashboard . ");\n";
        echo "</script>\n";
    }
    ?>
	
	<?php 
    if ($withHeader) {
        if ($dashboard->getId() > 0) {
            print dol_buildpath('/query/dashboard.php?action=run&uid=' . $dashboard->uid, 2);
        }
        dol_fiche_end();
        llxFooter();
    } else {
        if (GETPOST('for_incusion') > 0) {
            ?>
</div><?php 
        } else {
            ?>
		</body></html>
		<?php 
        }
    }
}
print '</form>';
print '</td></tr>';
$var = !$var;
print '<tr ' . $bc[$var] . '>';
print '<td>' . $langs->trans("set_ABRICOT_CONVERTPDF_CMD") . '</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="300" style="white-space:nowrap;">';
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="set_ABRICOT_CONVERTPDF_CMD">';
$formCore = new TFormCore();
print $formCore->texte('', 'ABRICOT_CONVERTPDF_CMD', empty($conf->global->ABRICOT_CONVERTPDF_CMD) ? '' : $conf->global->ABRICOT_CONVERTPDF_CMD, 80, 255, ' placeholder="libreoffice --invisible --norestore --headless --convert-to pdf --outdir " ');
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
print '</form>';
print '</td></tr>';
$var = !$var;
print '<tr ' . $bc[$var] . '>';
print '<td>' . $langs->trans("set_ABRICOT_NB_MAX_RESULT_SQL") . '</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="300" style="white-space:nowrap;">';
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="set_ABRICOT_NB_MAX_RESULT_SQL">';
$formCore = new TFormCore();
print $formCore->texte('', 'ABRICOT_NB_MAX_RESULT_SQL', empty($conf->global->ABRICOT_NB_MAX_RESULT_SQL) ? 2000 : $conf->global->ABRICOT_NB_MAX_RESULT_SQL, 10, 50);
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
print '</form>';
print '</td></tr>';
print '</table>';
llxFooter();
$db->close();
    }
}
/*
 * View
 */
$page_name = "importdevisSetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = importdevisAdminPrepareHead();
dol_fiche_head($head, 'settings', $langs->trans("Module104740Name"), 0, "importdevis@importdevis");
// Setup page goes here
$form = new Form($db);
$formabricot = new TFormCore();
$var = false;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Parameters") . '</td>' . "\n";
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="100">' . $langs->trans("Value") . '</td>' . "\n";
$TFormat = array('SMARTBOM' => 'SMARTBOM');
$TOtherFormat = explode(',', $conf->global->IMPORTPROPAL_OTHERFORMAT);
if (count($TOtherFormat) > 0) {
    foreach ($TOtherFormat as $format) {
        if (empty($format)) {
            continue;
        }
        $TFormat[$format] = $format;
    }
function _card(&$PDOdb, &$object)
{
    global $langs, $conf, $user, $db;
    llxHeader();
    dol_fiche_head(array(), 'menu', 'Menu');
    $formCore = new TFormCore('auto', 'formMenu', 'post');
    echo $formCore->hidden('action', 'save');
    echo $formCore->hidden('id', $object->getId());
    $TQuery = array('0' => '----') + TQuery::getQueries($PDOdb);
    $TDashBoard = array('0' => '----') + TQDashBoard::getDashboard($PDOdb, '', 0, true);
    $tbs = new TTemplateTBS();
    echo $tbs->render('tpl/menu.html', array(), array('menu' => array('type_menu' => $formCore->combo('', 'type_menu', $object->TTypeMenu, $object->type_menu), 'tab_object' => $formCore->combo('', 'tab_object', $object->TTabObject, $object->tab_object), 'mainmenu' => $formCore->combo('', 'mainmenu', TQueryMenu::getMenu($PDOdb, 'main'), $object->mainmenu), 'leftmenu' => $formCore->combo('', 'leftmenu', TQueryMenu::getMenu($PDOdb, 'left'), $object->leftmenu), 'fk_query' => $formCore->combo('', 'fk_query', $TQuery, $object->fk_query), 'fk_dashboard' => $formCore->combo('', 'fk_dashboard', $TDashBoard, $object->fk_dashboard), 'title' => $formCore->texte('', 'title', $object->title, 80, 255), 'perms' => $formCore->texte('', 'perms', $object->perms, 80, 255)), 'view' => array('langs' => $langs, 'buttons' => $formCore->btsubmit($langs->trans('Delete'), 'bt_delete', '', 'butActionDelete') . ' &nbsp; ' . $formCore->btsubmit($langs->trans('Save'), 'bt_save'))));
    $formCore->end();
    dol_fiche_end();
    llxFooter();
}
function fiche(&$commande, &$TImport)
{
    global $langs, $db, $conf;
    llxHeader();
    $head = ordersupplier_prepare_head($commande);
    $title = $langs->trans("SupplierOrder");
    dol_fiche_head($head, 'recepasset', $title, 0, 'order');
    entetecmd($commande);
    $form = new TFormCore('auto', 'formrecept', 'post', true);
    echo $form->hidden('action', 'SAVE');
    echo $form->hidden('id', $commande->id);
    if ($commande->statut < 5 && $conf->global->DISPATCH_USE_IMPORT_FILE) {
        echo $form->fichier('Fichier à importer', 'file1', '', 80);
        echo $form->btsubmit('Envoyer', 'btsend');
    }
    tabImport($TImport, $commande);
    $form->end();
    _list_already_dispatched($commande);
    llxFooter();
}
function liste($type)
{
    global $conf, $langs;
    $page_name = "RemiseSetup";
    llxHeader('', $langs->trans($page_name));
    $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
    print_fiche_titre($langs->trans($page_name), $linkback);
    // Configuration header
    $head = remiseAdminPrepareHead();
    dol_fiche_head($head, $type, $page_name, 0, "remise@remise");
    $l = new TListviewTBS('lPrice');
    $sql = "SELECT rowid as Id, palier,remise,zip,fk_shipment_mode,date_maj FROM " . MAIN_DB_PREFIX . "remise \n\t\t\tWHERE type=:type";
    $PDOdb = new TPDOdb();
    $form = new TFormCore('auto', 'form1', 'get');
    echo $form->hidden('type', $type);
    echo $l->render($PDOdb, $sql, array('link' => array('Id' => '<a href="' . dol_buildpath('/remise/admin/remise.php?action=edit&id=@val@&type=' . $type, 1) . '">@val@</a>'), 'type' => array('remise' => 'money', 'palier' => 'number', 'date_maj' => 'date'), 'title' => array('palier' => $langs->trans('Palier'), 'zip' => $langs->trans('Zip'), 'fk_shipment_mode' => $langs->trans('ShipmentMode'), 'remise' => $langs->trans('Remise'), 'date_maj' => $langs->trans('Update')), 'eval' => array('fk_shipment_mode' => 'showShipmentMode(@val@)'), 'search' => array('palier' => true, 'zip' => true, 'remise' => true)), array(':type' => $type));
    $form->end();
    echo '<div class="tabsAction">';
    echo $form->bt($langs->trans('New'), 'bt_new', ' onclick="document.location.href=\'?type=' . $type . '&action=new\' "');
    echo '</div>';
    dol_fiche_end();
    llxFooter();
}
 private function setSearch(&$TEntete, &$TParam)
 {
     global $langs;
     if (empty($TParam['search'])) {
         return array();
     }
     $TSearch = array();
     $form = new TFormCore();
     $nb_search_in_bar = 0;
     if (!empty($TParam['search'])) {
         foreach ($TEntete as $key => $libelle) {
             // init
             if (empty($TSearch[$key])) {
                 $TSearch[$key] = '';
             }
         }
     }
     foreach ($TParam['search'] as $key => $param_search) {
         $value = isset($_REQUEST['TListTBS'][$this->id]['search'][$key]) ? $_REQUEST['TListTBS'][$this->id]['search'][$key] : '';
         $typeRecherche = is_array($param_search) && isset($param_search['recherche']) ? $param_search['recherche'] : $param_search;
         if (is_array($typeRecherche)) {
             $typeRecherche = array('' => ' ') + $typeRecherche;
             $fsearch = $form->combo('', 'TListTBS[' . $this->id . '][search][' . $key . ']', $typeRecherche, $value);
         } else {
             if ($typeRecherche === 'calendar') {
                 $fsearch = $form->calendrier('', 'TListTBS[' . $this->id . '][search][' . $key . ']', $value, 10, 10);
             } else {
                 if ($typeRecherche === 'calendars') {
                     $fsearch = $form->calendrier('', 'TListTBS[' . $this->id . '][search][' . $key . '][deb]', isset($value['deb']) ? $value['deb'] : '', 10, 10) . ' ' . $form->calendrier('', 'TListTBS[' . $this->id . '][search][' . $key . '][fin]', isset($value['fin']) ? $value['fin'] : '', 10, 10);
                 } else {
                     if (is_string($typeRecherche)) {
                         $fsearch = $TParam['search'][$key];
                     } else {
                         $fsearch = $form->texte('', 'TListTBS[' . $this->id . '][search][' . $key . ']', $value, 15, 255);
                     }
                 }
             }
         }
         if (!empty($TEntete[$key]) || $TParam['type'] == 'chart') {
             $TSearch[$key] = $fsearch;
             $nb_search_in_bar++;
         } else {
             $libelle = !empty($TParam['title'][$key]) ? $TParam['title'][$key] : $key;
             $TParam['liste']['head_search'] .= '<div>' . $libelle . ' ' . $fsearch . '</div>';
         }
     }
     $search_button = ' <a href="#" onclick="TListTBS_submitSearch(this);" class="list-search-link">' . $TParam['liste']['picto_search'] . '</a>';
     if (!empty($TParam['liste']['head_search'])) {
         $TParam['liste']['head_search'] .= '<div align="right">' . $langs->trans('Search') . ' ' . $search_button . '</div>';
     }
     if ($nb_search_in_bar > 0) {
         end($TSearch);
         list($key, $v) = each($TSearch);
         $TSearch[$key] .= $search_button;
     } else {
         $TSearch = array();
     }
     return $TSearch;
 }
function _fiche_control(&$PDOdb, &$assetOf)
{
    global $langs, $db, $conf;
    llxHeader('', $langs->trans('OFAsset'), '', '');
    print dol_get_fiche_head(ofPrepareHead($assetOf, 'assetOF'), 'controle', $langs->trans('OFAsset'));
    /******/
    $TBS = new TTemplateTBS();
    $TBS->TBS->protect = false;
    $TBS->TBS->noerr = true;
    $form = new TFormCore($_SERVER['PHP_SELF'], 'form', 'POST');
    $form->Set_typeaff('view');
    $TControl = _fiche_ligne_control($PDOdb, $assetOf->getId());
    $TAssetOFControl = _fiche_ligne_control($PDOdb, $assetOf->getId(), $assetOf);
    print $TBS->render('tpl/fiche_of_control.tpl.php', array('TControl' => $TControl, 'TAssetOFControl' => $TAssetOFControl), array('assetOf' => array('id' => (int) $assetOf->getId()), 'view' => array('nbTControl' => count($TControl), 'nbTAssetOFControl' => count($TAssetOFControl), 'url' => DOL_URL_ROOT . '/custom/of/fiche_of.php')));
    $form->end();
    /******/
    llxFooter('$Date: 2011/07/31 22:21:57 $ - $Revision: 1.19 $');
}
    if (!isset($TData[$row->fk_soc])) {
        $TData[$row->fk_soc] = _init_line();
    }
    $TData[$row->fk_soc][$TMonth[(int) $row->month]] = (double) $row->total;
    $TData[$row->fk_soc]['total'] += (double) $row->total;
}
_get_company_object($TData);
//usort($TData, '_sort_company');
?>
	<style type="text/css">
		*[field=total],tr.liste_total td {
			font-weight: bold;
		}
	</style>
	<?php 
$formCore = new TFormCore('auto', 'form2', 'get');
$headsearch = $formCore->hidden('mode', $mode);
$headsearch .= $formCore->combo($langs->trans('Year'), 'year', $TYear, $year);
$headsearch .= $formCore->btsubmit($langs->trans('Ok'), 'bt_ok');
$listeview = new TListviewTBS('CAClientMonth');
print $listeview->renderArray($PDOdb, $TData, array('liste' => array('titre' => $langs->transnoentitiesnoconv('CAClientMonth'), 'head_search' => $headsearch), 'type' => $ColFormat, 'title' => array('client' => $langs->transnoentitiesnoconv('Company'), 'total' => $langs->transnoentitiesnoconv('Total'), 'year' => $langs->transnoentitiesnoconv('Year')), 'math' => $ColTotal, 'export' => array('CSV')));
$formCore->end();
dol_fiche_end();
llxFooter();
function _sort_company(&$a, &$b)
{
    $r = strcasecmp($a->name, $b->name);
    return empty($r) ? 0 : $r / abs($r);
}
function _get_company_object(&$TRender)
{
function _fiche(&$PDOdb, &$dolidacticiel, $action)
{
    global $langs, $db, $user;
    /*
     * View
     */
    $page_name = "dolidacticielSetup";
    llxHeader('', $langs->trans($page_name));
    // Subheader
    $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
    print_fiche_titre($langs->trans($page_name), $linkback);
    // Configuration header
    $head = dolidacticielAdminPrepareHead();
    dol_fiche_head($head, 'create', $langs->trans("Module104640Name"), 0, "dolidacticiel@dolidacticiel");
    $form = new TFormCore($_SERVER['PHP_SELF'], 'formDolidacticiel', 'POST');
    $form->Set_typeaff($action);
    $TBS = new TTemplateTBS();
    $tpl_fiche = "dolidacticiel_admin.tpl.php";
    print $TBS->render('../tpl/' . $tpl_fiche, array(), array('test' => array('id' => $dolidacticiel->getId(), 'rowid' => $form->hidden('rowid', $dolidacticiel->getId()), 'mainmenu' => $form->texte('', 'mainmenu', $dolidacticiel->mainmenu, 50), 'action' => $form->texte('', 'mainmenu', $dolidacticiel->action, 50), 'code' => $form->texte('', 'mainmenu', $dolidacticiel->code, 50), 'prev_code' => $form->texte('', 'mainmenu', $dolidacticiel->prev_code, 50), 'module_name' => $form->texte('', 'mainmenu', $dolidacticiel->module_name, 50), 'cond' => $form->texte('', 'mainmenu', $dolidacticiel->cond, 50), 'title' => $form->texte('', 'mainmenu', $dolidacticiel->title, 50), 'description' => $form->texte('', 'mainmenu', $dolidacticiel->description, 50), 'rights' => $form->texte('', 'mainmenu', $dolidacticiel->rights, 50), 'mainmenutips' => $form->texte('', 'mainmenu', $dolidacticiel->mainmenutips, 50), 'tips' => $form->texte('', 'mainmenu', $dolidacticiel->tips, 50)), 'view' => array('mode' => $action)));
    $form->end();
}
$var = !$var;
print '<tr ' . $bc[$var] . '>';
print '<td>' . $langs->trans("DISPATCH_HIDE_DLUO_PDF") . '</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="300">';
print ajax_constantonoff('DISPATCH_HIDE_DLUO_PDF');
print '</td></tr>';
$form = new TFormCore();
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Réception commande fournisseur") . '</td>' . "\n";
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="100">' . $langs->trans("Value") . '</td>' . "\n";
print '<tr>';
// Champ supplémentaire contenant le code comptable produit pour les ventes CEE
$var = !$var;
$form = new TFormCore($_SERVER["PHP_SELF"], 'const_dluo_by_default');
print $form->hidden('action', 'setconst');
print $form->hidden('const', 'DISPATCH_DLUO_BY_DEFAULT');
print '<tr ' . $bc[$var] . '><td>';
print $langs->trans("DispatchDLUOByDefault");
print '</td><td align="right">';
print $form->texte('', 'DISPATCH_DLUO_BY_DEFAULT', $conf->global->DISPATCH_DLUO_BY_DEFAULT, 30, 255);
print '</td><td align="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" />';
print "</td></tr>\n";
$form->end();
$var = !$var;
print '<tr ' . $bc[$var] . '>';
print '<td>' . $langs->trans("DISPATCH_UPDATE_ORDER_PRICE_ON_RECEPTION") . '</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="300">';
function _fiche(&$PDOdb, &$dispatch)
{
    global $db, $conf, $langs;
    llxHeader();
    $form = new TFormCore('auto', 'asset', 'post');
    echo $form->hidden('action', 'save');
    echo $form->hidden('id', $dispatch->fk_object);
    echo $form->hidden('type_object', $dispatch->type_object);
    $object = _header($dispatch->fk_object, $dispatch->type_object);
    $pListe[0] = "Sélectionnez une ligne";
    foreach ($object->lines as $k => &$line) {
        $label = !empty($line->label) ? $line->label : $line->libelle;
        if (empty($label) && !empty($line->desc)) {
            $label = $line->desc;
        }
        $pListe[$line->id] = $k + 1 . '/ ' . $label;
    }
    print count($dispatch->TDispatchAsset) . ' équipement(s) lié(s)<br />';
    ?>
	<table width="100%" class="border">
		<tr class="liste_titre">
			<?php 
    if (GETPOST('type_object') !== 'ticketsup') {
        print '<td>Ligne concernée</td>';
    }
    ?>
			<td>Equipement</td>
			<?php 
    if (!empty($conf->global->USE_LOT_IN_OF)) {
        ?>
<td>Numéro de Lot</td><?php 
    }
    print '<td>DLUO</td>';
    ?>
			<?php 
    if ($conf->global->clinomadic->enabled) {
        ?>
				<td>IMEI</td>
				<td>Firmware</td>
				<?php 
    }
    ?>
			<td>&nbsp;</td>
		</tr>
		
	<?php 
    foreach ($dispatch->TDispatchAsset as $k => &$da) {
        if ($da->to_delete) {
            continue;
        }
        $class = $class == 'pair' ? 'impair' : 'pair';
        ?>
<tr class="<?php 
        echo $class;
        ?>
">
			<?php 
        if (GETPOST('type_object') !== 'ticketsup') {
            echo '<td>' . $pListe[$da->fk_object] . '</td>';
        }
        ?>
			<td><?php 
        echo $da->asset->getNomUrl(1, 0, 1);
        ?>
</td>
			<td><?php 
        echo $da->asset->lot_number;
        ?>
</td>
			<?php 
        if (!empty($conf->global->USE_LOT_IN_OF)) {
            ?>
<td><?php 
            echo $da->asset->dluo ? dol_print_date($da->asset->dluo) : 'N/A';
            ?>
</td><?php 
        }
        ?>
			
			
			
			<?php 
        if ($conf->global->clinomadic->enabled) {
            ?>
				<td>IMEI</td>
				<td>Firmware</td>
				<?php 
        }
        ?>
			<td><?php 
        if ($object->statut == 0 || $type_object == 'contrat') {
            echo '<a href="?action=delete-line&k=' . $k . '&id=' . $object->id . '&type_object=' . $dispatch->type_object . '">' . img_delete() . '</a>';
        }
        ?>
</td>
		</tr>
		
		<?php 
    }
    $formproduct = new FormProduct($db);
    if ($object->statut == 0 || $type_object == 'contrat') {
        ?>
<tr style="background-color: lightblue;">
			<?php 
        if (GETPOST('type_object') !== 'ticketsup') {
            echo '<td>' . $form->combo('', 'TLine[-1][fk_object]', $pListe, '') . '</td>';
        }
        ?>
			<td><?php 
        echo $form->texte('', 'TLine[-1][serial_number]', '', 30);
        ?>
</td>
			<?php 
        if (!empty($conf->global->USE_LOT_IN_OF)) {
            ?>
<td>&nbsp;</td><?php 
        }
        ?>
			<td>&nbsp;</td>
			<?php 
        if ($conf->global->clinomadic->enabled) {
            ?>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<?php 
        }
        ?>
			<td>Nouveau
			</td>
	</tr><?php 
    }
    ?>
	</table>
	<script type="text/javascript">
		$(document).ready(function() {
			    $( "input[name='TLine[-1][serial_number]']" ).autocomplete({
			      source: "<?php 
    echo dol_buildpath('/dispatch/script/interface.php', 1);
    ?>
?get=serial_number",
			      minLength: 1,
			      select: function( event, ui ) {
			        
			      }
			    });
		});
		
			
		</script>
	<?php 
    echo $form->btsubmit($langs->trans('Save'), 'bt_new');
    dol_fiche_end();
    $form->end();
    llxFooter();
}
 function run($show_details = true, $height = 0, $table_element = '', $objectid = 0, $preview = -1, $force_list_mode = false)
 {
     global $conf;
     $PDOdb =& $this->pdodb;
     $this->show_details = $show_details;
     if ($preview !== -1) {
         $this->preview = $preview;
     }
     if (empty($this->nb_result_max)) {
         $this->nb_result_max = empty($conf->global->ABRICOT_NB_MAX_RESULT_SQL) ? 2000 : $conf->global->ABRICOT_NB_MAX_RESULT_SQL;
     }
     if ($this->preview) {
         $this->nb_result_max = 10;
     }
     if (!empty($height)) {
         $this->height = $height;
     }
     if ($force_list_mode) {
         $list = load_fiche_titre($this->title) . $this->runList($PDOdb, '', $table_element, $objectid);
     } else {
         if ($this->type == 'CHART') {
             $list = $this->runChart($PDOdb, 'ColumnChart', $table_element, $objectid);
         } else {
             if ($this->type == 'LINE') {
                 $list = $this->runChart($PDOdb, 'LineChart', $table_element, $objectid);
             } else {
                 if ($this->type == 'PIE') {
                     $list = $this->runChart($PDOdb, 'PieChart', $table_element, $objectid);
                 } else {
                     if ($this->type == 'AREA') {
                         $list = $this->runChart($PDOdb, 'AreaChart', $table_element, $objectid);
                     } else {
                         if ($this->type == 'RAW') {
                             return $this->runRAW($PDOdb, $table_element, $objectid);
                         } else {
                             if ($this->type == 'SIMPLELIST' || $this->preview) {
                                 $list = load_fiche_titre($this->title) . $this->runList($PDOdb, dol_buildpath('/query/tpl/html.simplelist.tbs.html'), $table_element, $objectid);
                             } else {
                                 $list = load_fiche_titre($this->title) . $this->runList($PDOdb, '', $table_element, $objectid);
                             }
                         }
                     }
                 }
             }
         }
     }
     $form = new TFormCore();
     $html .= $form->begin_form('auto', 'formQuery' . $this->getId(), 'get');
     $action = GETPOST('action') != '' ? GETPOST('action') : 'run';
     $html .= $form->hidden('action', $action);
     $html .= $form->hidden('id', GETPOST('id') ? GETPOST('id') : $this->getId());
     $html .= $list;
     $html .= $form->end();
     return $html;
 }
function _fiche(&$ATMdb, &$control, $mode = 'view', $editValue = false)
{
    global $db, $langs;
    llxHeader('', $langs->trans('AssetAddControl'), '', '');
    $TBS = new TTemplateTBS();
    $form = new TFormCore();
    $form->Set_typeaff($mode);
    $TForm = array('id' => $control->getId(), 'libelle' => $form->texte('', 'libelle', $control->libelle, 50, 255), 'type' => $form->combo('', 'type', TAssetControl::$TType, $control->type), 'question' => $form->texte('', 'question', $control->question, 120, 255));
    $TFormVal = _fiche_value($ATMdb, $editValue);
    $TVal = _liste_valeur($ATMdb, $control->getId(), $control->type);
    print $TBS->render('./tpl/control.tpl.php', array('TVal' => $TVal), array('co' => $TForm, 'FormVal' => $TFormVal, 'view' => array('mode' => $mode, 'editValue' => $editValue, 'type' => $control->type, 'url' => dol_buildpath('/of/control.php', 1))));
    llxFooter();
}