Example #1
0
// List of folder
if ($sa == 'list') {
    require_once NOALYSS_INCLUDE . '/class_sort_table.php';
    echo '<p>';
    echo HtmlInput::button(_('Ajouter'), _('Ajouter un dossier'), " onclick=\$('folder_add_id').show()");
    echo '</p>';
    $header = new Sort_Table();
    $url = $_SERVER['PHP_SELF'] . "?sa=list&action=" . $_REQUEST['action'];
    $header->add(_("id"), $url, " order by dos_id asc", " order by dos_id desc", "da", "dd");
    $header->add(_("Nom"), $url, " order by dos_name asc", " order by dos_name desc", "na", "nd");
    $header->add(_("Description"), $url, " order by dos_description asc", " order by dos_description  desc", "da", "dd");
    $repo = new Dossier(0);
    $repocn = new Database();
    $ord = isset($_REQUEST['ord']) ? $_REQUEST['ord'] : 'na';
    $sql_order = $header->get_sql_order($ord);
    $Res = $repocn->get_array("select *  from ac_dossier {$sql_order}");
    $compteur = 1;
    $template = "";
    echo '<div class="content">';
    echo '<span style="display:block">';
    echo _('Filtre') . HtmlInput::infobulle(23);
    echo HtmlInput::filter_table("t_dossier", "0,1,2", "1");
    echo '</span>';
    echo '<TABLE id="t_dossier" class="table_large" >';
    $r = "";
    $r .= '<th>' . $header->get_header(0) . '</td>';
    $r .= '<th>' . $header->get_header(1) . '</td>';
    $r .= '<th>' . $header->get_header(2) . '</td>';
    $r .= th(_('Taille')) . th(_('Nom base de données'));
    $r = tr($r);
    echo $r;
Example #2
0
}
$action = "";
if (isset($_GET["action"])) {
    $action = $_GET["action"];
}
//----------------------------------------------------------------------
// Action = save
//----------------------------------------------------------------------
if (isset($_POST['ok'])) {
    try {
        $cn->start();
        $sec_User = new User($cn, $_POST['user_id']);
        // save profile
        $sec_User->save_profile($_POST['profile']);
        /* Save first the ledger */
        $a = $cn->get_array('select jrn_def_id from jrn_def');
        foreach ($a as $key) {
            $id = $key['jrn_def_id'];
            $priv = sprintf("jrn_act%d", $id);
            $count = $cn->get_value('select count(*) from user_sec_jrn where uj_login=$1 ' . ' and uj_jrn_id=$2', array($sec_User->login, $id));
            if ($count == 0) {
                $cn->exec_sql('insert into user_sec_jrn (uj_login,uj_jrn_id,uj_priv)' . ' values ($1,$2,$3)', array($sec_User->login, $id, $_POST[$priv]));
            } else {
                $cn->exec_sql('update user_sec_jrn set uj_priv=$1 where uj_login=$2 and uj_jrn_id=$3', array($_POST[$priv], $sec_User->login, $id));
            }
        }
        /* now save all the actions */
        $a = $cn->get_array('select ac_id from action');
        foreach ($a as $key) {
            $id = $key['ac_id'];
            $priv = sprintf("action%d", $id);
$allcard = isset($_GET['allcard']) ? 1 : 0;
/*
 * Balance
 */
if ($_GET['histo'] == 4 || $_GET['histo'] == 5) {
    $fd = new Fiche_Def($cn, $_REQUEST['cat']);
    if ($allcard == 1 && $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false) {
        $pdf->Cell(0, 10, "Cette catégorie n'ayant pas de poste comptable n'a pas de balance");
        //Save PDF to file
        $fDate = date('dmy-Hi');
        $pdf->Output("category-{$fDate}.pdf", 'D');
        exit;
    }
    // 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 && empty($afiche)) {
        $pdf->Cell(0, 10, "Aucune fiche trouvée");
        //Save PDF to file
        $fDate = date('dmy-Hi');
        $pdf->Output("category-{$fDate}.pdf", 'D');
        exit;
    }
    for ($e = 0; $e < count($afiche); $e++) {
        $aCard = $cn->get_array("select f_id,ad_value from fiche join fiche_Detail using (f_id)  where ad_id=1 and fd_id=\$1 order by 2 ", array($afiche[$e]['fd_id']));
        $name = $cn->get_value('select fd_label from fiche_def where fd_id=$1', array($afiche[$e]['fd_id']));
        $pdf->SetFont('DejaVu', 'BI', 14);
        $pdf->Cell(0, 8, $name, 0, 1, 'C');
 echo '</div>';
 $sql = 'select pcm_val from tmp_pcmn ';
 $cond_poste = '';
 if ($from_poste->value != '') {
     $cond_poste = '  where ';
     $cond_poste .= ' pcm_val >= upper (\'' . Database::escape_string($from_poste->value) . '\')';
 }
 if ($to_poste->value != '') {
     if ($cond_poste == '') {
         $cond_poste = ' where pcm_val <= upper (\'' . Database::escape_string($to_poste->value) . '\')';
     } else {
         $cond_poste .= ' and pcm_val <= upper (\'' . Database::escape_string($to_poste->value) . '\')';
     }
 }
 $sql = $sql . $cond_poste . '  order by pcm_val::text';
 $a_poste = $cn->get_array($sql);
 if (sizeof($a_poste) == 0) {
     die("Nothing here. Strange.");
     exit;
 }
 if (isDate($_REQUEST['from_periode']) == null || isDate($_REQUEST['to_periode']) == null) {
     echo alert('Date malformée, désolée');
     return;
 }
 echo '<div class="content">';
 echo '<table class="result">';
 $l = isset($_REQUEST['letter']) ? 2 : 0;
 $s = isset($_REQUEST['solded']) ? 1 : 0;
 foreach ($a_poste as $poste_id) {
     $Poste = new Acc_Account_Ledger($cn, $poste_id['pcm_val']);
     $Poste->load();
}
require_once NOALYSS_INCLUDE . '/ac_common.php';
require_once NOALYSS_INCLUDE . '/class_database.php';
require_once NOALYSS_INCLUDE . '/class_acc_account_ledger.php';
require_once NOALYSS_INCLUDE . '/class_acc_operation.php';
$fDate = date('dmy-Hi');
header('Pragma: public');
header('Content-type: application/csv');
header('Content-Disposition: attachment;filename="poste-' . $fDate . '-' . $_REQUEST['poste_id'] . '.csv"', FALSE);
require_once NOALYSS_INCLUDE . '/class_dossier.php';
$gDossier = dossier::id();
/* Admin. Dossier */
$cn = new Database($gDossier);
if (isset($_REQUEST['poste_fille'])) {
    //choisit de voir tous les postes
    $a_poste = $cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like \$1||'%'", array($_REQUEST["poste_id"]));
} else {
    $a_poste = $cn->get_array("select pcm_val from tmp_pcmn where pcm_val = \$1", array($_REQUEST['poste_id']));
}
bcscale(2);
if (!isset($_REQUEST['oper_detail'])) {
    if (count($a_poste) == 0) {
        exit;
    }
    foreach ($a_poste as $pos) {
        $Poste = new Acc_Account_Ledger($cn, $pos['pcm_val']);
        $name = $Poste->get_name();
        list($array, $tot_deb, $tot_cred) = $Poste->get_row_date($_REQUEST['from_periode'], $_REQUEST['to_periode'], $_GET['ople']);
        if (count($Poste->row) == 0) {
            continue;
        }
Example #6
0
    <h1 class="legend">
        <?php 
echo _("Vérification des fiches") . '</legend>';
?>
    </h1>
    <h2>
        <?php 
echo _('Fiches ayant changé de poste comptable');
?>
    </h2>
    <?php 
$sql_year_target = " target.j_tech_per in (select p_id from parm_periode where p_exercice='" . $g_user->get_exercice() . "')";
$sql_year_source = " source.j_tech_per in (select p_id from parm_periode where p_exercice='" . $g_user->get_exercice() . "')";
$sql_qcode = "select distinct source.f_id,source.j_qcode \n            from jrnx as source ,jrnx as target \n            where\n            source.j_id < target.j_id \n            and source.j_poste<>target.j_poste \n            and source.j_qcode = target.j_qcode\n            and {$sql_year_source} and {$sql_year_target}\n           ";
$sql_poste = "select distinct j_poste,pcm_lib from jrnx join tmp_pcmn on (pcm_val=j_poste) where j_qcode =\$1 {$sql_year}";
$a_qcode = $cn->get_array($sql_qcode);
$res = $cn->prepare('get_poste', $sql_poste);
echo _("Résultat");
if (count($a_qcode) == 0) {
    echo " OK {$g_succeed}";
} else {
    echo " " . _('Attention ') . $g_failed;
}
?>
    <ol>
    <?php 
for ($i = 0; $i < count($a_qcode); $i++) {
    $poste = $cn->execute('get_poste', array($a_qcode[$i]['j_qcode']));
    ?>
        <li><?php 
    echo HtmlInput::card_detail($a_qcode[$i]["j_qcode"], $a_qcode[$i]["j_qcode"], ' style="display:inline"');
Example #7
0
 /**
  * \brief return an array with all the active users who can access 
  *  $p_dossier including the global admin. 
  *  The user must be activated
  *
  * \param $p_dossier dossier
  * \return an array of user's  object
  *  array indices
  *    - use_id (id )
  *    - use_login (login of the user)
  *    - use_name
  *    - use_first_name
  *
  * \exception throw an exception if nobody can access
  */
 static function get_list($p_dossier)
 {
     $sql = "select distinct use_id,use_login,use_first_name,use_name from ac_users\n             left outer join  jnt_use_dos using (use_id)\n             where\n              (dos_id=\$1 and use_active=1) or (use_active=1 and use_admin=1)\n              order by use_login,use_name";
     $repo = new Database();
     $array = $repo->get_array($sql, array($p_dossier));
     if ($repo->size() == 0) {
         throw new Exception('Error inaccessible folder');
     }
     return $array;
 }
Example #8
0
                 $filter_jrn = $cred;
             }
             $filter_card = $filter_jrn != "" ? " and fd_id in ({$filter_jrn})" : ' and false ';
             break;
         case 'all':
             $filter_card = '';
             break;
         default:
             $filter_card = "and fd_id in ({$d})";
     }
 } else {
     $filter_card = $d;
     $filter_card = str_replace('[sql]', '', $d);
 }
 $sql = "select vw_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id\n         from vw_fiche_attr\n         where quick_code=upper(\$1)" . $filter_card;
 $array = $cn->get_array($sql, array($_REQUEST['FID']));
 if (empty($array)) {
     echo '{"answer":"nok","flabel":"' . $fLabel . '"}';
     exit;
 }
 $name = $array[0]['vw_name'];
 $sell = $array[0]['vw_sell'];
 $buy = $array[0]['vw_buy'];
 $tva_id = $array[0]['tva_id'];
 // Check null
 $name = $name == null ? " " : str_replace('"', '', $name);
 $sell = $sell == null ? " " : str_replace('"', '', $sell);
 $buy = $buy == null ? " " : str_replace('"', '', $buy);
 $tva_id = $tva_id == null ? " " : str_replace('"', '', $tva_id);
 /* store the answer in an array and transform it later into a JSON object */
 $tmp = array();
Example #9
0
$name = $cn->get_value('select fd_label from fiche_def where fd_id=$1', array($_GET['cat']));
$pdf->SetFont('DejaVu', 'BI', 14);
$pdf->Cell(0, 8, $name, 0, 1, 'C');
$pdf->SetTitle($name, 1);
$pdf->SetAuthor('NOALYSS');
/* balance */
if ($_GET['histo'] == 4) {
    $fd = new Fiche_Def($cn, $_REQUEST['cat']);
    if ($fd->hasAttribute(ATTR_DEF_ACCOUNT) == false) {
        $pdf->Cell(0, 10, "Cette catégorie n'ayant pas de poste comptable n'a pas de balance");
        //Save PDF to file
        $fDate = date('dmy-Hi');
        $pdf->Output("category-{$fDate}.pdf", 'D');
        exit;
    }
    $aCard = $cn->get_array("select f_id,ad_value from fiche join fiche_Detail using (f_id)  where ad_id=1 and fd_id=\$1 order by 2 ", array($_REQUEST['cat']));
    if (empty($aCard)) {
        $pdf->Cell(0, 10, "Aucune fiche trouvée");
        //Save PDF to file
        $fDate = date('dmy-Hi');
        $pdf->Output("category-{$fDate}.pdf", 'D');
        exit;
    }
    $pdf->SetFont('DejaVuCond', '', 7);
    $pdf->Cell(30, 7, 'Quick Code', 0, 0, 'L', 0);
    $pdf->Cell(80, 7, 'Libellé', 0, 0, 'L', 0);
    $pdf->Cell(20, 7, 'Débit', 0, 0, 'R', 0);
    $pdf->Cell(20, 7, 'Crédit', 0, 0, 'R', 0);
    $pdf->Cell(20, 7, 'Solde', 0, 0, 'R', 0);
    $pdf->Cell(20, 7, 'D/C', 0, 0, 'C', 0);
    $pdf->Ln();
}
require_once NOALYSS_INCLUDE . '/class_acc_account_ledger.php';
require_once NOALYSS_INCLUDE . '/ac_common.php';
require_once NOALYSS_INCLUDE . '/class_database.php';
require_once NOALYSS_INCLUDE . '/class_impress.php';
require_once NOALYSS_INCLUDE . '/header_print.php';
require_once NOALYSS_INCLUDE . '/class_dossier.php';
require_once NOALYSS_INCLUDE . '/class_user.php';
require_once NOALYSS_INCLUDE . '/class_pdf.php';
$gDossier = dossier::id();
/* Security */
$cn = new Database($gDossier);
extract($_GET);
if (isset($poste_fille)) {
    //choisit de voir tous les postes
    $a_poste = $cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like '{$poste_id}%' order by pcm_val");
} else {
    $a_poste = $cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text = '{$poste_id}'");
}
$ret = "";
$pdf = new PDF($cn);
$pdf->setDossierInfo("  Periode : " . $_GET['from_periode'] . " - " . $_GET['to_periode']);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetAuthor('NOALYSS');
$pdf->setTitle("Détail poste comptable", true);
if (count($a_poste) == 0) {
    $pdf->Output('poste.pdf', 'D');
    exit;
}
$size = array(13, 25, 13, 65, 12, 20, 20, 20);
Example #11
0
          */
         if (isset($fil) && strlen(trim($fil)) > 0) {
             $where = sprintf(" where fd_id in (%s)", sql_string($fil));
         }
     }
 }
 if (strpos($where, " in ()") != 0) {
     $html = HtmlInput::anchor_close('select_card_div');
     $html .= h2info(_('Choix de la catégorie'));
     $html .= '<h3 class="notice">';
     $html .= _("Aucune catégorie de fiche ne correspond à" . " votre demande, le journal pourrait n'avoir accès à aucune fiche");
     $html .= '</h3>';
     break;
 }
 $sql .= " " . $where . " order by fd_label";
 $array = $cn->get_array($sql);
 $html = HtmlInput::title_box(_("Choix de la catégorie"), $ctl);
 if (empty($array)) {
     $html .= _("Aucune catégorie de fiche ne correspond  à" . " votre demande");
     if (DEBUG) {
         $html .= $sql;
     }
 } else {
     $r = '';
     $r .= '<p  style="padding-left:2em">';
     $r .= _("Choisissez la catégorie de fiche à laquelle vous aimeriez ajouter une fiche") . '</p>';
     $r .= '<div style="text-align:center">';
     $msg = _('Choisissez une catégorie svp');
     $r .= '<form id="sel_type" method="GET" onsubmit="this.ipopup=' . $ctl . ";if (\$('fd_id').value != 0 ) {dis_blank_card(this);return false;} else " . "{ \$('error_cat').innerHTML='" . $msg . "'; return false;}\">";
     $r .= '<span id="error_cat" class="notice"></span>';
     $r .= dossier::hidden();
Example #12
0
 /**
  * Display the next events for 30 days 
  * todo list + action to remind
  */
 function zoom_list($notitle)
 {
     global $g_user;
     $cn = new Database(dossier::id());
     $profile = $g_user->get_profile();
     // Get the event from now and before 30 before
     // union the TODO list
     $sql = "\n          select ag_id,ag_remind_date,to_char(ag_remind_date,'DD.MM.YY') as str_date,ag_title,ag_hour,\n             coalesce(name,'interne') as str_name,\n             case when ag_remind_date < now() then 'R' \n                when ag_remind_date = now() then 'N' \n                else 'F'\n              end as status,\n              coalesce (ag_remind_date::date,current_date) - current_date as delta_days\n              from action_gestion \n               left join vw_fiche_name  on (f_id=f_id_dest)\n              where \n               ag_dest in (select p_granted from user_sec_action_profile where p_id =\$1)\n              and ag_state IN (2, 3)\n              order by ag_remind_date,ag_hour\n        ";
     $a_event = $cn->get_array($sql, array($profile));
     ob_start();
     require_once NOALYSS_INCLUDE . '/template/calendar-list.php';
     $ret = ob_get_clean();
     return $ret;
 }
Example #13
0
        $html = escape_xml($r);
        header('Content-type: text/xml; charset=UTF-8');
        echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<code>{$html}</code>
<popup>{$popup}</popup>
</data>
EOF;
        break;
    case 'label_tva':
        $cn = new Database($gDossier);
        if (isNumber($id) == 0) {
            $value = _('tva inconnue');
        } else {
            $Res = $cn->get_array("select * from tva_rate where tva_id = \$1", array($id));
            if (count($Res) == 0) {
                $value = _('tva inconnue');
            } else {
                $value = $Res[0]['tva_label'];
            }
        }
        header('Content-type: text/xml; charset=UTF-8');
        echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<code>{$code}</code>
<value>{$value}</value>
</data>
EOF;
        break;
Example #14
0
        } else {
            $get_cred = 'jrn_def_fiche_cred';
            $get_deb = 'jrn_def_fiche_deb';
            $filter_jrn = $cn->make_list("select {$get_cred}||','||{$get_deb} as fiche from jrn_def where jrn_def_type=\$1", array($_REQUEST['type']));
            $filter_card = $filter_jrn != "" ? " and fd_id in ({$filter_jrn})" : ' and false ';
        }
    }
}
/* create a filter based on j */
/*$sql_str="select f_id, vw_name,quick_code,vw_description ".
  " from vw_fiche_attr where  ".
  " ( vw_name ilike '%'||$1||'%' or quick_code ilike $2||'%' or vw_description ilike '%'||$3||'%')    ".
  $filter_card;
*/
$sql_str = "select distinct f_id from fiche join fiche_detail using (f_id) where ad_id in (9,1,23) and ad_value ilike '%'||\$1||'%' " . $filter_card . ' limit 12';
$sql = $cn->get_array($sql_str, array($_REQUEST['FID']));
if (sizeof($sql) != 0) {
    echo "<ul>";
    $sql_get = $cn->prepare('get_name', "select ad_value from fiche_detail where f_id = \$1 and ad_id=\$2");
    for ($i = 0; $i < 12 && $i < count($sql); $i++) {
        $name = '';
        $quick_code = '';
        $desc = '';
        $sql_name = $cn->execute('get_name', array($sql[$i]['f_id'], 1));
        if (Database::num_row($sql_name) == 1) {
            $name = Database::fetch_result($sql_name, 0, 0);
        }
        $sql_name = $cn->execute('get_name', array($sql[$i]['f_id'], 9));
        if (Database::num_row($sql_name) == 1) {
            $desc = Database::fetch_result($sql_name, 0, 0);
        }
Example #15
0
require_once NOALYSS_INCLUDE . '/class_database.php';
include_once 'class_impress.php';
require_once NOALYSS_INCLUDE . '/class_own.php';
require_once NOALYSS_INCLUDE . '/class_dossier.php';
require_once NOALYSS_INCLUDE . '/class_user.php';
header('Content-type: application/csv');
header('Content-Disposition: attachment;filename="gl_comptes.csv"', FALSE);
header('Pragma: public');
$gDossier = dossier::id();
/* Security */
$cn = new Database($gDossier);
extract($_GET);
if (isset($poste_id) && strlen(trim($poste_id)) != 0 && isNumber($poste_id)) {
    if (isset($poste_fille)) {
        $parent = $poste_id;
        $a_poste = $cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like '{$parent}%' order by pcm_val::text");
    } elseif ($cn->count_sql('select * from tmp_pcmn where pcm_val=' . sql_string($poste_id)) != 0) {
        $a_poste = array('pcm_val' => $poste_id);
    }
} else {
    $cond_poste = '';
    $sql = "select pcm_val from tmp_pcmn ";
    if ($from_poste != '') {
        $cond_poste = '  where ';
        $cond_poste .= " pcm_val >= upper ('" . Database::escape_string($from_poste) . "')";
    }
    if ($to_poste != '') {
        if ($cond_poste == '') {
            $cond_poste = " where pcm_val <= upper ('" . Database::escape_string($to_poste) . "')";
        } else {
            $cond_poste .= " and pcm_val <= upper ('" . Database::escape_string($to_poste) . "')";
Example #16
0
 /**
  *connect to folder and give to admin. the profile Admin(builtin)
  * @param int $p_id dossier::id()
  */
 static function synchro_admin($p_id)
 {
     // connect to target
     $cn = new Database($p_id);
     if (!$cn->exist_table("profile_menu")) {
         echo_warning("Dossier invalide");
         return;
     }
     // connect to repo
     $repo = new Database();
     $a_admin = $repo->get_array("select use_login from ac_users where\n\t\t\tuse_admin=1 and use_active=1");
     try {
         /**
          * synchro global
          */
         $cn->start();
         for ($i = 0; $i < count($a_admin); $i++) {
             $exist = $cn->get_value("select p_id from profile_user\n\t\t\t\t\twhere user_name=\$1", array($a_admin[$i]['use_login']));
             if ($exist == "") {
                 $cn->exec_sql("insert into profile_user(user_name,p_id) values(\$1,1)", array($a_admin[$i]['use_login']));
             }
         }
         $cn->commit();
     } catch (Exception $e) {
         echo_warning($e->getMessage());
         $cn->rollback();
     }
 }
Example #17
0
        email <input type="text" name="email">
        <input type="submit" name="send_email" value="Envoi email">
    </form>
    <?php 
} elseif ($action == "send_email") {
    require_once NOALYSS_INCLUDE . '/class_sendmail.php';
    require_once NOALYSS_INCLUDE . '/class_database.php';
    /*
     * Check if user exists, if yes save a recover request
     */
    $login_input = HtmlInput::default_value_request("login", "");
    $email_input = HtmlInput::default_value_request("email", "");
    $cn = new Database(0);
    $valid = false;
    if (trim($login_input) != "") {
        $array = $cn->get_array("select use_id,use_email,use_login from ac_users where lower(use_login)=lower(\$1) ", array($login_input));
    } elseif (trim($email_input) != "") {
        $array = $cn->get_array("select use_id,use_email,use_login from ac_users where  " . "  lower(use_email)=lower(\$1) ", array($email_input));
    } else {
        return;
    }
    if ($cn->size() != 0) {
        list($user_id, $user_email, $user_login) = array_values($array[0]);
        if (trim($user_email) != " ") {
            $valid = true;
        }
    }
    if ($valid == true) {
        $request_id = generate_random(SIZE_REQUEST);
        $user_password = generate_random(10);
        /*