Exemplo n.º 1
0
 /**
  * @covers Fiche::get_bk_account
  * @todo   Implement testGet_bk_account().
  */
 public function testGet_bk_account()
 {
     include 'global.php';
     $this->object = new Fiche($g_connection);
     $result = $this->object->get_bk_account();
     $this->assertEquals(gettype($result), 'array');
     $count = count($result);
     $this->assertGreaterThan(0, $count);
 }
Exemplo n.º 2
0
 private function createView()
 {
     //Affichage des Trackers
     $this->oView->addData('titre', 'Signalements des membres');
     //Construction du tableau
     $oTable = new TableGenerator();
     $oTable->setId(md5('Signalements'));
     $oTable->addColumn('Date');
     $oTable->addColumn('Utilisateur');
     $oTable->addColumn('Fiche');
     $oTable->addColumn('Commentaire');
     $oTable->addColumn('');
     $aFiches = Fiche::getSignaledFiche();
     if ($aFiches != false) {
         foreach ($aFiches as $aFiche) {
             $oClearButton = new View('minibutton');
             $oClearButton->addData('link', 'index.php?p=modwarnings&type=' . $aFiche['type'] . '&id=' . $aFiche['id_fiche']);
             $oClearButton->addData('icon', 'fa-check');
             $oClearButton->addData('style', 'success');
             $oClearButton->create();
             $sLink = '<a href="index.php?p=fichedetail&type=' . $aFiche['type'] . '&id=' . $aFiche['id_fiche'] . '">[' . $aFiche['type'] . '] ' . $aFiche['id_fiche'] . '</a>';
             $oTable->addLine(array($aFiche['date'], $aFiche['login_user'], $sLink, $this->createCommentPopup($aFiche), $oClearButton->getCode()));
         }
     } else {
         $oTable->setBottom('Aucun signalement');
     }
     $oTable->create();
     $this->oView->addData('content', $oTable->getCode());
     $this->oView->create();
 }
Exemplo n.º 3
0
 function get_array_card($p_type, $p_extra = "")
 {
     switch ($p_type) {
         case 'X':
             $this->afiche = $this->cn->get_array("\n            with m as (select distinct qp_supplier as f_id from quant_purchase union select qs_client from quant_sold)\n            select distinct fiche.f_id as f_id ,f1.ad_value as name, f3.ad_value as first_name,f2.ad_value  as quick_code  \n                from fiche \n                    join m on (fiche.f_id=m.f_id)\n                    join fiche_detail as f1 on (fiche.f_id=f1.f_id and f1.ad_id=1) \n                    join fiche_detail as f2 on (fiche.f_id=f2.f_id and f2.ad_id=23) \n                    left join fiche_detail as f3 on (fiche.f_id=f3.f_id and f3.ad_id=32)\n                 where \n                 fiche.fd_id=\$1\n                 order by f1.ad_value\n                 ", array($p_extra));
             break;
         case 'U':
             $fiche = new Fiche($this->cn, $p_extra);
             $this->afiche[0]['f_id'] = $fiche->id;
             $this->afiche[0]['quick_code'] = $fiche->get_quick_code();
             $this->afiche[0]['name'] = $fiche->strAttribut(ATTR_DEF_NAME, 0);
             $this->afiche[0]['first_name'] = $fiche->strAttribut(ATTR_DEF_FIRST_NAME, 0);
             break;
         case 'F':
             $this->afiche = $this->cn->get_array("\n            select distinct qp_supplier as f_id ,f1.ad_value as name, f3.ad_value as first_name,f2.ad_value  as quick_code  \n                from quant_purchase join \n                    fiche_detail as f1 on (qp_supplier=f1.f_id and f1.ad_id=1) \n                    join fiche_detail as f2 on (qp_supplier=f2.f_id and f2.ad_id=23) \n                    left join fiche_detail as f3 on (qp_supplier=f3.f_id and f3.ad_id=32)\n                 order by f1.ad_value\n                 ");
             break;
         case 'C':
             $this->afiche = $this->cn->get_array("\n             select distinct qs_client as f_id ,f1.ad_value as name, f3.ad_value as first_name,f2.ad_value  as quick_code  \n                from quant_sold join \n                    fiche_detail as f1 on (qs_client=f1.f_id and f1.ad_id=1) \n                    join fiche_detail as f2 on (qs_client=f2.f_id and f2.ad_id=23) \n                    left join fiche_detail as f3 on (qs_client=f3.f_id and f3.ad_id=32)\n                 order by f1.ad_value\n                 ");
             break;
         default:
             throw new Exception('Type invalide');
     }
 }
