Voici votre URL de partage https://sharemycode.io/c/418d726 (Cliquer pour copier) (Copié)

Nom du fichier : Entreprise.php

<?php

namespace models\traits;

trait Entreprise
{
    function is_user_identreprise_valide($Id)
    {

        $Condition = compact(ID);
        $Table = "entreprise";
        $connection = $this->find($Table, $Condition);
        $items = $connection->get_result()->fetch_assoc();
        if ($items != 0) {
            return 1;
        } else {
            return 0;
        }
    }

    function controle_post($liste)
    {
        $error = 0;
        foreach ($liste as $field) {
            if (empty($_POST[$field])) {
                $error = 1;
            }
        }
        return $error;
    }

    function detail_compagny_update($Id_entreprise)
    {
        parent::__construct();

        $Table = "entreprise";
        $Id = $Id_entreprise;
        $Denomination_sociale = htmlspecialchars($_POST[DENOMINATION_SOCIALE]);
        $Siege_social = htmlspecialchars($_POST['Siege_social']);
        $Contact_entreprise = htmlspecialchars($_POST['Fixe_entreprise']);
        $Mail_entreprise = htmlspecialchars($_POST['Mail_entreprise']);
        $Fixe_entreprise = htmlspecialchars($_POST['Fixe_entreprise']);
        $Forme_juridique = htmlspecialchars($_POST['Forme_juridique']);
        $Domaine_activite = htmlspecialchars($_POST['Domaine_activite']);
        $Ninea = htmlspecialchars($_POST['Ninea']);
        $Numero_RC = htmlspecialchars($_POST['Numero_RC']);
        $Num_identification_fiscale = htmlspecialchars($_POST['Num_identification_fiscale']);
        $Capital_social = htmlspecialchars($_POST['Capital_social']);
        $Nombre_employe = htmlspecialchars($_POST['Nombre_employe']);
        $Service = htmlspecialchars($_POST['Service']);
        $Duree_Services = htmlspecialchars($_POST['Duree_Services']);
        $Annee_Demarrage = htmlspecialchars($_POST['Annee_Demarrage']);

        $required = $this->controle_post([
            "Denomination_sociale",
            "Siege_social",
            "Fixe_entreprise",
            "Mail_entreprise",
            "Fixe_entreprise",
            "Forme_juridique",
            "Domaine_activite",
            "Ninea",
            "Numero_RC",
            "Num_identification_fiscale",
            "Capital_social",
            "Nombre_employe",
            "Service",
            "Duree_Services",
            "Annee_Demarrage"
        ]);
        if ($required == 1) {
            return $this->message_code(200007);;
        }

        $Condition = compact(ID, "Denomination_sociale", "Siege_social", "Contact_entreprise", "Mail_entreprise", "Fixe_entreprise", "Forme_juridique", "Domaine_activite", "Ninea", "Numero_RC", "Num_identification_fiscale", "Capital_social", "Nombre_employe", "Service", "Duree_Services", "Annee_Demarrage");
        $update_comp = $this->update($Table, $Condition);
    }
    function find_compagny_update($Id)
    {


        parent::__construct();
        $Table = "entreprise";
        $Condition = compact(ID);
        $connection = $this->find($Table, $Condition);
        if ($Condition != 0) {
            $items = $connection->get_result();
        } else
            $items = $connection;
        return $items;
    }




    function create_id_entreprise()
    {
        $Id = rand(1001, 9999);
        if ($this->is_user_identreprise_valide($Id)) {
            $Id = $this->create_id_entreprise();
        } else {
            return $Id;
        }
    }

    function Add_entreprise()
    {
        parent::__construct();

        $Id = $this->create_id_entreprise();
        $Denomination_sociale = htmlspecialchars($_POST[DENOMINATION_SOCIALE]);
        $Siege_social = htmlspecialchars($_POST['Siege_social']);
        $Contact_entreprise = htmlspecialchars($_POST['Telephone']);
        $Mail_entreprise = htmlspecialchars($_POST['Mail_entreprise']);
        $Fixe_entreprise = htmlspecialchars($_POST['Fixe_entreprise']);
        $Forme_juridique = htmlspecialchars($_POST['Forme_juridique']);
        $Domaine_activite = htmlspecialchars($_POST['Domaine_activite']);
        $Devise = htmlspecialchars($_POST['Devise']);
        $Ninea = htmlspecialchars($_POST['Ninea']);
        $Numero_RC = htmlspecialchars($_POST['Numero_RC']);
        $Num_identification_fiscale = htmlspecialchars($_POST['Num_identification_fiscale']);
        $Capital_social = htmlspecialchars($_POST['Capital_social']);
        $Nombre_employe = htmlspecialchars($_POST['Nombre_employe']);
        $Service = htmlspecialchars($_POST['Service']);
        $Annee_Demarrage = htmlspecialchars($_POST['Annee_Demarrage']);
        $Duree_Services = htmlspecialchars($_POST['Duree_Services']);

        $required = $this->controle_post([
            "Denomination_sociale",
            "Siege_social",
            "Telephone",
            "Mail_entreprise",
            "Fixe_entreprise",
            "Forme_juridique",
            "Domaine_activite",
            "Ninea",
            "Numero_RC",
            "Num_identification_fiscale",
            "Devise",
            "Capital_social",
            "Nombre_employe",
            "Service",
            "Annee_Demarrage",
            "Duree_Services"
        ]);
        if ($required == 1) {
            return $this->message_code(200007);;
        }


        $Condition = compact(ID, "Denomination_sociale", "Siege_social", "Contact_entreprise", "Mail_entreprise", "Fixe_entreprise", "Forme_juridique", "Domaine_activite", "Ninea", "Numero_RC", "Num_identification_fiscale", "Devise", "Capital_social", "Nombre_employe", "Service", "Annee_Demarrage", "Duree_Services");
        $Table = "entreprise";
        $inser = $this->insert($Table, $Condition);
        $Table2 = "Solde_compte";
        $Id_identifiant = $Id;
        $Date_update = date("Y-m-d H:i:s");
        $Nom_table = $Table;
        $Condition2 = compact("Id_identifiant", "Date_update", "Nom_table");
        $inser2 = $this->insert($Table2, $Condition2);
        $inser3 = $this->inscription_supert($Id);

        // return "succés";

        $op = $this->add_dossier_entreprise($Denomination_sociale);

        return $op;
    }


    function Nombre_de_jours($Date_de_debut, $Date_de_fin)
    {
        //$date_select=date('Y-m-d',strtotime("+$i day",strtotime($reservation['Date_arrivee'])));
        $date1 = date_create_from_format('Y-m-d', $Date_de_debut);
        $date2 = date_create_from_format('Y-m-d', $Date_de_fin);
        $diff = (array) date_diff($date1, $date2);

        // Nombre de jours
        return  $diff;
    }


    function entreprise_all_access()
    {
        parent::__construct();
        $Table = "entreprise_access";
        $Condition = "";
        $connection = $this->find($Table, $Condition);
        $items = $connection;
        return $items;
    }
    function entreprise_all()
    {
        parent::__construct();
        $Table = "entreprise";
        $Condition = "";
        $connection = $this->find($Table, $Condition);
        $items = $connection;
        return $items;
    }


    function one_entreprise($Id)
    {
        parent::__construct();
        $Table = "entreprise";
        $Condition = compact(ID);
        $connection = $this->find($Table, $Condition);
        $items = $connection->get_result();
        return $items;
    }


    function delect_manage_access($Table, $Statut = null, $valeur = null)
    {
        parent::__construct();
        if ($Table != "Projet_access") {
            $Id = htmlspecialchars($_POST['Id_access']);
            $Statut = 0;
        } else {
            $Id = $valeur;
        }
        $Condition = compact(STATUT, ID);
        $update = $this->update($Table, $Condition);
    }
    function add_manage_access($Table, $Statut = null, $valeur = null)
    {

        parent::__construct();
        $Id_admin = htmlspecialchars($_POST['Id_user_add']);
        if (isset($Id_admin) and $Id_admin == "") {
            return $this->message_code(200007);
        }

        $Date_save = date("Y-m-d H:i:s");
        $Date_update = date("Y-m-d H:i:s");

        $exist = $this->one_manage_access($Id_admin, $Table, $valeur)->fetch_assoc();

        if ($exist) {
            $Statut = 1;
            $Id = $exist[ID];
            $Condition = compact(STATUT, "Date_update", ID);
            $update = $this->update($Table, $Condition);
        } else {
            if ($Table == "tache_access") {
                $Statut = 1;
                $Id_tache = htmlspecialchars($_GET['IdT']);
                $Condition = compact("Id_tache", STATUT, Date_save, ID_ADMIN);

                $user = $this->Get_all_user_byID($Id_admin)->fetch_assoc();

                if (isset($user[Email]) && $user[Email] != "") {


                    $Client = [
                        "Prenom" => $user['Prenom'],
                        NOM => $user[NOM],
                        "sujet" => 'test',  // This subject could be passed dynamically if needed
                        Email => $user['Email']
                    ];

                    $Id_entreprise = $this->whith_tache($Id_tache)->fetch_assoc();
                    $entreprise = $this->one_entreprise($Id_entreprise[ID_ENTREPRISE])->fetch_assoc();
                    //var_dump($Client);die();


                    $mess = "Nouvelles taches" . " par " . $entreprise[DENOMINATION_SOCIALE];

                    $Send_mail = $this->WSend_mail($Client, [$entreprise, 'sujet' => "new message"], $mess, "Message");
                }
            }
            if ($Table == "service_access") {
                $Statut = 1;
                $Id_service = htmlspecialchars($_GET['IdS']);
                $Condition = compact("Id_service", STATUT, Date_save, ID_ADMIN);
            }
            if ($Table == "contrat_unitaire_access") {
                $Statut = 1;
                $Id_contrat_unitaire = htmlspecialchars($_GET['IdSC']);
                $Condition = compact("Id_contrat_unitaire", STATUT, Date_save, ID_ADMIN);
            }
            if ($Table == "contrat_access") {
                $Statut = 1;
                $Id_contrat = htmlspecialchars($_GET['IdC']);
                $Condition = compact(ID_CONTRAT, STATUT, Date_save, ID_ADMIN);
            }
            if ($Table == "Projet_access") {
                $Projet_Id = htmlspecialchars($_GET['IdP']);


                $DL1_Id = $valeur;

                $Condition = compact("Projet_Id", "DL1_Id", STATUT, Date_save, ID_ADMIN);
            }
            //var_dump($Condition);
            $update = $this->insert($Table, $Condition);
        }
    }

