IT2704

Experience

690

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

23rd July, 2018

IT2704 started a new conversation How To Display A Table In A Popup Box With Laravel And Javascript? • 1 month ago

I have a form, with 4 comboboxes "Metier" "tache" "tacrification" and "technicien", I select a "Metier" and a "tache", after this I want that a popup box appears and show me a table that contains the "techniciens" and their "tarification" (of course only the "techniciens" that are related with the "tache" already selected). After this I select a "technician" from that table a now the form is completely filled with the "technician" and it's "pricing".

create.blade.php

@extends('Layouts/app')
@extends('Layouts/master')

@section('content')
<!--  jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">      
</script>
<link 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" 
 rel="stylesheet">

<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-               
datepicker/1.5.0/css/bootstrap- 
datepicker.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-  
datepicker/1.5.0/js/bootstrap- 
datepicker.js"></script>


    <script type="text/javascript">


    var getTachesByMetierUrl = "{{url('/tachesbymetier')}}";
    var getAdresseByClientUrl = "{{url('/adressebyclient')}}";
    var getTarificationsByTacheUrl = "{{url('/tarificationsbytache')}}";
 var getTechniciensByTarificationtacheUrl = "   
{{url('/techniciensbytarificationtache')}}";
    //console.log(getMetiersByTechnicienUrl, 
    getTachesByMetierUrl,getTarificationsByTacheUrl);


    function getAdresseByClient(val) {
    if(val.length>0) {
        var client_id = val;
        $.get(getAdresseByClientUrl+'/'+client_id,function(res) {
            var html = '<option value="">-Select-</option>' ;
            $.each(res.adresses,function(index,item) {
                html+='<option value="'+item.id+'">'+item.code_postal+'</option>';
            });
            $('#adresses').html(html);

        });
        }
        }


    function getTachesByMetier(val) {
    if(val.length>0) {
        var metier_id = val;
        $.get(getTachesByMetierUrl+'/'+metier_id,function(res) {
            var html = '<option value="">-Select-</option>' ;
            $.each(res.taches,function(index,item) {
                html+='<option value="'+item.id+'">'+item.libelle_tache+'</option>';
            });
            $('#taches').html(html);

        });
         }
        }

        function getTechniciensByTache(val) {
        if(val.length>0) {
            var tache_id = val;
            $.get(getTechniciensByTacheUrl+'/'+tarificationtache_id,function(res) {
            var html = '<option value="">-Select-</option>' ;
            $.each(res.techniciens,function(index,item) {
                html+='<option value="'+item.id+'">'+item.nom+'</option>';
            });
            $('#techniciens').html(html);

        });
        }
        }



    function getTarificationsByTache(val) {

    if(val.length>0) {
        var tache_id = val;
        $.get(getTarificationsByTacheUrl+'/'+tache_id,function(res) {
            var html = '<option value="">-Select-</option>' ;
            $.each(res.tarifications,function(index,item) {
                html+='<option value="'+item.id+'">'+item.tarif+'</option>';
            });
            $('#tarifications').html(html);

        });
        }
        }


    function rowSelect(currentRow){
    //this is the code to set a dropdown menu using jquery
    var technicien_id = selectedRow.children[0].innerHTML;
    $("#your_technicien_dropdown_menu_id").val(technicien_id);
    }




</script>



@if(count($errors))
    <div class="alert alert-danger" role="alert">
    <ul>
        @foreach($errors ->all() as $message)
            <li>{{$message}}</li>
        @endforeach
    </ul>
    </div>
@endif
<div class="container">
    <div class="row"></div>
    <div class="col-md-10">
    <h1>Ajout Intervention</h1>
    <form action=" {{url ('intervention')  }}" method="post">
        {{csrf_field()}}
        <div class="form-group">
            <label for="client">Client</label>
            <select onchange="getAdresseByClient(this.value)" name="client_id"          
id="client" 

class="form-control">
                <option value="">-Select-</option>
                @foreach($client as $t)
                    <option value="{{$t->id }}">
                        {{$t->user->nom}}
                    </option>
                @endforeach
            </select>
        </div>


        <div class="form-group">
            <label for="">date et heure </label>
            <input class="form-control" type="datetime-local"  name ="duree_prevu"                  
    value=" 
     {{old('duree_prevu')}}">
        </div>

        <div class="form-group">
            <label for="">description</label>
            <input type="text"  name ="description" class="form-control"value=" 
    {{old('description')}}">
        </div>

    <div class="form-group">
            <div class="col-md-12">
            <div class="col-md-4">
            <label>Metier: </label>
            <select onchange="getTachesByMetier(this.value)" style="width: 200px" 
class="productm form-control" id="metiers">
           <option value="">-Select-</option>
                @foreach($metiers as $t)
                    <option value="{{$t->id }}">
                        {{$t->libelle_metier}}
                    </option>
                @endforeach
            </select>
        </div>

        <div class="col-md-4">
            <label>tache: </label>
            <select onchange="getTarificationsByTache(this.value)" style="width: 200px" 
    class="productname form-control" name="tache" id="taches">
             <option value="">-Select-</option>
            </select>
        </div>

        <table class="table table-bordered bg-light">
    <thead class="bg-dark" style=" color: white">
            <tr>
                 <th class="light-table-filter" data-table="order-table" placeholder="Filter"   
    style=" 

    color: #337ab7">technicien </th>
                 <th class="light-table-filter" data-table="order-table" placeholder="Filter"            
    style=" 
    color: #337ab7">Tache </th>
                <th class="light-table-filter" data-table="order-table" placeholder="Filter"        
    style=" 

    color: #337ab7">tarif </th>
                
               
                <th style="color: #337ab7" width="220px" style="vertical-align: 
     middle">Action</th>
                
            </tr>
            </thead>
            <tbody>
            @foreach($tarifications as $tarifications)
            <tr>
                <td>{{$tarifications->technicien->user->nom}}</td>
                <td>{{$tarifications->tache->libelle_tache}}</td>
                <td>{{$tarifications->tarif}}</td>
                
                <td>
                    <div class="form-group">
                        <div class="form-group">
                        
                        <input type="checkbox"  name ="tarifications" value="id">
                    </div>
                </td>
            </tr>
            @endforeach
            </body>
        </table>
    </div>
        <div class="form-group">
            <div class="form-group">
            <label for="">statut    :   </label>
            <input type="checkbox"  name ="statut" value="1" required autofocus>
        </div>
        <div class="form-group">
            <label for="">payement</label>
            <input type="checkbox"  name ="payement" value="">
        </div>
        <div class="form-group">

            <input type="submit" value = "enregistrer" class="form-control btn btn-         
    primary">
        </div>
