Esempio n. 1
0
function initialize($installed)
{
    $defaults = $installed . '/Defaults';
    # conf
    if (!is_dir("conf")) {
        mkdir("conf");
    }
    copy($defaults . "/conf/saunter.inc.default", "conf/settings.inc.default");
    copy($defaults . "/conf/saucelabs.inc.default", "conf/saucelabs.inc.default");
    copy($defaults . "/phpunit.xml", "phpunit.xml");
    reinitialize($installed);
    if (!is_dir("scripts")) {
        mkdir("scripts");
    }
    if (!is_dir("includes")) {
        mkdir("includes");
    }
    if (!is_dir("includes/pages")) {
        mkdir("includes/pages");
    }
    if (!is_dir("includes/providers")) {
        mkdir("includes/providers");
    }
    if (!is_dir("includes/tailored")) {
        mkdir("includes/tailored");
    }
    if (!is_dir("logs")) {
        mkdir("logs");
    }
}
function enterdata($edit)
{
    //echo "entering data";
    $nomvalue = strtoupper($_POST['txt_Nom']);
    $prenomvalue = strtoupper($_POST['txt_Prenom']);
    $prenomvalue = strtr($prenomvalue, utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'), 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
    $_POST['chk_status'] = isset($_POST['chk_status']) ? 1 : 0;
    $_POST['txt_Notahiti'] == '' ? $notahiti = 'NULL' : ($notahiti = $_POST['txt_Notahiti']);
    //$status='TRUE';
    $Mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
    if ($edit == 0) {
        //new insert
        $query = "INSERT INTO `" . DB . "`.`mandataires` (`mandataireid`," . " `mandataireprefix`, `mandataireRS`," . " `mandatairestatus`, `mandatairenom`," . " `mandataireprenom`, `mandataireidtresor`, `mandataireemail`, `mandatairenotahiti`, `mandataireRC`," . " `mandatairetelephone`,`mandatairetelephone2`, `mandatairefax`, `mandatairebp`," . " `mandatairecp`, `mandataireville`, `mandatairecommune`, `mandatairepays`, `aroa`, `quartier`, `mandatairerib`,`obs`)" . " VALUES (NULL, '" . $_POST['box_Prefix'] . "', '" . strtoupper($_POST['txt_RS']) . "', '" . $_POST['chk_status'] . "', '" . strtoupper($_POST['txt_Nom']) . "', '" . strtoupper($_POST['txt_Prenom']) . "', '" . $_POST['txt_IDTresor'] . "', '" . strtolower($_POST['txt_Email']) . "', '" . $notahiti . "', '" . $_POST['txt_RC'] . "', '" . $_POST['txt_Telephone'] . "', '" . $_POST['txt_Telephone2'] . "', '" . $_POST['txt_Fax'] . "', '" . $_POST['txt_BP'] . "', '" . $_POST['txt_CP'] . "', '" . addslashes(strtoupper($_POST['txt_Ville'])) . "', '" . addslashes(strtoupper($_POST['txt_Commune'])) . "', '" . strtoupper($_POST['txt_Pays']) . "', '" . addslashes(strtoupper($_POST['txt_Commune'])) . "', '" . addslashes(strtoupper($_POST['txt_Pays'])) . "', '" . $_POST['txt_RIB'] . "', '" . addslashes($_POST['txt_obs']) . "')";
        //echo $query;
        $Mysqli->query($query);
        $lastid = $Mysqli->insert_id;
        if ($Mysqli->affected_rows > 0) {
            reinitialize();
            header("Location:mandataires.php?edit={$lastid}&success=1");
        } else {
            header("Location:mandataires.php?edit={$edit}&success=0");
        }
    } else {
        //update
        $query = "UPDATE `" . DB . "`.`mandataires` SET `mandatairestatus`='" . $_POST['chk_status'] . "', `mandataireprefix`='" . $_POST['box_Prefix'] . "', `mandataireRS`='" . strtoupper($_POST['txt_RS']) . "', `mandatairenom`='" . strtoupper($_POST['txt_Nom']) . "', `mandataireprenom`='" . strtoupper($_POST['txt_Prenom']) . "', `mandataireidtresor`='" . $_POST['txt_IDTresor'] . "', `mandataireemail`='" . strtolower($_POST['txt_Email']) . "', `mandatairenotahiti`='" . $notahiti . "', `mandataireRC`='" . $_POST['txt_RC'] . "', `mandatairetelephone`='" . $_POST['txt_Telephone'] . "', `mandatairetelephone2`='" . $_POST['txt_Telephone2'] . "', `mandatairefax`='" . $_POST['txt_Fax'] . "', `mandatairebp`='" . $_POST['txt_BP'] . "', `mandatairecp`='" . $_POST['txt_CP'] . "', `mandataireville`='" . addslashes(strtoupper($_POST['txt_Ville'])) . "', `mandatairecommune`='" . addslashes(strtoupper($_POST['txt_Commune'])) . "', `mandatairepays`='" . strtoupper($_POST['txt_Pays']) . "', `aroa`='" . addslashes(strtoupper($_POST['txt_Aroa'])) . "', `quartier`='" . addslashes(strtoupper($_POST['txt_Quartier'])) . "', `mandatairerib`='" . $_POST['txt_RIB'] . "', `obs`='" . addslashes($_POST['txt_obs']) . "'" . " WHERE `mandataireid`=" . $edit;
        //echo $query;
        $Mysqli->query($query);
        if ($Mysqli->affected_rows > 0) {
            reinitialize();
            header("Location:mandataires.php?edit={$edit}&success=1");
        } else {
            header("Location:mandataires.php?edit={$edit}&success=0");
        }
    }
}
function enterdata($edit)
{
    //echo "entering data";
    //$_POST['chk_status'] = (isset($_POST['chk_status']) ? 1 : 0);
    //$_POST['chk_principal'] = (isset($_POST['chk_principal']) ? 1 : 0);
    if ($_POST['chk_principal']) {
        unsetPrimaryHome($_POST['box_Proprietaire']);
    } else {
        $primary_home_count = checkPrimaryHome($_POST['box_Proprietaire'], $edit);
        //echo $primary_home_count;
        if ($primary_home_count == 0) {
            $_POST['chk_principal'] = 1;
        }
    }
    //$status='TRUE';
    $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
    if ($edit == 0) {
        //new insert
        $query = "INSERT INTO `" . DB . "`.`lieux` (" . "`lieuid` , `lieustatus` , `lieuprincipal` ," . "`lieuproprietaire` , `lieumandataire` ," . "`lieulocataire` , `lieucategorie` ," . "`lieunomlieu` , `lieusurface` ," . "`lieunmaison` , `lieuservitude` ," . "`lieuquartier` ,`lieufacturer` ," . "`lieuedt` ,`lieucompteur` ," . "`lieuobservations`)" . " VALUES (NULL, '" . $_POST['chk_status'] . "', '" . $_POST['chk_principal'] . "', '" . $_POST['box_Proprietaire'] . "', '" . $_POST['box_Mandataire'] . "', '" . $_POST['box_Locataire'] . "', '" . $_POST['box_Categorie'] . "', '" . ucwords($_POST['txt_Nomlieu']) . "', '" . $_POST['txt_Surface'] . "', '" . $_POST['txt_Nmaison'] . "', '" . $_POST['box_Servitude'] . "', '" . $_POST['box_Quartier'] . "', '" . $_POST['box_Facturer'] . "', '" . strtoupper($_POST['txt_Compteur']) . "', '" . strtoupper($_POST['txt_EDT']) . "', '" . $_POST['txt_Observations'] . "')";
    } else {
        //update
        $query = "UPDATE `" . DB . "`.`lieux` SET `lieustatus`='" . $_POST['chk_status'] . "', `lieuprincipal`='" . $_POST['chk_principal'] . "', `lieuproprietaire`='" . $_POST['box_Proprietaire'] . "', `lieumandataire`='" . $_POST['box_Mandataire'] . "', `lieulocataire`='" . $_POST['box_Locataire'] . "', `lieucategorie`='" . $_POST['box_Categorie'] . "',`lieunomlieu`='" . ucwords($_POST['txt_Nomlieu']) . "', `lieusurface`='" . $_POST['txt_Surface'] . "', `lieunmaison`='" . $_POST['txt_Nmaison'] . "', `lieuservitude`='" . $_POST['box_Servitude'] . "', `lieuquartier`='" . $_POST['box_Quartier'] . "', `lieufacturer`='" . $_POST['box_Facturer'] . "', `lieucompteur`='" . strtoupper($_POST['txt_Compteur']) . "', `lieuedt`='" . strtoupper($_POST['txt_EDT']) . "', `lieuobservations`='" . $_POST['txt_Observations'] . "'" . " WHERE `lieuid`='" . $edit . "'";
    }
    //echo $query;
    $mysqli->query($query);
    $affectedrows = $mysqli->affected_rows;
    $mysqli->close();
    if ($affectedrows > 0) {
        reinitialize();
        header("Location:lieux.php?edit={$edit}&success=1");
    } else {
        header("Location:lieux.php?edit={$edit}&success=0");
    }
}
function enterdata($edit)
{
    $nomvalue = strtoupper($_POST['txt_Nom']);
    $nomvalue = strtr($nomvalue, utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'), 'AAAAACEEEEIIIINOOOOOUUUUYAAAAACEEEEIIIINOOOOOUUUUY');
    $nomvalue = str_replace(' ', '', $nomvalue);
    $nomvalue = str_replace('-', '', $nomvalue);
    $prenomvalue = strtoupper($_POST['txt_Prenom']);
    $prenomvalue = strtr($prenomvalue, utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'), 'AAAAACEEEEIIIINOOOOOUUUUYAAAAACEEEEIIIINOOOOOUUUUY');
    $prenomvalue = str_replace(' ', '', $prenomvalue);
    $prenomvalue = str_replace('-', '', $prenomvalue);
    $dnvalue = $_POST['txt_DateNaissance'];
    $nomvalue .= "000";
    $nomvalue = substr($nomvalue, 0, 3);
    $prenomvalue .= "0000000";
    $prenomvalue = substr($prenomvalue, 0, 7);
    $date = explode("/", $dnvalue);
    $generatedcode = $date[2] . $date[1] . $date[0] . $nomvalue . $prenomvalue;
    $dnvalue = $date[2] . "-" . $date[1] . "-" . $date[0];
    $_POST['chk_status'] = isset($_POST['chk_status']) ? 1 : 0;
    $Mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
    if ($edit == 0) {
        //new insert
        $query = "INSERT INTO `" . DB . "`.`clients` (`clientid`, `clientcode`," . " `clientstatus`, `clientcivilite`, `clientnom`, `clientnommarital`," . " `clientprenom`, `clientprenom2`, `clientdatenaissance`," . " `clientlieunaissance`, `clientidtresor`, `clientemail`," . " `clientcps`, `clienttelephone`, `clientfax`, `clientbp`," . " `clientcp`, `clientville`, `clientcommune`, `clientpays`, `aroa`, `quartier`, `clientrib`, `obs`)" . " VALUES (NULL, '" . $generatedcode . "', '" . $_POST['chk_status'] . "', '" . $_POST['box_Civilite'] . "', '" . strtoupper($_POST['txt_Nom']) . "', '" . strtoupper($_POST['txt_NomMarital']) . "', '" . strtoupper($_POST['txt_Prenom']) . "', '" . strtoupper($_POST['txt_Prenom2']) . "', '" . $dnvalue . "', '" . strtoupper($_POST['txt_LieuNaissance']) . "', '" . $_POST['txt_IDTresor'] . "', '" . strtolower($_POST['txt_Email']) . "', '" . $_POST['txt_CPS'] . "', '" . $_POST['txt_Telephone'] . "', '" . $_POST['txt_Fax'] . "', '" . $_POST['txt_BP'] . "', '" . $_POST['txt_CP'] . "', '" . addslashes(strtoupper($_POST['txt_Ville'])) . "', '" . addslashes(strtoupper($_POST['txt_Commune'])) . "', '" . strtoupper($_POST['txt_Pays']) . "', '" . addslashes(strtoupper($_POST['txt_Aroa'])) . "', '" . addslashes(strtoupper($_POST['txt_Quartier'])) . "', '" . $_POST['txt_RIB'] . "', '" . addslashes($_POST['txt_obs']) . "');";
        $Mysqli->query($query);
        $lastid = $Mysqli->insert_id;
        //print $query;
        if ($Mysqli->affected_rows > 0) {
            reinitialize();
            header("Location:clients.php?edit={$lastid}&success=1&reset=1");
        } else {
            header("Location:clients.php?edit={$edit}&success=0");
        }
    } else {
        //update
        $query = "UPDATE `" . DB . "`.`clients` SET `clientcode`='" . $generatedcode . "'," . " `clientstatus`='" . $_POST['chk_status'] . "', `clientcivilite`='" . $_POST['box_Civilite'] . "', `clientnom`='" . strtoupper($_POST['txt_Nom']) . "', `clientnommarital`='" . strtoupper($_POST['txt_NomMarital']) . "', `clientprenom`='" . htmlentities(strtoupper($_POST['txt_Prenom']), ENT_QUOTES, 'UTF-8') . "', `clientprenom2`='" . strtoupper($_POST['txt_Prenom2']) . "', `clientdatenaissance`='" . $dnvalue . "'," . " `clientlieunaissance`='" . strtoupper($_POST['txt_LieuNaissance']) . "', `clientidtresor`='" . $_POST['txt_IDTresor'] . "', `clientemail`='" . strtolower($_POST['txt_Email']) . "', `clientcps`='" . $_POST['txt_CPS'] . "', `clienttelephone`='" . $_POST['txt_Telephone'] . "', `clientfax`='" . $_POST['txt_Fax'] . "', `clientbp`='" . $_POST['txt_BP'] . "', `clientcp`='" . $_POST['txt_CP'] . "', `clientville`='" . addslashes(strtoupper($_POST['txt_Ville'])) . "', `clientcommune`='" . addslashes(strtoupper($_POST['txt_Commune'])) . "', `clientpays`='" . strtoupper($_POST['txt_Pays']) . "', `aroa`='" . addslashes(strtoupper($_POST['txt_Aroa'])) . "', `quartier`='" . addslashes(strtoupper($_POST['txt_Quartier'])) . "', `clientrib`='" . $_POST['txt_RIB'] . "', `obs`='" . addslashes($_POST['txt_obs']) . "'" . " WHERE `clientid`=" . $edit;
        $Mysqli->query($query);
        //if ($Mysqli->affected_rows > 0){
        reinitialize();
        header("Location:clients.php?edit={$edit}&success=1&reset=1");
        //} else {
        //	header("Location:clients.php?edit=$edit&success=0");
        //}
    }
}