Exemplo n.º 4
0
 /**
  *@brief retrieve the client name and quick_code
  *@param $p_jr_id jrn.jr_id
  *@param $p_jrn_type ledger type ACH VEN FIN
  *@return array (0=>qcode,1=>name) or for FIN 0=>customer qc 1=>customer name 2=>bank qc 3=>bank name
  *@see class_print_ledger_simple, class_print_ledger_simple_without_vat
  */
 function get_tiers($p_jr_id, $p_jrn_type)
 {
     if ($p_jrn_type == 'ACH') {
         $array = $this->cn->get_array('SELECT
                                     jrnx.j_grpt,
                                     quant_purchase.qp_supplier,
                                     quant_purchase.qp_internal,
                                     jrn.jr_internal
                                     FROM
                                     public.quant_purchase,
                                     public.jrnx,
                                     public.jrn
                                     WHERE
                                     quant_purchase.j_id = jrnx.j_id AND
                                     jrnx.j_grpt = jrn.jr_grpt_id and jr_id=$1', array($p_jr_id));
         if (count($array) == 0) {
             return array("ERREUR {$p_jr_id}", '');
         }
         $customer_id = $array[0]['qp_supplier'];
         $fiche = new Fiche($this->cn, $customer_id);
         $customer_qc = $fiche->get_quick_code($customer_id);
         $customer_name = $fiche->getName();
         return array($customer_qc, $customer_name);
     }
     if ($p_jrn_type == 'VEN') {
         $array = $this->cn->get_array('SELECT
                                     quant_sold.qs_client
                                     FROM
                                     public.quant_sold,
                                     public.jrnx,
                                     public.jrn
                                     WHERE
                                     quant_sold.j_id = jrnx.j_id AND
                                     jrnx.j_grpt = jrn.jr_grpt_id and jr_id=$1', array($p_jr_id));
         if (count($array) == 0) {
             return array("ERREUR {$p_jr_id}", '');
         }
         $customer_id = $array[0]['qs_client'];
         $fiche = new Fiche($this->cn, $customer_id);
         $customer_qc = $fiche->get_quick_code($customer_id);
         $customer_name = $fiche->getName();
         return array($customer_qc, $customer_name);
     }
     if ($p_jrn_type == 'FIN') {
         $array = $this->cn->get_array('SELECT
                                     qf_other,qf_bank
                                     FROM
                                     public.quant_fin
                                     WHERE
                                     quant_fin.jr_id =$1', array($p_jr_id));
         if (count($array) == 0) {
             return array("ERREUR {$p_jr_id}", '', '', '');
         }
         $customer_id = $array[0]['qf_other'];
         $fiche = new Fiche($this->cn, $customer_id);
         $customer_qc = $fiche->get_quick_code($customer_id);
         $customer_name = $fiche->getName();
         $bank_id = $array[0]['qf_bank'];
         $fiche = new Fiche($this->cn, $bank_id);
         $bank_qc = $fiche->get_quick_code($bank_id);
         $bank_name = $fiche->getName();
         return array($customer_qc, $customer_name, $bank_qc, $bank_name);
     }
 }
Exemplo n.º 5
0
 $go = 0;
 // we ask a poste_id
 if (isset($_GET['poste_id']) && strlen(trim($_GET['poste_id'])) != 0) {
     if (isset($_GET['poste_fille'])) {
         $parent = $_GET['poste_id'];
         $a_poste = $cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like '{$parent}%' order by pcm_val::text");
         $go = 3;
     } elseif ($cn->count_sql('select * from tmp_pcmn where pcm_val=$1', array($_GET['poste_id'])) != 0) {
         $Poste = new Acc_Account_Ledger($cn, $_GET['poste_id']);
         $go = 1;
     }
 }
 if (strlen(trim($_GET['f_id'])) != 0) {
     require_once NOALYSS_INCLUDE . '/class_fiche.php';
     // thanks the qcode we found the poste account
     $fiche = new Fiche($cn);
     $qcode = $fiche->get_by_qcode($_GET['f_id']);
     $p = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
     if ($p != NOTFOUND) {
         $go = 2;
     }
 }
 // A account  is given
 if ($go == 1) {
     echo '<div class="content">';
     if (!isset($_REQUEST['oper_detail'])) {
         Acc_Account_Ledger::HtmlTableHeader();
         echo '<div class="content">';
         $Poste->HtmlTable(null, $_GET['ople']);
         echo '</div>';
         echo Acc_Account_Ledger::HtmlTableHeader();
Exemplo n.º 6
0
} else {
    echo th(_('Total'), 'style="text-align:right"');
}
if ($owner->MY_ANALYTIC != 'nu') {
    $anc = new Anc_Plan($cn);
    $a_anc = $anc->get_list(' order by pa_id ');
    $x = count($a_anc);
    /* set the width of the col */
    /* add hidden variables pa[] to hold the value of pa_id */
    $str_anc .= '<tr><th>Code</th><th>Montant</th><th colspan="' . $x . '">' . _('Compt. Analytique') . Anc_Plan::hidden($a_anc) . '</th></tr>';
}
echo '</tr>';
for ($e = 0; $e < count($obj->det->array); $e++) {
    $row = '';
    $q = $obj->det->array[$e];
    $fiche = new Fiche($cn, $q['qp_fiche']);
    $qcode = $fiche->strAttribut(ATTR_DEF_QUICKCODE);
    $view_card_detail = HtmlInput::card_detail($qcode, "", ' class="line" ');
    $row = td($view_card_detail);
    $sym_tva = '';
    if ($owner->MY_TVA_USE == 'Y' && $q['qp_vat_code'] != '') {
        /* retrieve TVA symbol */
        $tva = new Acc_Tva($cn, $q['qp_vat_code']);
        $tva->load();
        $sym_tva = h($tva->get_parameter('label'));
    }
    if ($owner->MY_UPDLAB == 'Y') {
        $l_lib = $q['j_text'] == '' ? $fiche->strAttribut(ATTR_DEF_NAME) : $q['j_text'];
        $hidden = HtmlInput::hidden("j_id[]", $q['j_id']);
        $input = new IText("e_march" . $q['j_id'] . "_label", $l_lib);
        $input->css_size = "100%";
Exemplo n.º 7
0
function Fiches_Import($data_in = array())
{
    Lib_myLog("action: " . $data_in['action']);
    foreach ($GLOBALS['tab_globals'] as $global) {
        global ${$global};
    }
    Lib_myLog("IN: ", $data_in);
    Lib_myLog("FILE: ", __FILE__);
    $continue = true;
    /*=============*/
    Lib_myLog("Import du fichier");
    $data_out['tab_resultat'][] = "Verification du fichier d'import";
    $uploaddir = "../dilasys/tmp/";
    $uploadfile = $uploaddir . $session . "_" . @basename($_FILES['userfile']['name']);
    /*=============*/
    Lib_myLog("Deplacement du fichier en {$uploadfile}");
    @move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
    if (file_exists($uploadfile)) {
        /*=============*/
        Lib_myLog("Fichier trouve. Verification du format et du nombre de colonnes");
        if (!preg_match("/csv\$/i", $_FILES['userfile']['name'])) {
            $data_out['message_ko'] = "Le format du fichier est incorrect (format csv attendu)";
            $continue = false;
        }
        if ($continue) {
            $data = file($uploadfile);
            $premiere_ligne = explode(";", $data[0]);
            if (count($premiere_ligne) < 7) {
                $data_out['message_ko'] = "La premi&egrave; ligne ne contient pas le nombre de colonnes attendu";
                $continue = false;
            }
        }
        if ($continue) {
            ini_set("max_execution_time", 2000);
            $numLigne = 1;
            $nbFiches = 0;
            foreach ($data as $ligne) {
                $tabCol = explode(";", $ligne);
                if ($numLigne == 1) {
                    $numLigne++;
                    continue;
                } else {
                    // On n'importe pas des fiches n'ayant pas de nom ou de prénom
                    if ($tabCol[0] == '' || $tabCol[1] == '') {
                        continue;
                    }
                    /*=============*/
                    Lib_myLog("Traitement {$tabCol[0]} {$tabCol[1]}");
                    $fiche = Fiche_recuperer('', $tabCol[0], $tabCol[1]);
                    if ($fiche->id_fiche == '') {
                        /*=============*/
                        Lib_myLog("Ajout de la fiche");
                        $data_out['tab_resultat'][] = "Ajout de la fiche de {$tabCol[0]} {$tabCol[1]}";
                        $fiche = new Fiche();
                        $fiche->fic_nom = utf8_encode($tabCol[0]);
                        $fiche->fic_prenom = utf8_encode($tabCol[1]);
                        $fiche->fic_adresse1 = utf8_encode($tabCol[2]);
                        $fiche->fic_adresse2 = utf8_encode($tabCol[3]);
                        $fiche->fic_cp = $tabCol[4];
                        $fiche->fic_ville = utf8_encode($tabCol[5]);
                        $fiche->fic_email = $tabCol[6];
                        $id_fiche = $fiche->ADD();
                    } else {
                        /*=============*/
                        Lib_myLog("Modification de la fiche");
                        $data_out['tab_resultat'][] = "Modification de la fiche de {$tabCol[0]} {$tabCol[1]}";
                        $fiche->fic_adresse1 = utf8_encode($tabCol[2]);
                        $fiche->fic_adresse2 = utf8_encode($tabCol[3]);
                        $fiche->fic_cp = $tabCol[4];
                        $fiche->fic_ville = utf8_encode($tabCol[5]);
                        $fiche->fic_email = $tabCol[6];
                        $fiche->UPD();
                    }
                    $numLigne++;
                    $nbFiches++;
                }
            }
            /*=============*/
            Lib_myLog("{$nbFiches} fiches traitees");
            $data_out['message_ok'] = "{$nbFiches} fiches ont &eacute;t&eacute; trait&eacute;es";
        }
    }
    $data_in['action'] = 'Annuaire_Accueil';
    call_user_func('Annuaire_Accueil', $data_in);
}
Exemplo n.º 8
0
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
/* $Revision$ */
// Copyright Author Dany De Bontridder danydb@aevalys.eu
/**
 * @file
 * @brief show detail of a operation of fin
 *
 */
echo '<table class="result">';
echo '<tr>';
echo th(_('Compte en banque'));
echo th(_('Tiers'));
echo th(_('Libellé'));
echo th(_('Montant'));
echo '</tr>';
echo '<tr>';
$bk = new Fiche($cn, $obj->det->array[0]['qf_bank']);
$view_card_detail = HtmlInput::card_detail($bk->get_quick_code(), h($bk->getName()), ' class="line" ');
echo td($view_card_detail);
$other = new Fiche($cn, $obj->det->array[0]['qf_other']);
$view_card_detail = HtmlInput::card_detail($other->get_quick_code(), h($other->getName()), ' class="line" ');
echo td($view_card_detail);
$comment = strip_tags($obj->det->jr_comment);
echo td($comment);
echo td(nbm($obj->det->array[0]['qf_amount']), ' class="inum"');
echo '</tr>';
echo '</table>';
?>

Exemplo n.º 9
0
 * Lettering
 *
 **********************************************************************************************************************************/
// all card
if ($allcard == 1) {
    $afiche = $cn->get_array("select fd_id from vw_fiche_def where ad_id=" . ATTR_DEF_ACCOUNT . " order by fd_label asc");
} else {
    $afiche[0] = array('fd_id' => $_REQUEST['cat']);
}
if ($allcard == 0) {
    echo $str_add_card;
}
echo $export_csv;
echo $export_pdf;
echo $export_print;
$fiche = new Fiche($cn);
for ($e = 0; $e < count($afiche); $e++) {
    $array = Fiche::get_fiche_def($cn, $afiche[$e]['fd_id'], 'name_asc');
    foreach ($array as $card) {
        $row = new Fiche($cn, $card['f_id']);
        $letter = new Lettering_Card($cn);
        $letter->set_parameter('quick_code', $row->strAttribut(ATTR_DEF_QUICKCODE));
        $letter->set_parameter('start', $_GET['start']);
        $letter->set_parameter('end', $_GET['end']);
        // all
        if ($_GET['histo'] == 0) {
            $letter->get_all();
        }
        // lettered
        if ($_GET['histo'] == 1) {
            $letter->get_letter();
Exemplo n.º 10
0
$r = HtmlInput::title_box(_("Détail fiche"), 'search_card');
$r .= '<form id="search_card1_frm" method="GET" onsubmit="action_add_concerned_card(this);return false;">';
$q = new IText('query');
$q->value = isset($query) ? $query : '';
$r .= '<span style="margin-left:50px">';
$r .= _('Fiche contenant') . HtmlInput::infobulle(19);
$r .= $q->input();
$r .= HtmlInput::submit('fs', _('Recherche'), "", "smallbutton");
$r .= '</span>';
$r .= dossier::hidden() . HtmlInput::hidden('op', 'add_concerned_card');
$r .= HtmlInput::request_to_hidden(array('ag_id'));
$r .= '</form>';
$query = HtmlInput::default_value_get("query", "");
$sql_array['query'] = $query;
$sql_array['typecard'] = 'all';
$fiche = new Fiche($cn);
/* Build the SQL and show result */
$sql = $fiche->build_sql($sql_array);
/* We limit the search to MAX_SEARCH_CARD records */
$sql = $sql . ' order by vw_name limit ' . MAX_SEARCH_CARD;
$a = $cn->get_array($sql);
for ($i = 0; $i < count($a); $i++) {
    $array[$i]['quick_code'] = $a[$i]['quick_code'];
    $array[$i]['name'] = h($a[$i]['vw_name']);
    $array[$i]['accounting'] = $a[$i]['accounting'];
    $array[$i]['first_name'] = h($a[$i]['vw_first_name']);
    $array[$i]['description'] = h($a[$i]['vw_description']);
    $array[$i]['javascript'] = sprintf("action_save_concerned(%d,'%s','%s')", $gDossier, $a[$i]['f_id'], $ag_id);
}
//foreach
echo $r;
Exemplo n.º 11
0
 function remove()
 {
     if ($this->id >= 500000) {
         throw new Exception(_('Catégorie verrouillée '));
     }
     $remain = 0;
     /* get all the card */
     $aFiche = fiche::get_fiche_def($this->cn, $this->id);
     if ($aFiche != null) {
         /* check if the card is used */
         foreach ($aFiche as $dfiche) {
             $fiche = new Fiche($this->cn, $dfiche['f_id']);
             /* if the card is not used then remove it otherwise increment remains */
             if ($fiche->is_used() == false) {
                 $fiche->delete();
             } else {
                 $remain++;
             }
         }
     }
     /* if remains == 0 then remove cat */
     if ($remain == 0) {
         $sql = 'delete from jnt_fic_attr where fd_id=$1';
         $this->cn->exec_sql($sql, array($this->id));
         $sql = 'delete from fiche_def where fd_id=$1';
         $this->cn->exec_sql($sql, array($this->id));
     }
     return $remain;
 }
Exemplo n.º 12
0
/*!\file
 * \brief this file is used for the follow up of the customer (mail, meeting...)
 *  - sb = detail
 *  - sc = sv
 *  - sd = this parameter is used here
 *  - $cn = database connection
 */
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
require_once NOALYSS_INCLUDE . '/class_follow_up.php';
/**
 *\note problem with ShowActionList, this function is local
 * to the file action.inc.php. And this function must different for each
 *  suivi
 */
$sub_action = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : "list";
$ag_id = isset($_REQUEST['ag_id']) ? $_REQUEST['ag_id'] : 0;
if (!isset($_GET['submit_query'])) {
    $_REQUEST['closed_action'] = 1;
    $_GET['closed_action'] = 1;
}
$p_action = $_REQUEST['ac'];
$base = "ac={$p_action}&sc=sv&sb=detail&f_id=" . $_REQUEST['f_id'] . "&" . HtmlInput::request_to_string(array("closed_action", "remind_date_end", "remind_date", "sag_ref", "only_internal", "state", "gDossier", "qcode", "ag_dest", "query", "tdoc", "date_start", "date_end", "hsstate", "searchtag", "sb", "sc"), "");
$retour = HtmlInput::button_anchor('Retour', '?' . dossier::get() . '&' . $base);
$fiche = new Fiche($cn, $_REQUEST['f_id']);
$_GET['qcode'] = $fiche->get_quick_code();
$_REQUEST['qcode'] = $fiche->get_quick_code();
echo '<div class="content">';
require_once NOALYSS_INCLUDE . '/action.common.inc.php';
echo '</div>';
Exemplo n.º 13
0
 function __construct($p_sId = 0, $p_sTitle = '', $p_sPoster = '')
 {
     parent::__construct($p_sId, $p_sTitle, $p_sPoster, 'music');
     $this->aTracks = array();
 }
Exemplo n.º 14
0
 $row .= td($view_history);
 if ($q[$e]['j_qcode'] != '') {
     $fiche = new Fiche($cn);
     $fiche->get_by_qcode($q[$e]['j_qcode']);
     $view_history = sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:view_history_card(\'%s\',\'%s\')" >%s</A>', $fiche->id, $gDossier, $q[$e]['j_qcode']);
 } else {
     $view_history = '';
 }
 $row .= td($view_history);
 $l_lib = $q[$e]['j_text'];
 if ($l_lib != '') {
     $l_lib = $q[$e]['j_text'];
 } else {
     if ($q[$e]['j_qcode'] != '') {
         // nom de la fiche
         $ff = new Fiche($cn);
         $ff->get_by_qcode($q[$e]['j_qcode']);
         $l_lib = $ff->strAttribut(ATTR_DEF_NAME);
     } else {
         // libellé du compte
         $name = $cn->get_value('select pcm_lib from tmp_pcmn where pcm_val=$1', array($q[$e]['j_poste']));
         $l_lib = $name;
     }
 }
 $l_lib = strip_tags($l_lib);
 if ($owner->MY_UPDLAB == 'Y') {
     $hidden = HtmlInput::hidden("j_id[]", $q[$e]['j_id']);
     $input = new IText("e_march" . $q[$e]['j_id'] . "_label", $l_lib);
     $input->css_size = "100%";
 } else {
     $input = new ISpan("e_march" . $q[$e]['j_id'] . "_label");
Exemplo n.º 15
0
 */
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
include_once "ac_common.php";
require_once NOALYSS_INCLUDE . '/class_database.php';
require_once NOALYSS_INCLUDE . '/class_fiche.php';
$f_id = HtmlInput::default_value_request("f_id", "-");
if ($f_id == "-") {
    throw new Exception('Invalid parameter');
}
require_once NOALYSS_INCLUDE . '/class_dossier.php';
$gDossier = dossier::id();
/* Admin. Dossier */
$cn = new Database($gDossier);
$Fiche = new Fiche($cn, $f_id);
$qcode = $Fiche->get_quick_code();
header('Content-type: application/csv');
header('Pragma: public');
header('Content-Disposition: attachment;filename="fiche-' . $qcode . '.csv"', FALSE);
$Fiche->getName();
list($array, $tot_deb, $tot_cred) = $Fiche->get_row_date($_GET['from_periode'], $_GET['to_periode'], $_GET['ople']);
if (count($Fiche->row) == 0) {
    echo "Aucune donnée";
    return;
}
if (!isset($_REQUEST['oper_detail'])) {
    echo '"Qcode";' . "\"Date\";" . "\"n° pièce\";" . "\"Code interne\";" . '"Code journal";' . '"Nom journal";' . "\"Description\";" . "\"Débit\";" . "\"Crédit\";" . "\"Prog.\";" . "\"Let.\"";
    printf("\n");
    $progress = 0;
    $current_exercice = "";
Exemplo n.º 16
0
$detail = new Acc_Misc($cn, $obj->jr_id);
$detail->get();
if ($owner->MY_ANALYTIC != 'nu') {
    $anc = new Anc_Plan($cn);
    $a_anc = $anc->get_list(' order by pa_id ');
    $x = count($a_anc);
    /* set the width of the col */
    $str_anc .= '<th colspan="' . $x . '" style="width:auto;text-align:center">' . _('Compt. Analytique') . '</th>';
    /* add hidden variables pa[] to hold the value of pa_id */
    $str_anc .= Anc_Plan::hidden($a_anc);
}
bcscale(2);
for ($e = 0; $e < count($detail->det->array); $e++) {
    $row = '';
    $q = $detail->det->array;
    $fiche = new Fiche($cn);
    $fiche->get_by_qcode($q[$e]['j_qcode']);
    /* Analytic accountancy */
    if ($owner->MY_ANALYTIC != "nu") {
        $poste = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
        if (preg_match('/^(6|7)/', $q[$e]['j_poste'])) {
            $qcode = $fiche->strAttribut(ATTR_DEF_QUICKCODE);
            $anc_op = new Anc_Operation($cn);
            $anc_op->j_id = $q[$e]['j_id'];
            $anc_op->in_div = $div;
            $str_anc .= '<tr>';
            $str_anc .= td($poste);
            $str_anc .= td($qcode);
            $str_anc .= td(nbm($q[$e]['j_montant']));
            $str_anc .= '<td>';
            $str_anc .= HtmlInput::hidden('op[]', $anc_op->j_id);
 if ($_GET['histo'] == 1) {
     $letter->get_letter();
 }
 // unlettered
 if ($_GET['histo'] == 2) {
     $letter->get_unletter();
 }
 if ($_GET['histo'] == 6) {
     $letter->get_letter_diff();
 }
 /* skip if nothing to display */
 if (count($letter->content) == 0) {
     continue;
 }
 $pdf->SetFont('DejaVuCond', '', 10);
 $fiche = new Fiche($cn, $row_fiche['f_id']);
 $pdf->Cell(0, 7, $fiche->strAttribut(ATTR_DEF_NAME) . " [" . $fiche->strAttribut(ATTR_DEF_QUICKCODE) . ":" . $fiche->strAttribut(ATTR_DEF_ACCOUNT) . "]", 1, 'C');
 $pdf->SetFont('DejaVuCond', '', 7);
 $pdf->Ln();
 $pdf->Cell($tab[0], 7, 'Date');
 $pdf->Cell($tab[1], 7, 'ref');
 $pdf->Cell($tab[2], 7, 'Internal');
 $pdf->Cell($tab[3], 7, 'Comm');
 $pdf->Cell($tab[4], 7, 'Montant', 0, 0, 'C');
 $pdf->Cell($tab[5], 7, 'Prog.', 0, 0, 'R');
 $pdf->Cell($tab[6], 7, 'Let.', 0, 0, 'R');
 $pdf->Cell($tab[7], 7, 'Diff. Let.', 0, 0, 'R');
 $pdf->ln();
 $amount_deb = 0;
 $amount_cred = 0;
 $prog = 0;
Exemplo n.º 18
0
}
// Il est demandé de démarrer l'importation
// Post parce qu'on sauve
// On image que le fichier CSV n'a que 4 champs
// "nom client","prenom client", "numero client","adresse client"
//
if (isset($_POST['start_import'])) {
    $fd_id = $_POST['fd_id'];
    $tmp_file = $_FILES['fichier_csv']['tmp_name'];
    if (!is_uploaded_file($tmp_file)) {
        die('Je ne peux charger ce fichier');
    }
    // on ouvre le fichier
    $f = fopen($tmp_file, 'r');
    // On récupère les propriétés de cette catégorie de fiche
    $client = new Fiche($cn);
    // $array contient toutes les valeurs nécessaires à Fiche::insert,
    $array = $client->to_array($_POST['fd_id']);
    while (($data = fgetcsv($f)) == true) {
        // remarque : on a éliminé les traitements d'erreur
        // On  remet tous les attributs (propriétés) à vide
        foreach (array_keys($array) as $key) {
            $array[$key] = "";
        }
        // Nom et prénom
        $array['av_text1'] = $data[0] . ' ' . $data[1];
        // Numéro de client
        $array['av_text30'] = $data[2];
        // Adresse
        $array['av_text14'] = $data[3];
        // Quickcode
Exemplo n.º 19
0
 /**
  *Replace a special tag *TAGxxxx with the value from fiche_detail, the xxxx
  * is the ad_value
  * @param $p_qcode qcode of the card
  * @param $p_tag tag to parse
  * @return  the ad_value contained in fiche_detail or for the type "select" the
  *          label
  */
 function replace_special_tag($p_qcode, $p_tag)
 {
     // check if the march exists
     if ($p_qcode == "") {
         return "";
     }
     $f = new Fiche($this->db);
     $found = $f->get_by_qcode($p_qcode, false);
     // if not found exit
     if ($found == 1) {
         return "";
     }
     // get the ad_id
     $attr = preg_replace("/^.*ATTR/", "", $p_tag);
     if (isNumber($attr) == 0) {
         return "";
     }
     $ad_type = $this->db->get_value("select ad_type from attr_def where ad_id=\$1", array($attr));
     // get ad_value
     $ad_value = $this->db->get_value("select ad_value from fiche_detail where f_id=\$1 and ad_id=\$2", array($f->id, $attr));
     // if ad_id is type select execute select and get value
     if ($ad_type == "select") {
         $sql = $this->db->get_value("select ad_extra from attr_def where ad_id=\$1", array($attr));
         $array = $this->db->make_array($sql);
         for ($a = 0; $a < count($array); $a++) {
             if ($array[$a]['value'] == $ad_value) {
                 return $array[$a]['label'];
             }
         }
     }
     // if ad_id is not type select get value
     return $ad_value;
 }
Exemplo n.º 20
0
 function create_query_histo($p_array)
 {
     global $cn, $g_user;
     $profile = $g_user->get_profile();
     $sql = "\n\t\t\tselect sg_id,\n\t\t\t\tsg.f_id,\n\t\t\t\t(select ad_value from fiche_Detail as fd1 where ad_id=1 and fd1.f_id=jx.f_id) as fname,\n\t\t\t\t(select ad_value from fiche_Detail as fd1 where ad_id=23 and fd1.f_id=jx.f_id) as qcode,\n\t\t\t\tsg_code,\n\t\t\t\tcoalesce(sg_comment,jr_comment) as ccomment,\n\t\t\t\tsg_exercice,\n\t\t\t\tr_name,\n\t\t\t\tsg.r_id,\n\t\t\t\tj_montant,\n\t\t\t\tjr_date,\n\t\t\t\tsg_quantity,\n\t\t\t\tcase when sg_type='c' then 'OUT' when sg_type='d' then 'IN' end as direction,\n\t\t\t\tjr_internal,\n\t\t\t\tjr_id,\n\t\t\t\tcoalesce(sg_date,jr_date) as real_date,\n\t\t\t\tto_char(coalesce(sg_date,jr_date),'DD.MM.YY') as cdate\n\t\t\tfrom stock_goods as sg\n\t\t\tjoin stock_repository as sr on (sg.r_id=sr.r_id)\n\t\t\tleft join jrnx as jx on (sg.j_id=jx.j_id)\n\t\t\tleft join jrn as j on (j.jr_grpt_id=jx.j_grpt)\n\t\t\twhere\n\t\t\tsg.r_id in (select r_id from profile_sec_repository where p_id = {$profile})";
     $and = " and ";
     $clause = "";
     if (isset($p_array['wdate_start']) && $p_array['wdate_start'] != '') {
         $clause = $and . " to_date('" . sql_string($p_array['wdate_start']) . "','DD.MM.YYYY')<=coalesce(sg_date,jr_date) ";
     }
     if (isset($p_array['wdate_end']) && $p_array['wdate_end'] != '') {
         $clause .= $and . " to_date('" . sql_string($p_array['wdate_end']) . "','DD.MM.YYYY')>=coalesce(sg_date,jr_date) ";
     }
     if (isset($p_array['wamount_start']) && $p_array['wamount_start'] != '' && isNumber($p_array['wamount_start']) == 1 && $p_array['wamount_start'] != 0) {
         $clause .= $and . " j_montant >= " . sql_string($p_array['wamount_start']);
     }
     if (isset($p_array['wamount_end']) && $p_array['wamount_end'] != '' && $p_array['wamount_end'] != 0 && isNumber($p_array['wamount_end']) == 1) {
         $clause .= $and . " j_montant <= " . sql_string($p_array['wamount_end']);
     }
     if (isset($p_array['wcard']) && $p_array['wcard'] != '') {
         $f = new Fiche($this->cn);
         $f->get_by_qcode($p_array['wcard'], false);
         if ($f->id != 0) {
             $clause .= $and . " sg.f_id =  " . sql_string($f->id);
         }
     }
     if (isset($p_array['wcode_stock']) && $p_array['wcode_stock'] != "") {
         $clause .= $and . " upper(sg_code) =  upper('" . sql_string(trim($p_array['wcode_stock'])) . "')";
     }
     if (isset($p_array['wrepo']) && $p_array['wrepo'] != -1) {
         $clause .= $and . " sg.r_id = " . sql_string($p_array['wrepo']);
     }
     if (isset($p_array['wdirection']) && $p_array['wdirection'] != -1) {
         $clause .= $and . " sg.sg_type = '" . sql_string($p_array['wdirection']) . "'";
     }
     return $sql . $clause;
 }
Exemplo n.º 21
0
echo th(_('Quantité'), 'style="text-align:right"');
echo th(_('Personnel'), 'style="text-align:right"');
echo th(_('Non ded'), 'style="text-align:right"');
if ($g_parameter->MY_TVA_USE == 'Y') {
    echo th(_('HTVA'), 'style="text-align:right"');
    echo th(_('TVA NP'), 'style="text-align:right"');
    echo th(_('TVA'), 'style="text-align:right"');
    echo th(_('TVAC'), 'style="text-align:right"');
} else {
    echo th(_('Total'), 'style="text-align:right"');
}
echo '</tr>';
for ($e = 0; $e < count($obj->det->array); $e++) {
    $row = '';
    $q = $obj->det->array[$e];
    $fiche = new Fiche($cn, $q['qp_fiche']);
    $view_card_detail = HtmlInput::card_detail($fiche->strAttribut(ATTR_DEF_QUICKCODE), "", ' class="line" ');
    $row = td($view_card_detail);
    $sym_tva = '';
    if ($g_parameter->MY_TVA_USE == 'Y' && $q['qp_vat_code'] != '') {
        /* retrieve TVA symbol */
        $tva = new Acc_Tva($cn, $q['qp_vat_code']);
        $tva->load();
        $sym_tva = h($tva->get_parameter('label'));
    }
    $input = new ISpan("e_march" . $q['j_id'] . "_label");
    $hidden = HtmlInput::hidden("j_id[]", $q['j_id']);
    $input->value = $fiche->strAttribut(ATTR_DEF_NAME);
    $row .= td($input->input() . $hidden);
    $row .= td($sym_tva, 'style="text-align:center"');
    $pu = 0;
Exemplo n.º 22
0
        for ($x = 0; $x < count($_POST['op']); $x++) {
            if ($row['jr_id'] == $_POST['op'][$x]) {
                $iradio->selected = true;
                break;
            }
        }
    }
    $r .= td(HtmlInput::hidden('jrid[' . $i . ']', $row['jr_id']) . $iradio->input(), ' style="text-align:center" ');
    if ($i % 2 == 0) {
        echo tr($r, ' class="odd" ');
    } else {
        echo tr($r, ' class="even" ');
    }
}
echo '</table>';
$bk_card = new Fiche($cn);
$bk_card->id = $Ledger->get_bank();
$filter_year = "  j_tech_per in (select p_id from parm_periode where  p_exercice='" . $g_user->get_exercice() . "')";
/*  get saldo for not reconcilied operations  */
$saldo_not_reconcilied = $bk_card->get_solde_detail($filter_year . " and j_grpt in (select jr_grpt_id from jrn where trim(jr_pj_number) ='' or jr_pj_number is null)");
/*  get saldo for reconcilied operation  */
$saldo_reconcilied = $bk_card->get_solde_detail($filter_year . " and j_grpt in (select jr_grpt_id from jrn where trim(jr_pj_number) != '' and jr_pj_number is not null)");
/* solde compte */
$saldo = $bk_card->get_solde_detail($filter_year);
echo '<table>';
echo '<tr>';
echo td("Solde compte  ");
echo td(nbm(bcsub($saldo['debit'], $saldo['credit'])), ' style="text-align:right"');
echo '</tr>';
echo '<tr>';
echo td("Solde non rapproché ");
Exemplo n.º 23
0
        $sort = 'class="sorttable_sorted"';
    }
    echo '<th ' . $sort . '>' . $aHeading[$i]->ad_text . $span . '</th>';
}
?>
</tr>
<?php 
$e = 0;
foreach ($array as $row) {
    $e++;
    if ($e % 2 == 0) {
        echo '<tr class="odd">';
    } else {
        echo '<tr class="even">';
    }
    $fiche = new Fiche($cn);
    $fiche->id = $row['f_id'];
    $fiche->getAttribut();
    $detail = HtmlInput::card_detail($fiche->strAttribut(ATTR_DEF_QUICKCODE));
    echo td($detail);
    foreach ($fiche->attribut as $attr) {
        $sort = "";
        if ($attr->ad_type != 'select') {
            if ($attr->ad_type == "date") {
                // format YYYYMMDD
                $sort = 'sorttable_customkey="' . format_date($attr->av_text, "DD.MM.YYYY", "YYYYMMDD") . '"';
            }
            echo td($attr->av_text, 'style="padding: 0 10 1 10;white-space:nowrap;" ' . $sort);
        } else {
            $value = $cn->make_array($attr->ad_extra);
            $row_content = "";
Exemplo n.º 24
0
                 $e->delete();
             }
         }
         if (strlen(trim($_POST['an_cat_acc' . $i])) != 0 || strlen(trim($_POST['an_qc' . $i])) != 0) {
             /* we save only if there is something */
             $e = new Forecast_item($cn);
             if (isset($_POST['fi_id' . $i])) {
                 $e->set_parameter("id", $_POST['fi_id' . $i]);
             }
             $e->set_parameter('text', $_POST['an_label' . $i]);
             $e->set_parameter('amount', $_POST['an_cat_amount' . $i]);
             $e->set_parameter('debit', $_POST['an_deb' . $i]);
             $e->set_parameter('cat_id', $_POST['an_cat' . $i]);
             $e->set_parameter('account', $_POST['an_cat_acc' . $i]);
             $e->set_parameter('periode', $_POST['month' . $i]);
             $f = new Fiche($cn);
             if ($f->get_by_qcode($_POST['an_qc' . $i], false) == 0) {
                 $e->set_parameter('card', $f->id);
             } else {
                 $e->set_parameter('card', null);
             }
             $e->set_parameter('order', $i);
             $e->save();
         }
     }
     $cn->commit();
     $sa = 'vw';
     // to avoid to restart the add of new anticipation
 } catch (Exception $e) {
     $cn->rollback();
     alert($e->getMessage());
Exemplo n.º 25
0
function ExecActions($action)
{
    /*=============*/
    Lib_myLog("action: ", $action);
    // On recupere la configuration issue de conf.php
    global $lang, $taille_ecran, $MSG, $secure, $cle, $config, $taille_tableaux, $taille_tableaux_admin;
    // On recupere tous les objet contenant les donnees
    global $data_in, $data_out, $data_srv, $session, $tab_session;
    // Initialization des variables
    global $message, $fiche;
    switch ($action) {
        case "Recherche":
        case "Annuaire_Accueil":
            if (!isset($data_in['srch_nom']) && !isset($data_in['srch_prenom'])) {
                /*=============*/
                Lib_myLog("On recupere du cache toutes les clefs de recherche");
                if (!empty($data_srv['args_recherche'])) {
                    foreach ($data_srv['args_recherche'] as $key => $value) {
                        if (!isset($data_in[$key])) {
                            $data_in[$key] = $value;
                        }
                    }
                }
                /*=============*/
                Lib_myLog("Cache recupere:", $data_srv);
            }
            /*=============*/
            Lib_myLog("On sauvegarde dans le cache toutes les clefs de recherche");
            $data_srv['args_recherche'] = $data_in;
            /*=============*/
            Lib_myLog("Recuperation des fiches a partir du cache");
            $data_out['liste_types'] = TypesFiches_getCache();
            /*=============*/
            Lib_myLog("Recuperation de la liste des fiches avec les criteres de recherche");
            $args_fiches['id_fiche'] = '*';
            if (isset($data_in['srch_nom'])) {
                $args_fiches['fic_nom'] = '%' . $data_in['srch_nom'] . '%';
            }
            if (isset($data_in['srch_prenom'])) {
                $args_fiches['fic_prenom'] = '%' . $data_in['srch_prenom'] . '%';
            }
            $args_fiches['count'] = 1;
            $data_out['nb_resultats'] = $nb_sections = Fiches_chercher($args_fiches);
            // ======================= Tableau de navigation ===========================
            if ($nb_sections > 1) {
                $data_out['nb_sections'] = $nb_sections;
                /*=============*/
                Lib_myLog("Recuperation de la section {$data_in['section']}");
                $data_out['section'] = $data_in['section'];
                $args_fiches['limit'] = $taille_tableaux_admin;
                $args_fiches['start'] = !empty($data_in['section']) ? $data_in['section'] * $taille_tableaux_admin : 0;
            }
            $data_out['section'] = $data_in['section'];
            // ======================= ===============================================
            /*=============*/
            Lib_myLog("Recherche des fiches");
            $args_fiches['order_by'] = !empty($data_in['order_by']) ? $data_in['order_by'] : 'fic_nom';
            $args_fiches['asc_desc'] = !empty($data_in['asc_desc']) ? $data_in['asc_desc'] : 'ASC';
            unset($args_fiches['count']);
            $liste_fiches = Fiches_chercher($args_fiches);
            $data_out['action'] = 'Annuaire_Accueil';
            $data_out['liste_fiches'] = $liste_fiches;
            if ($data_in['id_fiche']) {
                $data_out['id_fiche'] = $data_in['id_fiche'];
            }
            $data_out['page'] = 'annuaire.php';
            break;
        case "Fiche_ADD":
            $F5 = Lib_checkF5($session, $data_in['timestamp']);
            $continue = $F5 ? false : true;
            // On intialise une pseudo-transaction qui nous permettre de stocker tous les objets rajoutés à la base
            // pour pouvoir les supprimer si nécessaire
            $transaction = new Collection();
            if ($continue) {
                /*=============*/
                Lib_myLog("Ajout d'un objet fiche");
                $fiche = new Fiche();
                $fiche->id_type_fiche = $data_in['id_type_fiche'];
                $fiche->fic_nom = $data_in['fic_nom'];
                $fiche->fic_prenom = $data_in['fic_prenom'];
                $fiche->fic_adresse1 = $data_in['fic_adresse1'];
                $fiche->fic_adresse2 = $data_in['fic_adresse2'];
                $fiche->fic_adresse3 = $data_in['fic_adresse3'];
                $fiche->fic_ville = $data_in['fic_ville'];
                $fiche->fic_email = $data_in['fic_email'];
                $id_fiche = $fiche->ADD();
                // On passe l'id_fiche en data_in pour effectuer la recherche sur la fiche
                $data_in['id_fiche'] = $id_fiche;
                $data_in['srch_nom'] = $data_in['fic_nom'];
                $data_in['srch_prenom'] = $data_in['fic_prenom'];
                if (!$fiche->isError()) {
                    $transaction->addElement($fiche);
                } else {
                    $continue = false;
                }
            }
            // Utiliser les lignes suivantes si des fiches supplémentaires doivent être ajoutés
            // et que l'on doit gérer une transaction
            // if ($continue) {
            //	 /*=============*/ Lib_myLog("Ajout des informations supplementaires a l'objet fiche");
            //	 $sous_fiche = new SousFiche($data_in['champ_sup1'], $data_in['champ_sup2'] , $data_in['champ_sup3']);
            //	 $sous_fiche->ADD();
            //	 if (!$sous_fiche->isError()) {
            //		  $transaction->addElement($sous_fiche);
            //	 } else {
            //		  $transaction->DEL();
            //		  $continue = false;
            //	 }
            //}
            if ($continue) {
                $data_out['message_ok'] = $MSG['fr']['%%fiche_ADD%%'];
                // On force le filtre pour que le système aille chercher à nouveau toutes les données en base
                $data_in['filtrer'] = 1;
                ExecActions('Annuaire_Accueil');
            } else {
                if ($F5) {
                    /*=============*/
                    Lib_myLog("Tentative de F5!");
                    $data_out['message'] = $MSG[$lang]['%%Erreur_Revalidation%%'];
                    ExecActions('Annuaire_Accueil');
                } else {
                    /*=============*/
                    Lib_myLog("Annulation de l'ajout suite a une erreur");
                    if (!isset($data_out['message_ko'])) {
                        $data_out['message_ko'] = $MSG[$lang]['%%Erreur_Mysql%%'];
                    }
                    // On ré-affiche les données dans la page de saisie...
                    $data_out = array_merge($data_out, $data_in);
                    ExecActions('Annuaire_Accueil');
                }
            }
            break;
        case "Fiche_UPD":
            /*=============*/
            Lib_myLog("Mise a jour du fiche");
            $fiche = Fiche_recuperer($data_in['id_fiche']);
            $fiche->id_type_fiche = $data_in['id_type_fiche'];
            $fiche->fic_nom = $data_in['fic_nom'];
            $fiche->fic_prenom = $data_in['fic_prenom'];
            $fiche->fic_adresse1 = $data_in['fic_adresse1'];
            $fiche->fic_adresse2 = $data_in['fic_adresse2'];
            $fiche->fic_adresse3 = $data_in['fic_adresse3'];
            $fiche->fic_ville = $data_in['fic_ville'];
            $fiche->fic_email = $data_in['fic_email'];
            $fiche->UPD();
            $data_out['message_ok'] = $MSG['fr']['%%fiche_UPD%%'];
            // On force le filtre pour que le système aille chercher à nouveau toutes les données en base
            $data_in['filtrer'] = 1;
            ExecActions('Annuaire_Accueil');
            break;
        case "Fiche_DEL":
            /*=============*/
            Lib_myLog("Suppression du fiche avec l'identifiant " . $data_in['id_fiche']);
            $fiche = Fiche_recuperer($data_in['id_fiche']);
            $fiche->DEL();
            $data_out['message_ok'] = $MSG['fr']['%%fiche_DEL%%'];
            ExecActions('Annuaire_Accueil');
            break;
        case "Fiches_XL":
            /*=============*/
            Lib_myLog("On recupere du cache toutes les clefs de recherche");
            if (!empty($data_srv['args_recherche'])) {
                foreach ($data_srv['args_recherche'] as $key => $value) {
                    if (!isset($data_in[$key])) {
                        $data_in[$key] = $value;
                    }
                }
            }
            /*=============*/
            Lib_myLog("Recuperation de la liste des fiches avec les criteres de recherche");
            $args_fiches['id_fiche'] = '*';
            $args_fiches['fic_nom'] = '%' . $data_in['srch_nom'] . '%';
            $args_fiches['fic_prenom'] = '%' . $data_in['srch_prenom'] . '%';
            $liste_fiches = Fiches_chercher($args_fiches);
            /*=============*/
            Lib_myLog("Impression de la liste en XL");
            $time = time();
            $file = "../exports/extraction_" . $time . ".xls";
            // le fichier doit déjà exister
            if (!($myfile = fopen($file, "w"))) {
                /*=============*/
                Lib_myLog("Erreur lors de la creation du fichier {$file}");
                exit;
            } else {
                /*=============*/
                Lib_myLog("Creation du fichier {$file}");
            }
            $header .= "Nom\t ";
            $header .= "Prenom\t ";
            $header .= "Adresse1\t ";
            $header .= "Adresse2\t ";
            $header .= "Adresse3\t ";
            $header .= "CP\t ";
            $header .= "Ville\t ";
            $header .= "Email\t ";
            $header .= "\n";
            fputs($myfile, $header);
            $body = '';
            foreach ($liste_fiches as $fiche) {
                if (!isset($data_in['chk' . $fiche['id_fiche']])) {
                    continue;
                }
                $body .= utf8_decode($fiche['fic_nom']) . "\t";
                $body .= utf8_decode($fiche['fic_prenom']) . "\t";
                $body .= utf8_decode($fiche['fic_adresse1']) . "\t";
                $body .= utf8_decode($fiche['fic_adresse2']) . "\t";
                $body .= utf8_decode($fiche['fic_adresse3']) . "\t";
                $body .= $fiche['fic_cp'] . "\t";
                $body .= utf8_decode($fiche['fic_ville']) . "\t";
                $body .= $fiche['fic_email'] . "\t";
                $body .= "\r\n";
            }
            fputs($myfile, $body);
            fclose($myfile);
            //on ferme le fichier
            chmod($file, 0755);
            $size = filesize($file);
            header("Content-Type: application/octet-stream");
            header("Content-Length: {$size}");
            header("Content-Disposition: attachment; filename=file_" . $time . ".xls");
            header("Content-Transfer-Encoding: binary");
            $fh = fopen($file, "r");
            fpassthru($fh);
            break;
        case "Fiches_PDF":
            /*=============*/
            Lib_myLog("On recupere du cache toutes les clefs de recherche");
            if (!empty($data_srv['args_recherche'])) {
                foreach ($data_srv['args_recherche'] as $key => $value) {
                    if (!isset($data_in[$key])) {
                        $data_in[$key] = $value;
                    }
                }
            }
            /*=============*/
            Lib_myLog("Recuperation de la liste des fiches avec les criteres de recherche");
            $args_fiches['id_fiche'] = '*';
            $args_fiches['fic_nom'] = '%' . $data_in['srch_nom'] . '%';
            $args_fiches['fic_prenom'] = '%' . $data_in['srch_prenom'] . '%';
            $data_out['liste_fiches'] = Fiches_chercher($args_fiches);
            $data_out['page'] = '../pdf/annuaire_pdf.php';
            break;
        case "Fiches_Import":
            $continue = true;
            /*=============*/
            Lib_myLog("Import du fichier");
            $data_out['tab_resultat'][] = "Verification du fichier d'import";
            $uploaddir = "../dilasys/tmp/";
            $uploadfile = $uploaddir . $session . "_" . @basename($_FILES['userfile']['name']);
            /*=============*/
            Lib_myLog("Deplacement du fichier en {$uploadfile}");
            @move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
            if (file_exists($uploadfile)) {
                /*=============*/
                Lib_myLog("Fichier trouve. Verification du format et du nombre de colonnes");
                if (!preg_match("/csv\$/i", $_FILES['userfile']['name'])) {
                    $data_out['message_ko'] = "Le format du fichier est incorrect (format csv attendu)";
                    $continue = false;
                }
                if ($continue) {
                    $data = file($uploadfile);
                    $premiere_ligne = explode(";", $data[0]);
                    if (count($premiere_ligne) < 7) {
                        $data_out['message_ko'] = "La premi&egrave; ligne ne contient pas le nombre de colonnes attendu";
                        $continue = false;
                    }
                }
                if ($continue) {
                    ini_set("max_execution_time", 2000);
                    $numLigne = 1;
                    $nbFiches = 0;
                    foreach ($data as $ligne) {
                        $tabCol = explode(";", $ligne);
                        if ($numLigne == 1) {
                            $numLigne++;
                            continue;
                        } else {
                            // On n'importe pas des fiches n'ayant pas de nom ou de prénom
                            if ($tabCol[0] == '' || $tabCol[1] == '') {
                                continue;
                            }
                            /*=============*/
                            Lib_myLog("Traitement {$tabCol[0]} {$tabCol[1]}");
                            $fiche = Fiche_recuperer('', $tabCol[0], $tabCol[1]);
                            if ($fiche->id_fiche == '') {
                                /*=============*/
                                Lib_myLog("Ajout de la fiche");
                                $data_out['tab_resultat'][] = "Ajout de la fiche de {$tabCol[0]} {$tabCol[1]}";
                                $fiche = new Fiche();
                                $fiche->fic_nom = utf8_encode($tabCol[0]);
                                $fiche->fic_prenom = utf8_encode($tabCol[1]);
                                $fiche->fic_adresse1 = utf8_encode($tabCol[2]);
                                $fiche->fic_adresse2 = utf8_encode($tabCol[3]);
                                $fiche->fic_cp = $tabCol[4];
                                $fiche->fic_ville = utf8_encode($tabCol[5]);
                                $fiche->fic_email = $tabCol[6];
                                $id_fiche = $fiche->ADD();
                            } else {
                                /*=============*/
                                Lib_myLog("Modification de la fiche");
                                $data_out['tab_resultat'][] = "Modification de la fiche de {$tabCol[0]} {$tabCol[1]}";
                                $fiche->fic_adresse1 = utf8_encode($tabCol[2]);
                                $fiche->fic_adresse2 = utf8_encode($tabCol[3]);
                                $fiche->fic_cp = $tabCol[4];
                                $fiche->fic_ville = utf8_encode($tabCol[5]);
                                $fiche->fic_email = $tabCol[6];
                                $fiche->UPD();
                            }
                            $numLigne++;
                            $nbFiches++;
                        }
                    }
                    /*=============*/
                    Lib_myLog("{$nbFiches} fiches traitees");
                    $data_out['message_ok'] = "{$nbFiches} fiches ont &eacute;t&eacute; trait&eacute;es";
                }
            }
            ExecActions('Annuaire_Accueil');
            break;
            /*============================================================================
            		Actions AJAX
            		=============================================================================*/
        /*============================================================================
        		Actions AJAX
        		=============================================================================*/
        case "BLOC_Fiche_SEE":
        case "BLOC_Fiche_ADD":
        case "BLOC_Fiche_UPD":
            if (isset($data_in['id_fiche'])) {
                /*=============*/
                Lib_myLog("Recuperation de la fiche");
                $args_fiche['id_fiche'] = $data_in['id_fiche'];
                $data_out['fiche'] = Fiches_chercher($args_fiche);
            }
            /*=============*/
            Lib_myLog("Recuperation des fiches a partir du cache");
            $data_out['liste_types'] = TypesFiches_getCache();
            if ($action == "BLOC_Fiche_SEE") {
                $data_out['mode'] = 'see';
            }
            if ($action == "BLOC_Fiche_ADD") {
                $data_out['mode'] = 'add';
            }
            if ($action == "BLOC_Fiche_UPD") {
                $data_out['mode'] = 'upd';
            }
            $data_out['page'] = 'annuaire_bloc_fiche.php';
            break;
        case "AUTO_ListeNoms_ADD":
            // Action utilisée pour la saisie semi-automatique et appelée par la fonction AJAX
            /*=============*/
            Lib_myLog("Recherche des fiches");
            $args_fiche['fic_nom'] = $data_in['fic_nom'] . '%';
            $args_fiche['fic_prenom'] = $data_in['fic_prenom'] . '%';
            $data_out['liste_fiches'] = Fiches_chercher($args_fiche);
            /*=============*/
            Lib_myLog("Retour");
            $data_out['page'] = 'annuaire_auto_noms_add.php';
            break;
            /*============================================================================
            		DEBUT Ajout dynamique
            		=============================================================================*/
        /*============================================================================
        		DEBUT Ajout dynamique
        		=============================================================================*/
        case "POPUP_TypeFicheADD":
            $data_out['page'] = 'annuaire_popup_type_fiche_add.php';
            break;
        case "SELECT_TypesFiches":
            /*=============*/
            Lib_myLog("Recherche des types de fiches");
            $args_types['id_type_fiche'] = '*';
            $data_out['liste_types'] = TypesFiches_chercher($args_types);
            $data_out['valeur_select'] = $data_in['valeur_select'];
            $data_out['page'] = 'annuaire_select_types_fiches.php';
            break;
        case "TypeFiche_ADD":
            $erreur = false;
            $F5 = Lib_checkF5($session, $data_in['timestamp']);
            $continue = $F5 ? false : true;
            /*=============*/
            Lib_myLog("On verifie qu'un type a bien ete saisi");
            if ($data_in['libelle'] == '') {
                $continue = false;
                $erreur = true;
                $data_out['message_ko'] = $MSG[$lang]['%%ERR_type_fiche_manque%%'];
            }
            /*=============*/
            Lib_myLog("On verifie si le type saisi n'existe pas deja");
            if ($data_in['libelle'] != '') {
                $args_type['libelle'] = $data_in['libelle'];
                $liste_types = TypesFiches_chercher($args_type);
                if (count($liste_types)) {
                    $continue = false;
                    $erreur = true;
                    $data_out['message_ko'] = $MSG[$lang]['%%ERR_type_fiche_existe%%'];
                }
            }
            if ($continue) {
                /*=============*/
                Lib_myLog("Ajout d'un type de fiche");
                $type = new TypeFiche();
                $type->libelle = $data_in['libelle'];
                $id_type_fiche = $type->ADD();
                Lib_writeData('', 'LISTE_TYPES_FICHES');
            }
            if ($continue) {
                $data_out['message_ok'] = $MSG[$lang]['%%type_fiche_ADD%%'];
                $data_out['perte_focus'] = 1;
                $data_out['valeur_select'] = $id_type_fiche;
                $data_out['page'] = "annuaire_popup_type_fiche_add.php";
            } else {
                if ($erreur) {
                    $data_out['page'] = 'annuaire_popup_type_fiche_add.php';
                } else {
                    if ($F5) {
                        /*=============*/
                        Lib_myLog("Tentative de F5!");
                        $data_out['message_ko'] = $MSG[$lang]['%%Erreur_Revalidation%%'];
                        $data_out['page'] = "annuaire_popup_type_fiche_add.php";
                    } else {
                        /*=============*/
                        Lib_myLog("Annulation de l'ajout suite a une erreur mysql");
                        $data_out['message_ko'] = $MSG[$lang]['%%Erreur_Mysql%%'];
                        // On ré-affiche les données dans la page de saisie...
                        $data_out = array_merge($data_out, $data_in);
                        $data_out['page'] = "annuaire_popup_type_fiche_add.php";
                    }
                }
            }
            break;
            /*============================================================================
            		FIN Ajout dynamique
            		=============================================================================*/
        /*============================================================================
        		FIN Ajout dynamique
        		=============================================================================*/
        case "POPUP_Memos_SEE":
        case "POPUP_MemosFiche_SEE":
        case "POPUP_Memos_UPD":
            /*=============*/
            Lib_myLog("Recuperation des memos de la fiche");
            // Affichage du plus récent en premier
            $args_memos['id_fiche'] = $data_in['id_fiche'];
            $args_memos['order_by'] = 'id_memo';
            $args_memos['asc_desc'] = 'DESC';
            $data_out['liste_memos'] = FicheMemos_chercher($args_memos);
            $data_out['id_fiche'] = $data_in['id_fiche'];
            if ($action == 'POPUP_Memos_SEE') {
                $data_out['page'] = 'annuaire_popup_memos_see.php';
            }
            if ($action == 'POPUP_MemosFiche_SEE') {
                $data_out['page'] = 'annuaire_popup_memos_fiche_see.php';
            }
            if ($action == 'POPUP_Memos_UPD') {
                $data_out['page'] = 'annuaire_popup_memos_upd.php';
            }
            break;
        case "Memos_UPD":
            /*=============*/
            Lib_myLog("Recuperation des memos de la fiche {$data_in['id_fiche']} pour mise a jour");
            $args_memos['id_fiche'] = $data_in['id_fiche'];
            $liste_memos = FicheMemos_chercher($args_memos);
            foreach ($liste_memos as $memo) {
                $memo_upd = FicheMemo_recuperer($memo['id_memo']);
                $memo_upd->memo = $data_in['memo' . $memo['id_memo']];
                $memo_upd->UPD();
            }
            if ($data_in['memo'] != '') {
                /*=============*/
                Lib_myLog("Ajout du nouveau memo");
                $memo_add = new FicheMemo();
                $memo_add->id_fiche = $data_in['id_fiche'];
                $memo_add->date_memo = mktime(0, 0, 0, $tab_date_memo[1], $tab_date_memo[0], $tab_date_memo[2]);
                $memo_add->memo = $data_in['memo'];
                $memo_add->ADD();
            }
            break;
        case "Memos_DEL":
            /*=============*/
            Lib_myLog("Suppression du memo");
            $memo_del = FicheMemo_recuperer($data_in['id_memo']);
            $memo_del->DEL();
            $data_in['id_fiche'] = $memo_del->id_fiche;
            ExecActions('POPUP_Memos_UPD');
            break;
        default:
            ExecActions('Annuaire_Accueil');
            break;
    }
}
Exemplo n.º 26
0
    function Summary($p_search = "", $p_action = "", $p_sql = "", $p_nothing = false)
    {
        $p_search = sql_string($p_search);
        $extra_sql = "";
        if ($this->company != "") {
            $extra_sql = "and f_id in (select f_id from fiche_detail\n                       where ad_value=upper('" . $this->company . "') and ad_id=" . ATTR_DEF_COMPANY . ") ";
        }
        $url = urlencode($_SERVER['REQUEST_URI']);
        $script = $_SERVER['PHP_SELF'];
        // Creation of the nav bar
        // Get the max numberRow
        $all_contact = $this->count_by_modele($this->fiche_def_ref, $p_search, $extra_sql);
        // Get offset and page variable
        $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
        $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
        $bar = navigation_bar($offset, $all_contact, $_SESSION['g_pagesize'], $page);
        // set a filter ?
        $search = "";
        if (trim($p_search) != "") {
            $search = " and f_id in\n                    (select f_id from fiche_Detail\n                    where\n                    ad_id=1 and ad_value ~* '{$p_search}') ";
        }
        // Get The result Array
        $step_contact = $this->get_by_category($offset, $search . $extra_sql . $p_sql);
        if ($all_contact == 0) {
            return "";
        }
        $r = $bar;
        $r .= '<table id="contact_tb" class="sortable">
            <TR>
            <th>Quick Code</th>
            <th>Nom</th>
            <th>Prénom</th>
			<th>Société</th>
            <th>Téléphone</th>
            <th>email</th>
            <th>Fax</th>
            </TR>';
        $base = $_SERVER['PHP_SELF'];
        // Compute the url
        $url = "";
        $and = "?";
        $get = $_GET;
        if (isset($get)) {
            foreach ($get as $name => $value) {
                // we clean the parameter offset, step, page and size
                if (!in_array($name, array('f_id', 'detail'))) {
                    $url .= $and . $name . "=" . $value;
                    $and = "&";
                }
                // if
            }
            //foreach
        }
        // if
        $back_url = urlencode($_SERVER['REQUEST_URI']);
        if (sizeof($step_contact) == 0) {
            return $r;
        }
        $idx = 0;
        foreach ($step_contact as $contact) {
            $l_company = new Fiche($this->cn);
            $l_company->get_by_qcode($contact->strAttribut(ATTR_DEF_COMPANY), false);
            $l_company_name = $l_company->strAttribut(ATTR_DEF_NAME);
            if ($l_company_name == NOTFOUND) {
                $l_company_name = "";
            }
            // add popup for detail
            if ($l_company_name != "") {
                $l_company_name = HtmlInput::card_detail($contact->strAttribut(ATTR_DEF_COMPANY), $l_company_name, 'style="text-decoration:underline;"');
            }
            $tr = $idx % 2 == 0 ? ' <tr class="odd">' : '<tr class="even">';
            $idx++;
            $r .= $tr;
            $qcode = $contact->strAttribut(ATTR_DEF_QUICKCODE);
            $r .= '<TD>' . HtmlInput::card_detail($qcode) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_NAME) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_FIRST_NAME) . "</TD>";
            $r .= "<TD>" . $l_company_name . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_TEL) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_EMAIL) . "</TD>" . "<TD> " . $contact->strAttribut(ATTR_DEF_FAX) . "</TD>";
            $r .= "</TR>";
        }
        $r .= "</TABLE>";
        $r .= $bar;
        return $r;
    }
Exemplo n.º 27
0
 function __construct($p_cn, $p_id = 0)
 {
     $this->fiche_def_ref = FICHE_TYPE_EMPL;
     parent::__construct($p_cn, $p_id);
 }
Exemplo n.º 28
0
 /**
  * Insert a new ledger
  * @param type $array normally $_POST
  * @see verify_ledger
  */
 function save_new($array)
 {
     $this->load();
     extract($array);
     $this->jrn_def_id = -1;
     $this->jrn_def_name = $p_jrn_name;
     $this->jrn_def_ech_lib = $p_ech_lib;
     $this->jrn_def_max_line_deb = $p_jrn_deb_max_line;
     $this->jrn_def_type = $p_jrn_type;
     $this->jrn_def_pj_pref = $jrn_def_pj_pref;
     $this->jrn_def_fiche_deb = isset($FICHEDEB) ? join($FICHEDEB, ',') : "";
     $this->jrn_deb_max_line = $min_row;
     $this->jrn_def_code = sprintf("%s%02d", trim(substr($this->jrn_def_type, 0, 1)), Acc_Ledger::next_number($this->db, $this->jrn_def_type));
     $this->jrn_def_description = $p_description;
     switch ($this->jrn_def_type) {
         case 'ACH':
         case 'VEN':
             $this->jrn_def_fiche_cred = isset($FICHECRED) ? join($FICHECRED, ',') : '';
             break;
         case 'ODS':
             $this->jrn_def_class_deb = $p_jrn_class_deb;
             $this->jrn_def_fiche_cred = null;
             break;
         case 'FIN':
             $a = new Fiche($this->db);
             $result = $a->get_by_qcode(trim(strtoupper($_POST['bank'])), false);
             $bank = $a->id;
             $this->jrn_def_bank = $bank;
             if ($result == -1) {
                 throw new Exception(_("Aucun compte en banque n'est donné"));
             }
             $this->jrn_def_num_op = isset($numb_operation) ? 1 : 0;
             break;
     }
     parent::insert();
 }
Exemplo n.º 29
0
 $row = '';
 $q = $detail->det->array;
 $view_history = sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:view_history_account(\'%s\',\'%s\')" >%s</A>', $q[$e]['j_poste'], $gDossier, $q[$e]['j_poste']);
 $row .= td($view_history);
 if ($q[$e]['j_qcode'] != '') {
     $fiche = new Fiche($cn);
     $fiche->get_by_qcode($q[$e]['j_qcode']);
     $view_history = sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:view_history_card(\'%s\',\'%s\')" >%s</A>', $fiche->id, $gDossier, $q[$e]['j_qcode']);
 } else {
     $view_history = '';
 }
 $row .= td($view_history);
 if ($q[$e]['j_text'] == "") {
     if ($q[$e]['j_qcode'] != '') {
         // nom de la fiche
         $ff = new Fiche($cn);
         $ff->get_by_qcode($q[$e]['j_qcode']);
         $row .= td($ff->strAttribut(h(ATTR_DEF_NAME)));
     } else {
         // libellé du compte
         $name = $cn->get_value('select pcm_lib from tmp_pcmn where pcm_val=$1', array($q[$e]['j_poste']));
         $row .= td(h($name));
     }
 } else {
     $row .= td(h($q[$e]['j_text']));
 }
 $montant = td(nbm($q[$e]['j_montant']), 'class="num"');
 $row .= $q[$e]['j_debit'] == 't' ? $montant : td('');
 $row .= $q[$e]['j_debit'] == 'f' ? $montant : td('');
 $class = $e % 2 == 0 ? ' class="even"' : 'class="odd"';
 echo tr($row, $class);
Exemplo n.º 30
0
 function __construct($p_sId = 0, $p_sTitle = '', $p_sPoster = '')
 {
     parent::__construct($p_sId, $p_sTitle, $p_sPoster, 'film');
 }