</div>
 </div>
 </div>
<script>
    function getMessage(){
     $.ajax({
              type:'GET',
              url:your_url,
              dataType: 'json',
              success:function(tarifications_list){
                $table_body = $("#tbl_body_name");
                $table_body.empty();

                if (tarifications_list.length > 0) {
                    div_no_data.style.display = 'none';
                    $.each(tarifications_list, function (index, value) {
                        $table_body.append('<tr class="deselected" onclick="rowSelect(this)">' +
                            '<td style="text-align: left;">' + value.technicien_id  + '</td>' +
                            '<td style="text-align: left;">' + value.tache_id + '</td>' +
                            '</tr>');
                    });
                }
              }
            });
        }
</script>
@endsection

26th June, 2018

IT2704 started a new conversation Json: How To To Add An Avg To Get The Average • 2 months ago

I have a function that displays the 'tarificationtaches' list i would like to add an avg to get the average 'techniciens' moyenne_avis from tables avis_intervention where "intervention.technicien_id" = "tarificationtaches.techncien_id" , in this is my schema .

tarificationtaches_tables

Schema::create('tarificationtaches', function (Blueprint $table) {
    $table->increments('id');
    $table->float('tarif', 8,2);
    $table->integer('tache_id')->unsigned();
    $table->foreign('tache_id')->references('id')->on('taches');
    $table->integer('technicien_id')->unsigned();
    $table->foreign('technicien_id')->references('id')->on('techniciens');
    $table->datetime('deleted_at')->nullable();
    $table->timestamps();
});

techniciens_tables

Schema::create('techniciens', function (Blueprint $table) {
    $table->increments('id');
    $table->boolean('actif')->default(1);
    $table->float('moyenne_avis')->nullable();
    $table->integer('user_id')->unsigned();
    $table->foreign('user_id')->references('id')->on('users');
    $table->datetime('deleted_at')->nullable();
    $table->timestamps();
    
});

avis_interventions_tables

Schema::create('avis_interventions', function (Blueprint $table) {
    $table->increments('id');
    $table->string('qualité');
    $table->integer('nbr_heure');
    $table->string('service');
    $table->float('note', 1,1);
    $table->integer('client_id')->unsigned();
    $table->foreign('client_id')->references('id')->on('clients');
    $table->integer('intervention_id')->unsigned();
    $table->foreign('intervention_id')->references('id')->on('interventions');
    $table->timestamps();
});

interventions_tables

Schema::create('interventions', function (Blueprint $table) {
    $table->increments('id');
    $table->date('date_intervention')->nullable();
    $table->string('description');
    $table->dateTime('duree_prevu');
    $table->boolean('statut');
    $table->integer('technicien_id')->unsigned();
    $table->foreign('technicien_id')->references('id')->on('techniciens');
    $table->integer('tarification_id')->unsigned();
    $table->foreign('tarification_id')->references('id')->on('tarificationtaches');
    $table->integer('client_id')->unsigned();
    $table->foreign('client_id')->references('id')->on('Clients');


    $table->timestamps();
});

this is my function

public function getTar(){
    $tarifications = tarificationtache::with('technicien')->get();

    return $tarifications->map(function ($tarification) {
        return [
            'nom' => $tarification->technicien->user->nom,
            'moyenne_avis' => $tarification->technicien->moyenne_avis,
            'tache' => $tarification->tache->libelle_tache,
            'tarif' => $tarification->tarif,
        ];
    });    



}

it shown like this