    function one_manage_access($Id_admin, $name, $valeur = null)
    {
        if ($name == "tache" or $name == "tache_access") {
            $Table = "tache_access";
            $Id_tache = htmlspecialchars($_GET['IdT']);
            $Condition = compact(ID_ADMIN, "Id_tache");
        }
        if ($name == "service" or $name == "service_access") {
            $Table = "service_access";
            $Id_service = htmlspecialchars($_GET['IdS']);
            $Condition = compact(ID_ADMIN, "Id_service");
        }
        if ($name == "contrat_unitaire" or $name == "contrat_unitaire_access") {
            $Table = "contrat_unitaire_access";
            $Id_contrat_unitaire = htmlspecialchars($_GET['IdSC']);
            $Condition = compact(ID_ADMIN, "Id_contrat_unitaire");
        }
        if ($name == "contrat" or $name == "contrat_access") {
            $Table = "contrat_access";
            $Id_contrat = htmlspecialchars($_GET['IdC']);
            $Condition = compact(ID_ADMIN, ID_CONTRAT);
        }
        if ($name == "Projet_It" or $name == "Projet_access") {
            $Table = "Projet_access";
            $Projet_Id = htmlspecialchars($_GET['IdP']);
            $DL1_Id = $valeur;

            $Condition = compact(ID_ADMIN, "Projet_Id", "DL1_Id");
        }

        $connection = $this->find($Table, $Condition);
        $items = $connection->get_result();

        return $items;
    }





    function create_id_attachement()
    {
        $Id = rand(101, 99999);
        if ($this->is_user_idattachement_valide($Id)) {
            $Id = $this->create_id_attachement();
        } else {
            return $Id;
        }
    }

    function download_attachement()
    { //$attachement[NOM]
        $Code_attachement = htmlspecialchars($_POST[CODE_ATTACHEMENT]);
        $attachement = $this->one_Tache_chat_Attachment($Code_attachement)->fetch_assoc();
        $filepath = $attachement['Destination'];

        if (file_exists($filepath)) {
            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename="' . basename($filepath) . '"');
            header('Expires: 0');
            header('Cache-Control: must-revalidate');
            header('Pragma: public');
            header('Content-Length: ' . filesize($filepath));
            readfile($filepath);
            exit;
        }
    }

    function liste_etat()
    {
        parent::__construct();
        $Table = STATUT;
        $Condition = "";
        $connection = $this->find($Table, $Condition);
        $items = $connection;
        return $items;
    }
    function statut_by_id($id)
    {
        parent::__construct();
        $Table = STATUT;
        $Condition = compact("id");
        $connection = $this->find($Table, $Condition);
        $items = $connection->get_result();
        return $items;
    }


    function Get_all_Balance()
    {
        parent::__construct();
        $Table = "Solde_compte";
        $Condition = "";
        $connection = $this->find($Table, $Condition);
        $items = $connection;
        return $items;
    }

    function monetary_currency()
    {
        parent::__construct();
        $Table = "monetary_currency";
        $Condition = "";
        $connection = $this->find($Table, $Condition);
        $items = $connection;
        return $items;
    }
}

Informations

Cet extrait a été créé le 29 nov. 2024 à 13:30:53

Cet extrait expire le 29 déc. 2024 à 13:30:53

Langage : php

Logo php

Link

Voici votre URL de partage : https://sharemycode.io/c/418d726 Copié

Ce code a été partagé avec Share on ShareMyCode.io pour VSCode