Beispiel #1
0
            if ($pos === false) {
                return $string;
            } else {
                return substr($string, 0, $pos);
            }
        }
        function strafter($string, $substring)
        {
            $pos = strpos($string, $substring);
            if ($pos === false) {
                return $string;
            } else {
                return substr($string, $pos + strlen($substring));
            }
        }
        $id = strbefore(Request::get('id'), '.');
        $id_produit = strafter(Request::get('id'), '.');
        $module = Module::select('prix_module', 'type_module')->findOrFail($id);
        $produit = Produit::select('nom_produit', 'vers_produit')->findOrFail($id_produit);
        $data['module']['prix_module'] = $module->prix_module;
        $data['module']['type_module'] = $module->type_module;
        $data['produit']['id'] = $id_produit;
        $data['produit']['nom'] = 'Licence ' . $produit->nom_produit . ' Version ' . $produit->vers_produit;
    }
    return json_encode($data);
});
Route::get('/ProduitArticleSelect', function () {
    if (Request::ajax()) {
        $id = Request::get('id');
        $produit = Produit::findOrFail($id);
        $modules = $produit->modules;
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateDevisRequest $request)
 {
     /** Début function extraction partie string **/
     function strafter($string, $substring)
     {
         $pos = strpos($string, $substring);
         if ($pos === false) {
             return $string;
         } else {
             return substr($string, $pos + strlen($substring));
         }
     }
     function strbefore($string, $substring)
     {
         $pos = strpos($string, $substring);
         if ($pos === false) {
             return $string;
         } else {
             return substr($string, 0, $pos);
         }
     }
     /** Fin function extraction partie string **/
     $data = $request->all();
     $modules = $request->input('module_id');
     foreach ($modules as $key => $value) {
         if (strpos($value, '.') === false) {
             $produit = Produit::findOrFail($value);
             $modules_produit = $produit->modules;
             if ($data['produit_quantite'][$key] != 0) {
                 foreach ($modules_produit as $module) {
                     if ($module->type_module == 'Base') {
                         $data['module_id'][] = $module->id . '.' . $value;
                         $data['produit_quantite'][] = $data['produit_quantite'][$key];
                         $data['produit_remise'][] = $data['produit_remise'][$key];
                         $data['service_duree'][] = $data['service_duree'][$key];
                     }
                 }
             }
         }
     }
     $modules = $data['module_id'];
     foreach ($modules as $key => $value) {
         if (!empty($value)) {
             if (strpos($value, '.') !== false) {
                 $produit = Produit::findOrfail(strafter($value, '.'));
                 $dv_prefix = $produit->prefix_produit;
                 $dv_suffix = $produit->suffix_produit;
                 $devis_number = DB::table('devis')->select('num_devis')->where('num_devis', 'like', '%DV-' . $dv_prefix . '%')->orderBy('id', 'desc')->first();
                 if (empty($devis_number)) {
                     $dv_num = 'DV-' . $dv_prefix . '-' . date('y') . date('m') . $dv_suffix;
                 } else {
                     foreach ($devis_number as $dnvalue) {
                         $last_dv_number = $dnvalue;
                     }
                     $lg = strlen('DV-' . $dv_prefix . '-') + 4;
                     $inc_devis_number = substr($last_dv_number, $lg) + 1;
                     $dv_num = 'DV-' . $dv_prefix . '-' . date('y') . date('m') . $inc_devis_number;
                 }
                 $module_id = strbefore($value, '.');
                 $produit_id = strafter($value, '.');
                 $produit_quantite = $data['produit_quantite'][$key];
                 $produit_remise = $data['produit_remise'][$key];
                 $service_duree = $data['service_duree'][$key];
                 $ligne[$key] = ['module_id' => $module_id, 'produit_id' => $produit_id, 'service_duree' => $service_duree, 'devis_id' => $dv_num, 'produit_quantite' => $produit_quantite, 'produit_remise' => $produit_remise];
                 $devi_module[$key] = ['module_id' => $module_id, 'produit_id' => $produit_id, 'devis_id' => $dv_num, 'produit_quantite' => $produit_quantite, 'produit_remise' => $produit_remise];
             }
         }
     }
     $dv_number_liste = [];
     foreach ($ligne as $key => $value) {
         foreach ($value as $lkey => $lvalue) {
             if (substr($lvalue, 0, 2) == 'DV') {
                 if (empty($dv_number_liste)) {
                     $produit = Produit::select('nom_produit', 'vers_produit')->findOrfail($value['produit_id']);
                     $nom_produit = $produit->nom_produit . ' ' . $produit->vers_produit;
                     $dv_number_liste[$nom_produit] = $lvalue;
                 } else {
                     $exist = 0;
                     foreach ($dv_number_liste as $dkey => $dvalue) {
                         if ($dvalue == $lvalue) {
                             $exist = 1;
                         }
                     }
                     if ($exist == 0) {
                         $produit = Produit::select('nom_produit', 'vers_produit')->findOrfail($value['produit_id']);
                         $nom_produit = $produit->nom_produit . ' ' . $produit->vers_produit;
                         $dv_number_liste[$nom_produit] = $lvalue;
                     }
                 }
             }
         }
     }
     // Récupération des données à entrer dans la table Devis
     setlocale(LC_TIME, 'fr');
     $sclient = Societe::findOrfail($data['societe_id']);
     $client = Contact::select('nom_contact', 'prenoms_contact', 'genre_contact')->findOrfail($data['contact_id']);
     $nom_client = $client->nom_contact . ' ' . $client->prenoms_contact;
     $societedata = DB::table('societedatas')->select('id')->orderBy('created_at', 'desc')->first();
     $gescom = DB::table('gescoms')->select('id')->orderBy('created_at', 'desc')->first();
     $restemois = Carbon::now()->daysInMonth - Carbon::now()->day;
     $add = $restemois + 30;
     $echeance = Carbon::now()->addDays($add)->formatLocalized('%d %B %Y');
     // Remplissage des lignes d'entrées dans la table de devis
     foreach ($dv_number_liste as $key => $value) {
         $dv_num_int = $data['prefix_id'] . '/' . $value;
         $lg2 = strlen('DV-' . $dv_prefix . '-');
         $dv_num_ext = substr($value, $lg2);
         $devis = ['num_devis' => $value, 'num_devis_int' => $dv_num_int, 'num_devis_ext' => $dv_num_ext, 'pays_clt' => $sclient->pays_clt, 'ville_clt' => $sclient->ville_siege_clt, 'produit' => $key, 'adresse_scliente' => $sclient->adresse_siege_clt, 'tel_clt' => $sclient->tel_siege_clt, 'fax_clt' => $sclient->fax_siege_clt, 'bp_clt' => $sclient->bp_clt, 'email_clt' => $sclient->email_siege_clt, 'nom_scontact' => $nom_client, 'nom_scliente' => $sclient->nom_clt, 'url_clt' => $sclient->url_clt, 'ref_client' => $sclient->ref_client, 'civilite_contact' => $client->genre_contact, 'echeance_devis' => $echeance, 'user_id' => $data['user_id'], 'suivi_devis' => $data['suivi_devis'], 'societedata_id' => $societedata->id, 'gescom_id' => $gescom->id, 'contact_id' => $data['contact_id'], 'societe_id' => $data['societe_id']];
         Devis::create($devis);
     }
     // Enregistrement direct des données dans la table ligne_devis
     $produit_base = $ligne;
     foreach ($ligne as $key => $value) {
         $devis_id = Devis::select('id')->where('num_devis', $value['devis_id'])->get();
         foreach ($devis_id as $dvkey => $dvvalue) {
             $value['devis_id'] = $dvvalue->id;
         }
         //$produit_base[$] = $value['produit_id'];
         /*** Utilisation de la fonction Many To Many **/
         $devis_module = Devis::findOrfail($value['devis_id']);
         $id_devis[$value['produit_id']] = $devis_module->id;
         $devis_module->modules()->attach($value['module_id'], ['produit_quantite' => $value['produit_quantite'], 'produit_remise' => $value['produit_remise'], 'produit_id' => $value['produit_id'], 'service_duree' => $value['service_duree']]);
     }
     // Enregistrement des modules de base pour les licences présentes
     foreach ($id_devis as $key => $value) {
         $produits_list = Produit::findOrfail($key);
         $module_list = $produits_list->modules;
         foreach ($module_list as $mkey => $mvalue) {
             if ($mvalue->type_module == 'Base') {
                 $modules_base[$key][] = $mvalue->id;
             }
         }
     }
     // Calcul des totaux des devis
     foreach ($ligne as $key => $value) {
         $devis_id = Devis::select('id')->where('num_devis', $value['devis_id'])->get();
         foreach ($devis_id as $dvkey => $dvvalue) {
             $value['devis_id'] = $dvvalue->id;
         }
         $tht = 0;
         $devis = Devis::with('gescom')->findOrfail($value['devis_id']);
         foreach ($devis->modules as $modules) {
             $tt = $modules->pivot->produit_quantite * $modules->prix_module;
             $remise = $tt * ($modules->pivot->produit_remise / 100);
             $tht += $tt - $remise;
         }
         $remise_anpme = $tht * ($devis->gescom->taux_anpme / 100);
         $tt_anpme = $tht * ($devis->gescom->taux_anpme / 100);
         $tt_part = $tht - $tt_anpme;
         $devis_update = ['total_ht' => $tht, 'total_anpme' => $tt_anpme, 'total_part' => $tt_part];
         $devis->update($devis_update);
     }
     return redirect()->route('gescom.index');
 }
Beispiel #3
0
/**
* Create the shortcode handler
* 
* Standard shortcode handler that inserts the bible text output into the post/page
* 
* @param array $atts
* @param string $content
* @return string 
*/
function mbbt_shortcode($atts, $content = null)
{
    $atts = shortcode_atts(array('passage' => 'Genesis 1:1', 'version' => 'esv', 'heading' => FALSE), $atts);
    $content = mbbt_add_bible_text($atts['passage'], $atts['version'], $atts['heading']);
    $pos = 0;
    $loop_ = 0;
    $cont_final = "";
    $code_temp = "";
    $code_left = "";
    do {
        // This case is the first loop
        if ($loop_ == 0) {
            $code_temp = $content;
        } else {
            $code_temp = $code_left;
        }
        //Let's check if a flash object exist
        $ocurr_ = substr_count($code_temp, '</object>');
        if ($ocurr_ > 0) {
            // if flash object exists, let's get the first part of the code
            $code_left = strafter($code_temp, '</object>');
            $code_temp = strbefore($code_temp, '</object>');
            //Let's get ocurrences of ESV
            $ocurr_ = substr_count($code_temp, 'myUrl=hw%2F');
            if ($ocurr_ > 0) {
                //ESV exists
                $thepasage = strafter($code_temp, 'myUrl=hw%2F');
                //$myvar = 'Christ,World'
                $thepasage = strbefore($thepasage, '"');
                //result 'Christ'
                $pos = count($code_temp);
                $str_added = "</object>&nbsp;&nbsp;<audio class=\"audio_mpeg\" controls><source src=\"http://stream.esvmedia.org/mp3-play/hw/{$thepasage}.mp3\" type=\"audio/mpeg\"></audio>";
                //$str_added = "</object><span><!-- thepasage:$thepasage POS: $pos LOOP: $loop_ OCURR: $ocurr_ --></span>";
                $code_temp .= $str_added;
                $cont_final .= $code_temp;
            }
        }
        $loop_++;
    } while ($ocurr_ > 0);
    if ($cont_final != "") {
        $content = $cont_final . $code_left;
    }
    return $content;
}