[{"nom":"tech 1","moyenne_avis":null,"tache":"tache 2","tarif":29.55},{"nom":"tech   
    2","moyenne_avis":null,"tache":"tache 3","tarif":55.12},{"nom":"tech 
    1","moyenne_avis":null,"tache":"tache 3","tarif":253},{"nom":"tech 
 2","moyenne_avis":null,"tache":"tache 3","tarif":28.22}]

20th June, 2018

IT2704 started a new conversation How To Display In A Popup Table Only "tarificationtache" That Are Related To The Selected "tache" ? • 3 months ago

I have several "metier" each "metier" has several "taches" and each "tache" has several "tarificationtache", when I select a "metier" I have the corresponding "tache", now I want that when I select a "tache" I get a popup table showing the "tarifacationtache" related to that "tache".

iterventioncontroller

    public function index()
    {

        $Listintervention=Intervention::with(['technicien','client','tarificationtache'])->get();

     return view('intervention.index',['interventions'=>$Listintervention]);


    }


    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()

    {

        $client = client::orderBy('id', 'asc')->get();
    $metiers = metier::orderBy('id', 'asc')->get();
    $technicien = Technicien::orderBy('id', 'desc')->get();
        $tarifications = tarificationtache::with('techniciens.user')->get(); 

        return view('intervention.create')->with('technicien', $technicien)-
    >with('client',$client)-            
        >with('metiers',$metiers)->with('tarifications',$tarifications);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(InterventionRequest $request)
    {
        $intervention = new Intervention();

        $intervention ->description =$request->input('description');
        $intervention ->duree_prevu =$request->input('duree_prevu');


        if($request->has('statut')){
        $intervention->statut = $request->input('statut');
        }else{
        $intervention->statut = 0;
        }

        $intervention ->technicien_id = $request->input('technicien_id');
        $intervention ->client_id = $request->input('client_id');
        $intervention ->tarification_id = $request->tarificationtache_id;
        $intervention->save();
        return redirect('intervention');


    }

create.blade.php

    @extends('Layouts/app')
        @extends('Layouts/master')
    @section('content')
        <!--  jQuery -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" 
    rel="stylesheet">

    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-       
    datepicker/1.5.0/css/bootstrap- 
    datepicker.css" rel="stylesheet">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-  
    datepicker/1.5.0/js/bootstrap- 
    datepicker.js"></script>


    <script type="text/javascript">
    var getTachesByMetierUrl = "{{url('/tachesbymetier')}}";
        var getAdresseByClientUrl = "{{url('/adressebyclient')}}";
        var getTarificationsByTacheUrl = "{{url('/tarificationsbytache')}}";
    var getTechniciensByTarificationtacheUrl = "{{url('/techniciensbytarificationtache')}}";
        //console.log(getMetiersByTechnicienUrl,getTachesByMetierUrl 
        ,getTarificationsByTacheUrl);


        function getAdresseByClient(val) {
        if(val.length>0) {
            var client_id = val;
            $.get(getAdresseByClientUrl+'/'+client_id,function(res) {
            var html = '<option value="">-Select-</option>' ;
            $.each(res.adresses,function(index,item) {
                html+='<option value="'+item.id+'">'+item.code_postal+'</option>';
            });
            $('#adresses').html(html);

            });
        }
        }


        function getTachesByMetier(val) {
        if(val.length>0) {
            var metier_id = val;
            $.get(getTachesByMetierUrl+'/'+metier_id,function(res) {
            var html = '<option value="">-Select-</option>' ;
            $.each(res.taches,function(index,item) {
                html+='<option value="'+item.id+'">'+item.libelle_tache+'</option>';
            });
            $('#taches').html(html);

            });
        }
        }

         function getTechniciensByTache(val) {
        if(val.length>0) {
            var tache_id = val;
            $.get(getTechniciensByTacheUrl+'/'+tarificationtache_id,function(res) {
            var html = '<option value="">-Select-</option>' ;
            $.each(res.techniciens,function(index,item) {
                html+='<option value="'+item.id+'">'+item.nom+'</option>';
            });
            $('#techniciens').html(html);

            });
        }
        }


        function rowSelect(currentRow){
        //this is the code to set a dropdown menu using jquery
        var technicien_id = selectedRow.children[0].innerHTML;
        $("#your_technicien_dropdown_menu_id").val(technicien_id);
        }




    </script>



    @if(count($errors))
        <div class="alert alert-danger" role="alert">
        <ul>
            @foreach($errors ->all() as $message)
            <li>{{$message}}</li>
            @endforeach
        </ul>
        </div>
    @endif
    <div class="container">
        <div class="row"></div>
        <div class="col-md-10">
        <h1>Ajout Intervention</h1>
        <form action=" {{url ('intervention')  }}" method="post">
            {{csrf_field()}}
            <div class="form-group">
            <label for="client">Client</label>
            <select onchange="getAdresseByClient(this.value)" name="client_id" id="client" 
    class="form-control">
                <option value="">-Select-</option>
                @foreach($client as $t)
                    <option value="{{$t->id }}">
                        {{$t->user->nom}}
                    </option>
                @endforeach
            </select>
          </div>


            <div class="form-group">
            <label for="">date et heure </label>
            <input class="form-control" type="datetime-local"  name ="duree_prevu" value=" 
    {{old('duree_prevu')}}">
         </div>

            <div class="form-group">
            <label for="">description</label>
            <input type="text"  name ="description" class="form-control"value=" 
    {{old('description')}}">
            </div>

        <div class="form-group">
            <div class="col-md-12">
            <div class="col-md-4">
            <label>Metier: </label>
            <select onchange="getTachesByMetier(this.value)" style="width: 200px" 
    class="productm form-control" id="metiers">
           <option value="">-Select-</option>
                @foreach($metiers as $t)
                    <option value="{{$t->id }}">
                        {{$t->libelle_metier}}
                    </option>
                @endforeach
            </select>
            </div>

         <div class="col-md-4">
            <label>tache: </label>
            <select onchange="getTarificationsByTache(this.value)" style="width: 200px" 
     class="productname form-control" name="tache" id="taches">
            <option value="">-Select-</option>
            </select>
        </div>

        
    </div>
            <div class="form-group">
            <div class="form-group">
            <label for="">statut    :   </label>
            <input type="checkbox"  name ="statut" value="1" required autofocus>
            </div>
            <div class="form-group">
            <label for="">payement</label>
            <input type="checkbox"  name ="payement" value="">
            </div>
            <div class="form-group">

            <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
            </div>
    </div>
    </div>
    </div>
    <script>
        function getMessage(){
        $.ajax({
              type:'GET',
              url:your_url,
              dataType: 'json',
              success:function(tarifications_list){
                $table_body = $("#tbl_body_name");
                $table_body.empty();

                if (tarifications_list.length > 0) {
                    div_no_data.style.display = 'none';
                    $.each(tarifications_list, function (index, value) {
                        $table_body.append('<tr class="deselected" onclick="rowSelect(this)">' +
                            '<td style="text-align: left;">' + value.technicien_id  + '</td>' +
                            '<td style="text-align: left;">' + value.tache_id + '</td>' +
                            '</tr>');
                    });
                }
              }
                 });
         }
     </script>


    @endsection

table tarificationtaches

    public function up()
    {
        Schema::create('tarificationtaches', function (Blueprint $table) {
        $table->increments('id');
        $table->float('tarif', 8,2);
        $table->integer('tache_id')->unsigned();
        $table->foreign('tache_id')->references('id')->on('taches');
        $table->integer('technicien_id')->unsigned();
        $table->foreign('technicien_id')->references('id')->on('techniciens');
        $table->datetime('deleted_at')->nullable();
        $table->timestamps();
        });
    }

13th June, 2018

IT2704 started a new conversation Dropdown List Empty When Id Is Autocompleted • 3 months ago

A button "add price" already selected leads us to this interface below which allows us to add a tarification==price after having selected the metier==job and the tache==task in question. The technician id box is auto-completed. My problem is that I always find the job list empty.

BUT When I manually select a technician id the job list is no longer empty. Thanks.

Note that each technician has a list of trades and each trade has a list of related tasks.

tarificationcontroller.php

public function create($technicien_id = null)   
{
$technicien = technicien::orderBy('id','desc')->get();
$taches = Tache::orderBy('libelle_tache', 'asc')->get();
$metiers = Metier::orderBy('libelle_metier', 'asc')->get();
>with('technicien', $technicien)->with('metiers', $metiers)- 
>with('technicien_id', $technicien_id);
}

create.blade.php

@extends('Layouts/app')
@extends('Layouts.master')
@section('content')
@if(count($errors))
<div class="alert alert-danger" role="alert">
<ul>
@foreach($errors ->all() as $message)
<li>{{$message}}</li>

@endforeach

@endif 0) { var technicien_id = val; $.get(getMetiersByTechnicienUrl+'/'+technicien_id,function(res) { var html = '

11th May, 2018

IT2704 left a reply on How To Display A Table In A Popup Box With Javascript? • 4 months ago

@Vilfago Thanks, could you please explain more your idea of ajax code?

IT2704 left a reply on How To Display A Table In A Popup Box With Javascript? • 4 months ago

@bobbybouwmann if you don't want to help please don't say anything at all. That's very mean what you're saying.

IT2704 started a new conversation How To Display A Table In A Popup Box With Javascript? • 4 months ago

I have the form below, with 4 comboboxes "Metier" "tache" "tacrification" et "technicien", i select a Metier and a tache, after this i want that a popup box appears and show me a table that contains all the "techniciens" and their "tarification" (of course only the "techniciens" that are related with the "tache" already selected.) after this i select a "technicien" from that table a now the form is completely filled with the "technicien" and it's "tarification". Could anyone help me with this please?

iterventioncontroller

public function create()

{
$client = client::orderBy('id', 'asc')->get();
$metiers = metier::orderBy('id', 'asc')->get();
$technicien = Technicien::orderBy('id', 'desc')->get();
$tarifications = tarificationtache::orderBy('id', 'desc')->get();

return view('intervention.create')->with('technicien', $technicien)- 
>with('client',$client)- 
>with('metiers',$metiers)->with('tarifications',$tarifications);
}

/**
* Store a newly created resource in storage.
*
* @param  \Illuminate\Http\Request  $request
* @return \Illuminate\Http\Response
*/
public function store(InterventionRequest $request)
{
$intervention = new Intervention();
$intervention ->date_intervention =$request- 
>input('date_intervention');
$intervention ->description =$request->input('description');
$intervention ->duree_prevu =$request->input('duree_prevu');
if($request->has('statut')){
$intervention->statut = $request->input('statut');
}else{
   $intervention->statut = 0;
}

$intervention ->technicien_id = $request->input('technicien_id');
$intervention ->client_id = $request->input('client_id');
$intervention ->tarification_id = $request->tarification_id;
$intervention->save();
return redirect('intervention');

}

create.blade.php

@extends('Layouts/app')
@extends('Layouts/master')

@section('content')
<!--  jQuery -->
<script 

src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>



<script type="text/javascript">


var getTachesByMetierUrl = "{{url('/tachesbymetier')}}";
var getAdresseByClientUrl = "{{url('/adressebyclient')}}";
var getTarificationsByTacheUrl = "{{url('/tarificationsbytache')}}";
var getTechniciensByTarificationtacheUrl = " 
{{url('/techniciensbytarificationtache')}}";
//console.log(getMetiersByTechnicienUrl,getTachesByMetierUrl,getTarificationsByTacheU       rl);

    function getAdresseByClient(val) {
    if(val.length>0) {
    var client_id = val;
    $.get(getAdresseByClientUrl+'/'+client_id,function(res) {
        var html = '<option value="">-Select-</option>' ;
        $.each(res.adresses,function(index,item) {
            html+='<option 
    value="'+item.id+'">'+item.code_postal+'</option>';
        });
        $('#adresses').html(html);

    });
    }
    }


function getTachesByMetier(val) {
    if(val.length>0) {
    var metier_id = val;
    $.get(getTachesByMetierUrl+'/'+metier_id,function(res) {
        var html = '<option value="">-Select-</option>' ;
        $.each(res.taches,function(index,item) {
            html+='<option 
value="'+item.id+'">'+item.libelle_tache+'</option>';
        });
        $('#taches').html(html);

    });
    }
}
function getTarificationsByTache(val) {

    if(val.length>0) {
    var tache_id = val;
    $.get(getTarificationsByTacheUrl+'/'+tache_id,function(res) {
        var html = '<option value="">-Select-</option>' ;
        $.each(res.tarifications,function(index,item) {
            html+='<option 
value="'+item.id+'">'+item.tarif+'</option>';
        });
        $('#tarifications').html(html);

    });
    }
}

function getTechniciensByTarificationtache(val) {
    if(val.length>0) {
    var tarificationtache_id = val;
    $.get(getTechniciensByTarificationtacheUrl+'/'+tarificationtache_id,function(res) {
        var html = '<option value="">-Select-</option>' ;
        $.each(res.techniciens,function(index,item) {
            html+='<option value="'+item.id+'">'+item.id+'</option>';
        });
        $('#techniciens').html(html);

    });
    }
}
@if(count($errors))
<div class="alert alert-danger" role="alert">
    <ul>
    @foreach($errors ->all() as $message)
        <li>{{$message}}</li>
    @endforeach
    </ul>
</div>
@endif
<div class="container">
<div class="row"></div>
<div class="col-md-10">
    <h1>Ajout Intervention</h1>
    <form action=" {{url ('intervention')  }}" method="post">
    {{csrf_field()}}
    <div class="form-group">
        <label for="client">Client</label>
        <select onchange="getAdresseByClient(this.value)" 
name="client_id" id="client" 
class="form-control">
            <option value="">-Select-</option>
            @foreach($client as $t)
                <option value="{{$t->id }}">
                    {{$t->user->nom}}
                </option>
            @endforeach
        </select>
    </div>


    <div class="form-group">
        <label for="">date intervention</label>

        <input class="form-control" type="date" id="example-date- 
input" name 
="date_intervention" value="{{old('date_intervention')}}">
    </div>

    <div class="form-group">
        <label for="">description</label>
        <input type="text"  name ="description" class="form- 
control"value=" 
{{old('description')}}">
    </div>


    <div class="form-group">
        <label for="">duree_prevu</label>
        <input class="form-control" type="datetime-local"  name 
="duree_prevu" value=" 
{{old('duree_prevu')}}">
    </div>

<div class="form-group">
        <div class="col-md-12">
        <div class="col-md-4">
        <label>Metier: </label>
        <select onchange="getTachesByMetier(this.value)" 
style="width: 200px" 
class="productm form-control" id="metiers">
       <option value="">-Select-</option>
                @foreach($metiers as $t)
                <option value="{{$t->id }}">
                    {{$t->libelle_metier}}
                </option>
            @endforeach
        </select>
    </div>

    <div class="col-md-4">
        <label>tache: </label>
        <select onchange="getTarificationsByTache(this.value)" 
style="width: 200px" 
class="productname form-control" name="tache" id="taches">
        <option value="">-Select-</option>
        </select>
    </div>

    <div class="col-md-4">
        <label>tarification: </label>
        <select 
onchange="getTechniciensByTarificationtache(this.value)" 
style="width: 
200px" class="productname form-control" name="tarificationtache_id" 
id="tarifications">
        <option value="">-Select-</option>
        </select>
    </div>

    <div class="col-md-4">
                <label>technicien: </label>
                <select style="width: 200px" class="productname 
form-control" 
name="technicien_id" id="techniciens">
                    <option value="">-Select-</option>
                </select>
            </div>



</div>
</div>

</div>
</div>
</div>

<link 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"            rel="stylesheet">

<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap- 
datepicker/1.5.0/css/bootstrap- 
datepicker.css" rel="stylesheet">

<script 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"> 
</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap- 
datepicker/1.5.0/js/bootstrap-         
datepicker.js"></script>
@endsection

2nd May, 2018

IT2704 started a new conversation How To Display The Average Rate Of "tarifs" For A Selected "tache" • 4 months ago

i have 2 tables the first tache 'id','libelle_tache' , 'tarif' and table tarification tache 'tache_id', 'tarif' .I would like to display in the interface tache.show the average rate of "tarifs" of this selected tache for all technicien.

@extends('Layouts/app')
@extends('Layouts.master')
@section('content')
@if(count($errors))
    <div class="alert alert-danger" role="alert">
 <ul>
    @foreach($errors ->all() as $message)
    <li>{{$message}}</li>
    @endforeach
    </ul>
    </div>
    @endif
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>



    <script type="text/javascript">

    var getMetiersByTechnicienUrl = "{{url('/metiersbytechnicien')}}";
var getTachesByMetierUrl = "{{url('/tachesbymetier')}}";

//console.log(getMetiersByTechnicienUrl,getTachesByMetierUrl,
getTarificationsByTacheUrl);
 function getMetiersByTechnicien(val) {
    if(val.length>0) {
    var technicien_id = val;
    $.get(getMetiersByTechnicienUrl+'/'+technicien_id,function(res) {
        var html = '<option value="">-Select-</option>' ;
        $.each(res.metiers,function(index,item) {
            html+='<option value="'+item.id+'">'+item.libelle_metier+'</option>';
        });
        $('#metiers').html(html);

    });
    }
 }
    function getTachesByMetier(val) {
     if(val.length>0) {
    var metier_id = val;
    $.get(getTachesByMetierUrl+'/'+metier_id,function(res) {
        var html = '<option value="">-Select-</option>' ;
        $.each(res.taches,function(index,item) {
            html+='<option value="'+item.id+'">'+item.libelle_tache+'</option>';
        });
        $('#taches').html(html);

    });
    }
    }

    </script>
    <div class="container">
    <div class="row"></div>
    <div class="col-md-12">
    Z
    <div class="col-md-10">
    <h1>Tarification tache</h1>
    <form action=" {{url ('tarification')  }}" method="post">
     {{csrf_field()}}

    <div class="form-group">
     <label for="technicien">Technicien</label>
        <select onchange="getMetiersByTechnicien(this.value)" name="technicien_id" 
    id="technicien" class="form-control">
            <option value="">-Select-</option>
            @foreach($technicien as $t)
                <option value="{{$t->id }}">
                    {{$t->user->nom}}
                </option>
            @endforeach
        </select>
        </div>
        <div class="form-group">
        <div class="col-md-12">
            <div class="col-md-4">
        <label>Metier: </label>
        <select onchange="getTachesByMetier(this.value)" style="width: 200px"    
        class="productm form-control" id="metiers">
         <option value="">-Select-</option>


        </select>
            </div>
            <div class="col-md-4">
                <label>tache: </label>
                <select style="width: 200px" class="productname form-control" 
    name="tache_id" id="taches">
                    <option value="">-Select-</option>
                </select>
            </div>
            <div class="col-md-4">
                <label>tarification: </label>
                <input style="width: 200px" class="productname form-control" type="text"  
name ="Tarif" class="form-control" value="{{old('tarif')}}">
                   
                
            </div>


        </div>
        </div>
        <div class="form-group">
        <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
         </div>
        </div>
        </div>
     </div>

@endsection
tarificationcontroller:

<?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use App\tarificationtache;
    use App\technicien;
    use App\tache;
    use App\metier;

    class TarificationController extends Controller
{
    /**
    * Display a listing of the resource.
    *
    * @return \Illuminate\Http\Response
    */
    public function index()
 {
    $Listtache=tache::orderBy('libelle_tache')->get();
    $Listtarification=tarificationtache::all();
    return view('tarification.index',['tarification'=>$Listtarification]);
}

/**
    * Show the form for creating a new resource.
 *
    * @return \Illuminate\Http\Response
    */
    public function create()
    
    $technicien = technicien::orderBy('id','desc')->get();
    $taches = Tache::orderBy('libelle_tache', 'asc')->get();
    $metiers = Metier::orderBy('libelle_metier', 'asc')->get();
    return view('tarification.create')->with('taches', $taches)->with('technicien', $technicien)- 
    >with('metiers', $metiers);
}

/**
* Store a newly created resource in storage.
*
* @param  \Illuminate\Http\Request  $request
*@return \Illuminate\Http\Response
*/
public function store(Request $request)
{

    $tarification = new tarificationtache();
    $tarification ->tache_id = $request->input('tache_id');
    $tarification ->Tarif =$request->input('Tarif');
    $tarification->save();
    $tarification->techniciens()->attach($request->technicien_id);
    return redirect('technicien');  }

/**
    * Display the specified resource.
    *
    * @param  int  $id
    * @return \Illuminate\Http\Response
    */
    public function show($id)
    {
    //
    }

    /**
    * Show the form for editing the specified resource.
    *
    * @param  int  $id
    * @return \Illuminate\Http\Response
    */
    public function edit($id)
    {
$tache=Tache::find($id);
 return view('tache.edit',['libelle_tache'=>$tache],['Tarif'=>$tache],['metier_id'=>$tache]);
    }

    /**
* Update the specified resource in storage.
*
* @param  \Illuminate\Http\Request  $request
* @param  int  $id
* @return \Illuminate\Http\Response
*/
    public function update(Request $request, $id)
    {
    //
}

/**
    * Remove the specified resource from storage.
    *
* @param  int  $id
    * @return \Illuminate\Http\Response
    */
public function destroy($id)
{
    $tache =Tache::find($id);
    $tache->delete();

 return redirect('tache');
}
public function getTarificationsByTache($tache_id)
    {
    $t =tache::find($tache_id);
    return response()->json(['tarifications' => $t->tarificationtache]);
    }

IT2704 left a reply on How To Autofill Form With Id From The Previous Form • 4 months ago

@danielec81 thank you for your help. Could you please explain me more how i could call getMetiersByTechnicien({{$technicien_id}}).. because trying this i've got "Undefined variable: technicien_id (View: C:\xampp\htdocs\projet\resources\views\tarification\create.blade.php)" knowing that i have many tomany relation between "technicien" and "tarification" Thanks again

30th April, 2018

IT2704 started a new conversation How To Autofill Form With Id From The Previous Form • 4 months ago

I'm trying to autofill form with id of techinician from the previous form after clicking add button

@extends('Layouts/app') @extends('Layouts.master') @section('content') @if(count($errors))

@endif

<script type="text/javascript">

var getMetiersByTechnicienUrl = "{{url('/metiersbytechnicien')}}";
var getTachesByMetierUrl = "{{url('/tachesbymetier')}}";

//console.log(getMetiersByTechnicienUrl,getTachesByMetierUrl, getTarificationsByTacheUrl); function getMetiersByTechnicien(val) { if(val.length>0) { var technicien_id = val; $.get(getMetiersByTechnicienUrl+'/'+technicien_id,function(res) { var html = '-Select-' ; $.each(res.metiers,function(index,item) { html+=''+item.libelle_metier+''; }); $('#metiers').html(html);

        });
    }
}

