jeudi 17 mai 2018

How to display a table in a popup box?

I have the form below, with 4 comboboxes "Metier=profession" "tache=task" "tacrification=pricing" et "technicien=technician", 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.) please see the second form.After this i select a "technician" from that table a now the form is completely filled with the "technician" and it's "pricing". Could anyone help me with this please?

enter image description here

what i'm trying to do enter image description here

intervention

    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();
    });

tarificationtache

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->datetime('deleted_at')->nullable();
         $table->timestamps();
          });

Intervention extends Model

class Intervention extends Model
{
protected $fillable = [ ];
protected $guarded = [];

public function avisintervention()
{
    return $this->hasMany(AvisIntervention::class);
}

public function technicien()
{
    return $this->belongsTo(technicien::class);

}

public function client()
{
    return $this->belongsTo(Client::class);

}
 public function tarificationtache()
{
return $this->belongsTo('App\Tarificationtache','tarification_id');

}

class tache extends Model

class tache extends Model
{
use SoftDeletes;
protected $guarded = [];
 protected $dates = ['deleted_at'];

public function metier()
{
    return $this->belongsTo(Metier::class);
}

public function tarificationtache()
{
    return $this->hasMany(Tarificationtache::class);
}

}

class metier extends Model

class metier extends Model 
{
use SoftDeletes;
protected $guarded = [];
 protected $dates = ['deleted_at'];
public function taches()
{
    return $this->hasMany(Tache::class);
}
public function techniciens()
{
    return $this- 
    >belongsToMany('App\technicien','technicien_zone','metier_id','technicien_id');

}
}

class tarificationtache extends Model

class tarificationtache extends Model
{
use SoftDeletes;
protected $guarded = [];
 protected $dates = ['deleted_at'];
public function tache()
{
    return $this->belongsTo(Tache::class);
}


public function techniciens()
{
    return $this->belongsToMany('App\technicien','technicien_tarificationtache','tarificationtache_id','technicien_id');

}
public function intervention() {
    return $this->hasMany(intervention::class);
}

}

intervention controller

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 ->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');

    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire