Hello evryone, i try to integrate dhtmlxScheduler with laravel 5.
I had succed to load data from DB, but i can’t add or udate the event, I log my script tying to get the problemee, and i have no errors.
the probleme is in the [[ conn->event->attach(“beforeInsert”,“insert_data”); ]] I coud not call the function “insert_data” after been attached with “event->attach”, this is my code
(Client side)=> scheduler.load("/load");
var dp = new dataProcessor("/save");
dp.init(scheduler);
(server side)=>the controller
<?php namespace App\Http\Controllers; require_once "codebase/connector/scheduler_connector.php"; require_once "codebase/connector/db_pdo.php"; class DhtmlxConnectorController extends Controller { /** * Event Model * @var Event */ protected $events; protected $res; protected $conn; protected $last_event_id; protected $agendas; protected $prestations; public function __construct() { $this->init(); } public function getIndex() { return view('scheduler/index'); } /** * Loads all events. * * @return events */ public function init() { __logthis("init"); $this->res = new \PDO('mysql:host=localhost;dbname=schedulerDB','root',''); $this->conn = new \SchedulerConnector($this->res,"PDO"); } public function load(){ $this->conn->render_sql("select * from events"); } /** * Saves events. * * @return events */ public function save(){ $this->init(); $this->conn->event->attach("beforeInsert","insert_data"); $this->conn->render_sql("select * from events"); } public function insert_data($data){ __logthis("call insert"); $nom=$data->get_value("nom"); $prenom=$data->get_value("prenom"); $this->conn->sql->query("insert into users(nom,prenom) values('{$nom}' , '{$prenom}')"); $user_id=mysql_insert_id(); $start=$data->get_value("start_date"); $end=$data->get_value("end_date"); $txt=$data->get_value("text"); $important=$data->get_value("important"); $agenda_id=$data->get_value("agenda_id"); $prestation_id=$data->get_value("prestation_id"); $this->conn->sql->query("insert into events(start_date,end_date,text,user_id,agenda_id,prestation_id,important) values('{$start}' , '{$end}' , '{$txt}' , {$user_id} , {$agenda_id} , {$prestation_id} , {$important})"); $this->last_event_id=mysql_insert_id(); $data->success(); } }