function getTachesByMetier(val) { if(val.length>0) { var metier_id = val; $.get(getTachesByMetierUrl+'/'+metier_id,function(res) { var html = '-Select-' ; $.each(res.taches,function(index,item) { html+=''+item.libelle_tache+''; }); $('#taches').html(html);

        });
    }
 }

</script>
Z

Tarification tache

{{csrf_field()}}
    <div class="form-group">
        <label for="technicien">Technicien</label>
            <select onchange="getMetiersByTechnicien(this.value)" name="technicien_id" 
 id="technicien" class="form-control">
                <option value="">-Select-</option>
                @foreach($technicien as $t)
                    <option value="{{$t->id }}">
                        {{$t->user->nom}}
                    </option>
                @endforeach
            </select>
    </div>
    <div class="form-group">
        <div class="col-md-12">
                <div class="col-md-4">
        <label>Metier: </label>
        <select onchange="getTachesByMetier(this.value)" style="width: 200px"    
class="productm form-control" id="metiers">
             <option value="">-Select-</option>


        </select>
                </div>
                <div class="col-md-4">
                    <label>tache: </label>
                    <select style="width: 200px" class="productname form-control" 
name="tache_id" id="taches">
                        <option value="">-Select-</option>
                    </select>
                </div>
                <div class="col-md-4">
                    <label>tarification: </label>
                    <input style="width: 200px" class="productname form-control" type="text"  

