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') . '   ' . $formCore->btsubmit($langs->trans('Save'), 'bt_save'))));
    $formCore->end();
    dol_fiche_end();
    llxFooter();
}
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') . '   ' . $formCore->btsubmit($langs->trans('Save'), 'bt_save'))));
    $formCore->end();
    dol_fiche_end();
    llxFooter();
}
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();
}
function _printTicket(&$PDOdb)
{
    global $db, $conf, $langs;
    $dirName = 'OF_TICKET(' . date("Y_m_d") . ')';
    $dir = DOL_DATA_ROOT . '/of/' . $dirName . '/';
    $fileName = date('YmdHis') . '_ETIQUETTE';
    $TPrintTicket = GETPOST('printTicket', 'array');
    $TInfoEtiquette = _genInfoEtiquette($db, $PDOdb, $TPrintTicket);
    //var_dump($TInfoEtiquette);exit;
    @mkdir($dir, 0777, true);
    if (defined('TEMPLATE_OF_ETIQUETTE')) {
        $template = TEMPLATE_OF_ETIQUETTE;
    } else {
        if ($conf->global->DEFAULT_ETIQUETTES == 2) {
            $template = "etiquette_custom.html";
        } else {
            $template = "etiquette.html";
        }
    }
    $TBS = new TTemplateTBS();
    $file_path = $TBS->render(dol_buildpath('/of/exempleTemplate/' . $template), array('TInfoEtiquette' => $TInfoEtiquette), array('date' => date("d/m/Y"), 'margin_top' => intval($conf->global->DEFINE_MARGIN_TOP), 'margin_left_impair' => intval($conf->global->DEFINE_MARGIN_LEFT), 'width' => intval($conf->global->DEFINE_WIDTH_DIV), 'height' => intval($conf->global->DEFINE_HEIGHT_DIV), 'margin_right_pair' => intval($conf->global->DEFINE_MARGIN_RIGHT), 'margin_top_cell' => intval($conf->global->DEFINE_MARGIN_TOP_CELL)), array(), array('outFile' => $dir . $fileName . ".html", 'convertToPDF' => true));
    header("Location: " . dol_buildpath("/document.php?modulepart=of&entity=1&file=" . $dirName . "/" . $fileName . ".pdf", 1));
    exit;
}
    $TPDOdb = new TPDOdb();
    //création des div pleines
    foreach ($expedition->lines as $ligne) {
        $TPDOdb->Execute("SELECT rowid FROM " . MAIN_DB_PREFIX . "expeditiondet_asset WHERE fk_expeditiondet = " . $ligne->rowid);
        $TidExepeditiondetAsset = array();
        while ($TPDOdb->Get_line()) {
            $TidExepeditiondetAsset[] = $TPDOdb->Get_field('rowid');
        }
        foreach ($TidExepeditiondetAsset as $idExpeditiondetAsset) {
            $sql = "SELECT p.ref, p.label as nom, p.note as descritpion, eda.tare as tare, a.serial_number as code, a.lot_number as lot, eda.weight_reel as poids, eda.weight_reel_unit as poids_unit, eda.tare_unit as tare_unit\n\t\t\t\t\tFROM " . MAIN_DB_PREFIX . "expeditiondet_asset as eda\n\t\t\t\t\t\tLEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON (a.rowid = eda.fk_asset)\n\t\t\t\t\t\tLEFT JOIN " . MAIN_DB_PREFIX . "product as p ON (p.rowid = a.fk_product)\n\t\t\t\t\tWHERE eda.rowid = " . $idExpeditiondetAsset;
            $TPDOdb->Execute($sql);
            $TPDOdb->Get_line();
            $tare_unit = _unit($TPDOdb->Get_field('tare_unit'));
            $poids_unit = _unit($TPDOdb->Get_field('poids_unit'));
            //On duplique l'étiquette autant de fois que demandé en paramètre
            for ($i = 0; $i < $nbCopies; $i++) {
                $Tetiquettes[] = array("ref" => $TPDOdb->Get_field('ref'), "nom" => $TPDOdb->Get_field('nom'), "description" => (int) $TPDOdb->Get_field('description') != 0 ? $TPDOdb->Get_field('description') : "", "tare" => number_format($TPDOdb->Get_field('tare'), 2, ',', ' '), "tare_unit" => $tare_unit, "code" => $TPDOdb->Get_field('code'), "lot" => $TPDOdb->Get_field('lot'), "poids" => number_format($TPDOdb->Get_field('poids'), 2, ',', ' '), "poids_unit" => $poids_unit);
            }
        }
    }
    if (!empty($_REQUEST['margetop'])) {
        dolibarr_set_const($db, 'ETIQUETTE_MARGE_TOP_' . $modele, $_REQUEST['margetop'], 'chaine', 1, 'Marge en mm');
    }
    if (!empty($_REQUEST['margeleft'])) {
        dolibarr_set_const($db, 'ETIQUETTE_MARGE_LEFT_' . $modele, $_REQUEST['margeleft'], 'chaine', 1, 'Marge en mm');
    }
    $TMarges = array('margetop' => $_REQUEST['margetop'], 'margeleft' => $_REQUEST['margeleft']);
    $TBS = new TTemplateTBS();
    $rendu = $TBS->Render("modele/" . $modele, array('etiquette_vide' => $TetiquettesVides, 'etiquette' => $Tetiquettes), array('marge' => $TMarges));
    echo $rendu;
}
 private function renderList(&$TEntete, &$TChamps, &$TTotal, &$TParam)
 {
     $TBS = new TTemplateTBS();
     $javaScript = $this->getJS($TParam);
     if ($this->typeRender != 'dataTableAjax') {
         $TPagination = array('pagination' => array('pageSize' => $TParam['limit']['nbLine'], 'pageNum' => $TParam['limit']['page'], 'blockName' => 'champs', 'totalNB' => count($TChamps)));
     } else {
         $TPagination = array();
     }
     $TSearch = $this->setSearch($TEntete, $TParam);
     $TExport = $this->setExport($TParam, $TChamps, $TEntete);
     return $TBS->render($this->template, array('entete' => $TEntete, 'champs' => $TChamps, 'recherche' => $TSearch, 'total' => $TTotal, 'export' => $TExport), array('liste' => array_merge(array('haveExport' => count($TExport), 'id' => $this->id, 'nb_columns' => count($TEntete), 'totalNB' => count($TChamps), 'nbSearch' => count($TSearch), 'haveTotal' => (int) (!empty($TTotal)), 'havePage' => (int) (!empty($TPagination))), $TParam['liste'])), $TPagination, array()) . $javaScript;
 }
Example #7
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();
}
<?php

require '../config.php';
$TBS = new TTemplateTBS();
$TBS->render(__FILE__, array(), array(), array(), array('outFile' => __DIR__ . '/out.html', 'convertToPDF' => 1));
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();
}
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 $');
}
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();
}