name ="Tarif" class="form-control" value="{{old('tarif')}}">

                </div>


            </div>
            </div>
            <div class="form-group">
            <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
        </div>
        </div>
            </div>
        </div>

@endsection

tarificationcontroller:

 <?php
 namespace App\Http\Controllers;
 use Illuminate\Http\Request;
 use App\tarificationtache;
 use App\technicien;
 use App\tache;
 use App\metier;

 class TarificationController extends Controller
 {
 /**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
 public function index()
{
$Listtache=tache::orderBy('libelle_tache')->get();
$Listtarification=tarificationtache::all();
return view('tarification.index',['tarification'=>$Listtarification]);
}

/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $technicien = technicien::orderBy('id','desc')->get(); $taches = Tache::orderBy('libelle_tache', 'asc')->get(); $metiers = Metier::orderBy('libelle_metier', 'asc')->get(); return view('tarification.create')->with('taches', $taches)->with('technicien', $technicien)- >with('metiers', $metiers); }

/**

  • Store a newly created resource in storage.

  • @param \Illuminate\Http\Request $request

  • @return \Illuminate\Http\Response */ public function store(Request $request) {

    $tarification = new tarificationtache(); $tarification ->tache_id = $request->input('tache_id'); $tarification ->Tarif =$request->input('Tarif'); $tarification->save(); $tarification->techniciens()->attach($request->technicien_id); return redirect('technicien'); }

/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // }

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
 public function edit($id)
{
$tache=Tache::find($id);
return view('tache.edit',['libelle_tache'=>$tache],['Tarif'=>$tache],['metier_id'=>$tache]);
 }

/**

  • Update the specified resource in storage.
  • @param \Illuminate\Http\Request $request
  • @param int $id
  • @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // }

/** * Remove the specified resource from storage. *

  • @param int $id

    • @return \Illuminate\Http\Response */ public function destroy($id) { $tache =Tache::find($id); $tache->delete();

    return redirect('tache'); } public function getTarificationsByTache($tache_id) { $t =tache::find($tache_id); return response()->json(['tarifications' => $t->tarificationtache]); }

29th March, 2018

IT2704 started a new conversation I'm Trying To Do Autocomplete Search With Laravel, With The Code Below I Don't Get Any Error But Nothing Happens • 5 months ago

metiercontroller.php

 public function index()
{
$Listmetier=metier::all();
return view('metier.index');
}

 public function search(Request $request)
 {
 if ($request->ajax()) 
 {
 $output="";
 $metiers = $metiers->where('libelle_metier', 'like', '%' . $search . '%')
    ->orderBy($id, $sort)
    ->paginate(5)
    ->withPath('?search=' . $search . '&gender=' . $gender . '&field=' . $id . '&sort=' . $sort);
    if ($metiers)
    {
        foreach ($metiers as $key => $metiers) {
        $output.='<tr>'.
                '<td>'.$metiers->id.'</td>'.
                '<td>'.$metiers->libelle_metier.'</td>'.
                '</tr>';   
    }
    return Response($output);
    }else
    {
        return Response()->json(['no'=>'not found']);
    }
  }
}

index.blade.php

@extends('Layouts.app')

@extends('Layouts.master') @section('content')

Metier

Liste des Metiers Ajouter Metier libelle metier //////////
</div>
<script type="text/javascript">
$('#search').on('keyup',function){
    $value=$(this).val();
    $.ajax({
        type: 'get',
        url : '{{URL::to('search')}}',
        data : {'search':$value},
        success:function(data){
            $('tbody').html(data);
        } 
    });
  }
@endsection route.php

Route::get('/metier', '[email protected]'); Route::get('/metier/search', '[email protected]');

28th March, 2018

IT2704 left a reply on Search Whith Laravel • 5 months ago

@zymawy Thank you :)) do you suggest a good tuto that i could follow?

IT2704 left a reply on Search Whith Laravel • 5 months ago

@zymawy thank you but where should i add this please ?

IT2704 left a reply on Search Whith Laravel • 5 months ago

@zymawy no more errors now but nothing happens. I updated my index.blade.php please take a look

IT2704 left a reply on Search Whith Laravel • 5 months ago

@zymawy i still get exactly the same error

IT2704 left a reply on Search Whith Laravel • 5 months ago

@zymawy thank you for your quick response . trying this I got this error "Parse error: syntax error, unexpected '$search' (T_VARIABLE), expecting ';' or '{'"

IT2704 started a new conversation Search Whith Laravel • 5 months ago

I would like to search on the index page (in a table) I tried with this code but did not work can someone help me

route.php

Route::get('/metier', '[email protected]');
Route::get('/metier/search', '[email protected]');
metiercontroller

public function index()
{
$Listmetier=metier::all();
return view('metier.index',['metier'=>$Listmetier]);
}
public function search(Request $request)
{     
if($request->ajax())
{
$output="";
$metiers=DB::table('metiers')->where('libelle_metier','LIKE','%'.$request->search."%")-
>get();
if($metiers)
{
    foreach ($metiers as $key => $metiers) {
    $output.='<tr>'.
    '<td>'.$metiers->id.'</td>'.
    '<td>'.$metiers->libelle_metier.'</td>'.
    '</tr>';
 }
 return Response($output);
 }
}

index.blade.php

@extends('Layouts.app')
@extends('Layouts.master')
@section('content')
<link rel="stylesheet" type="text/css"     
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

Metier

Liste des Metiers Ajouter Metier
            <head>
            <tr>
                <th>libelle metier</th>
                <th>Action</th>
                
            </tr>
            </head>
            <body>
           
            </body>
        </table>

    </div>
    <script type="text/javascript">
        $('#search').on('keyup',function){
            $value=$(this).val();
            $.ajax({
                type: 'get',
                url : '{{URL::to('search')}}',
                data : {'search':$value},
                success:function(data){
                    console.log(data);
                } 
            });
        }
    </script>
</div>
</div>
@endsection

28th February, 2018

IT2704 left a reply on How To Autofill Edit Form With Old Information From Two Different Tables? • 6 months ago

I have two tables technicien and user with hetitage and one to one conenction. When i try to edit a technician i would like the edit form to be autofilled with information of a technicien those information will be retreived from the two tables technicien and user. How could i do this please?

IT2704 started a new conversation Dropdown List • 6 months ago

How to make a dropdown list suggest only options in relation with a selected value?

In my form i have two dropdown lists the first one to choose "metier" and a second one to choose "tache" when i choose a "metier" i want that the second dropdown list "tache" suggest only options in relation with the already selected "Metier". Could anyone help me with this please.

create.blade.php

@extends('Layouts/app') @extends('Layouts.master') @section('content') @if(count($errors))

@endif

Tarification tache

{{csrf_field()}}

        <div class="form-group">
            <label for="technicien">Technicien</label>
            <select name="technicien_id" id="technicien" class="form-control" >

                    @foreach($techniciens as $techniciens)
                     <option value="{{ $techniciens->id }}">
                        {{$techniciens->id}}
                     </option>
                    @endforeach
            </select>
        </div>
 ////////////
        {{Form::open(array('url'=>'','files'=>true))}}
        <div class="form-group">
            <label for="metier">Libelle metier</label>
            <select name="metier" id="metier" class="form-control">

                    @foreach($metiers as $metier)
                     <option value="{{ $metier->id }}">
                        {{$metier->libelle_metier}}
                     </option>
                    @endforeach
            </select>
        </div>

        <div class="form-group">
            <label for="Tache">Libelle Tache</label>
            <select name="tache" id="Tache" class="form-control">

                    @foreach($taches as $tache)
                     <option value="{{ $tache->id }}">
                        {{$tache->libelle_tache}}
                     </option>
                    @endforeach
            </select>
        </div>
        {{Form::close()}}

//////////////
        <div class="form-group">
            <label for="">Tarif</label>
            <input type="text"  name ="Tarif" class="form-control"value="{{old('tarif')}}">
        </div>
        <div class="form-group">
            <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
        </div>
    </form>
</div>
</div>
$('#metier').on('change',function(e){ console.long(e); var met_id = e.target.value;
    $.get('/ajax-tac?met_id=' + met_id, function(data){
        $('#tache').empty();
        $.each(data,function(index, tacObj){
            $('#tache').append('<option value="'+tacObj.id+'">'+catObj.libelle_tache+'</option>');
        });

    });

});

@endsection route.php

Route::get('/tarification', '[email protected]'); Route::get('/tarification/create', '[email protected]'); Route::post('/tarification', '[email protected]'); Route::get('/tarification/{id}/edit', '[email protected]'); Route::put('/tarification/{id}', '[email protected]'); Route::delete('/tarification/{id}', '[email protected]');

Route::get('/ajax-metier',function(){
    $met_id = Input::get('met_id');
    $taches = tache::where('metier_id','=', $met_id)->get();
    return Response::json($metiers);
});

controller

public function create()
{
$techniciens = technicien::orderBy('id','desc')->get();
$taches = Tache::orderBy('libelle_tache', 'asc')->get();
$metiers = Metier::all();
return view('tarification.create')->with('taches', $taches)->with('techniciens', $techniciens)-
>with('metiers', $metiers);
}

 /**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
$tarification = new tarificationtache();

$tarification ->tache_id = $request->input('tache_id');
$tarification ->Tarif =$request->input('Tarif');
$tarification->save();
$tarification->techniciens()->attach($request->technicien_id);
return redirect('home');
}

IT2704 started a new conversation Autofill • 6 months ago

How to autofill Edit form with old Information from two different tables?

I have a form "Edit tache". Editing one "tache" affects two tables "user" and "technicien", when i choose to edit "tache" the form is autofilled with information from the technicien table but the fields related to the table user are not autofilled. How could i autofill the form with information from the two tables? Thank you.

controller

public function edit($id) { $technicien=technicien::find($id); $user = user::orderBy('id', 'asc')->get(); return view('technicien.edit',['moyenne_avis'=>$technicien],['actif'=>$technicien],['user_id'=>$technicien])->with('users', $user ); }

public function update(Request $request, $id) { // do some request validation $technicien=technicien::find($id); $technicien->update($request->all()); return redirect('technicien'); }

View

@extends('Layouts/app') @extends('Layouts.master') @section('content')

Modifier Tache

{{csrf_field()}} {{ method_field('PATCH') }}
        <div class="form-group">
            <label for="">Nom</label>
            <input id="nom" type="text" class="form-control" name="nom" value="{{ old('nom') ? old('nom') : $actif->nom }}" required autofocus>
        </div>
        <div class="form-group">
            <label for="">Prenom</label>
            <input id="nom" type="text" class="form-control" name="nom" value="{{ old('nom') ? old('nom') : $actif->nom }}" required autofocus>
        </div>

        <div class="form-group">
            <label for="">moyenne Avis</label>
            <input type="text"  name ="moyenne_avis" class="form-control"value ="{{$moyenne_avis->moyenne_avis}}" >
        </div>
        <div class="form-group">
            <label for="">Etat Technicien</label>
            <input type="text"  name ="actif" class="form-control"value ="{{$actif->actif}}" >
        </div>



        <div class="form-group">

            <input type="submit" value = "enregistrer" class="form-control btn btn-primary">
        </div>
    </form>
</div>
@endsection

route

Route::get('/technicien/{id}/edit', '[email protected]'); Route::put('/technicien/{id}', '[email protected]')-

name('technicien.update');

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.