Dhtmlx load data into dropdown - php

I'm using Dhtmlx scheduler and it works really fine, but I have some issue with customization of the LightBox. I have added a dropdown list and I would like to load data from my MySqli db using json.
Here is my code
require_once('codebase/connector/scheduler_connector.php');
require("codebase/connector/db_mysqli.php");
$mysqli = new mysqli("$db", "$dbn", "$pw", "$tb");
$listcollab = new OptionsConnector($mysqli, "MySQLi");
$listcollab->render_table("Operator","ID","ID(value),Name(label)");
$scheduler = new JSONSchedulerConnector($mysqli, "MySQLi");
$scheduler->set_options("coll", $listcollab); //without this scheduler charge data
$scheduler->render_table("Agenda","ID","AppStart,AppEnd,Cliente,Servizio");
This is Client side
var list = scheduler.serverList("coll");
function init() {
scheduler.config.xml_date = "%Y-%m-%d %H:%i";
scheduler.config.prevent_cache = true;
scheduler.config.first_hour = 8;
scheduler.config.last_hour = 21;
scheduler.config.limit_time_select = true;
scheduler.locale.labels.section_location = "Servizio";
scheduler.locale.labels.section_select = 'Seleziona';
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.prevent_cache = true;
scheduler.config.lightbox.sections = [
{name:"CLIENTE", height:90, map_to:"Cliente", type:"textarea" , focus:true},
{name:"Servizio", height:43, type:"textarea", map_to:"Servizio" },
{name:"select", height:40, map_to:"ID", type:"select", options:scheduler.serverList(list)},
{name:"Collaboratore", height:43, type:"textarea", map_to:"auto" },
{name:"Orario", height:72, type:"time", map_to:"auto"}
];
scheduler.init('scheduler_here', new Date(2015, 9, 23), "week");
scheduler.load("connessione.php", 'json');
var dp = new dataProcessor("connessione.php");
dp.init(scheduler);
Can someone helps me to get data from db using php?
Thanks in advance

What you use on server side? If you have PHP and dhtmlxConnector on a backend, this article should help.
If you've implemented data loading manually then you'll need these two methods:
http://docs.dhtmlx.com/scheduler/api__scheduler_serverlist.html
http://docs.dhtmlx.com/scheduler/api__scheduler_updatecollection.html
The common way to go is following - you declare options as named collection using scheduler.serverList method, and then update using scheduler.updateCollection when data is loaded from the server

Related

How to run an independent PHP script in Laravel?

I am new to laravel and PHP, so I apologize if something similar is asked before which I couldn't find as per my needs. I have an independent PHP script in public folder:
define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS','');
define('DB_NAME','fyp');
define('API_ACCESS_KEY', 'AAAAk4V5b8k:APA91bFUo5crCI-gmfhlB9znAWpxdy9bdvA-29VBgLdRmQtYvjNuUe4xi7lkmyAmTOuhuCaaSphaGTvULTq6oREJEUwNNRBW9AKiadl9zzjbXFnEwINlfJzGFIpZojWim2cTT2D7rKJz');
//$registrationIds = 'f4tul16ETjK6wR64Nix7HO:APA91bGPa4ijApEp_vrDcAr-NEzUU-WcovjLhpxtwSiNv94aZ-aOMVek0AbTHNFHCmwZrXOzeqocFglWOlABWcjcDXnDdmh2qEsIgh0X7MkXcN_YD6qBREP5QyS1WlGn27qGiyYTdpoV';
$id = $_POST['id'];
$status = $_POST['status'];
$case_id = $_POST['case_id'];
What I want is to pass the values to this script and execute when I press a button on my page e.g.
When I press save, the following function in the controller executes:
public function storedetail(Request $req, $id)
{
$detail = Detail::firstOrNew(['case_id' => $id,]);
$detail->lawyerName = $req->input('lawyerName');
$detail->event = $req->input('proc_type');
$detail->room = $req->input('room');
$detail->eventDate = $req->input('date');
$detail->status = 1;
// $data = Cases::find($id);
$detail->case_id = $id;
// $data->details()->save($detail);
$detail->save();
return redirect()->back();
}
What is the simplest way to pass the id, status and case_id to the PHP script and execute it?
As per I understand you just need to pass data from laravel controller to separate php file.
just pass all the parameters to the specific file path.
ex : xyz.com/public/phpfile.php?id=123&status=abc&case_id=45

Navigating forms and grabbing DOM-Elements from a website using Guzzle/Goutte (PHP, Debugging)

I'm fairly new to PHP and playing around with Goutte/Guzzle to grab some basic information from a website after filling out a few forms.
However I have problems finding issues (there might be a ton of them) since I could not find a way to display or console log any of the results or problems. The script finishes with Code 0 but does not return anything. A tip on how to print out what is currently stored in $client would already go a long way.
Here is the whole code I'm trying to run with a bunch of comments for clarification. I'm sorry for using such a large block, but any of this could have issues.
<?php
use Goutte\Client;
use GuzzleHttp\Client as GuzzleClient;
class grabPlate
{
// WKZ
public function checkPlate
{
$goutteClient = new Client();
$guzzleClient = new GuzzleClient(array(
'cookies' => true,
'timeout' => 60,
));
$goutteClient->setClient($guzzleClient);
$crawler = $goutteClient->request('GET', 'https://kfz-portal.berlin.de/kfzonline.public/start.html?oe=00.00.11.000000');
//Click the first "Start" in the top left
$link = $crawler
->filter('a:contains("Start")')
->eq(0)
->link()
;
$crawler = $client->click($link);
//Check checkbox, fill in name and press the button
$buttonCrawlerNode = $crawler->selectButton('Weiter');
$form = $buttonCrawlerNode->form();
$form['gwt-uid-1']->tick();
$form['select2-hidden-accessible']->select('Herr');
$form['gwt-uid-4'] = 'John';
$form['gwt-uid-5'] = 'Doe';
$client->submit($form);
//Fill some Data into the forms and search
$buttonCrawlerNode = $crawler->selectButton('Button-3616');
$form = $buttonCrawlerNode->form();
$form['.kfzonline-KennzeichenGrossEb'] = 'AB';
$form['.kfzonline-KennzeichenGrossEn'] = '123';
$client->submit($form);
//Extract collection
$info = $crawler->extract('.collection');
//return 1 if something is inside collection, 0 if it's empty
if($info == NULL) {
return 1;
} else {
return 0;
}
}
}
?>
As I said just running the script in PHPStorm returns the status 0. However when plugging it into an API and accessing it, I get a server timeout response.
You should either use a Debugging. Install xDebug to do so in PHP. This is also easy to integrate into Phpstorm.
Alternatively use var_dump() for printing out debug information about variables of any type to console.
You can display the requested page inside your php page, you have to add this snippet :
$client = new GuzzleHttp\Client();
$res = $client->request('GET', 'https://www.facebook.com/');
echo $res->getBody();

Uploading An Image As A ByteArray to a Blob using AS3 & AMFPHP

I'm currently having a bit of an issue when I try to upload a photo taking using an iOS camera to a MySQL database using PHP and unfortunately have been unable to find the right help online.
Basically The User takes a photo on their iOS device and I take that raw MediaPromise and put it into a ByteArray. I then call a PHP function using AMFPHP to add the binary to a Blob in my database. But when I test the whole thing, it never seems to work. Could somebody maybe help me with this problem or at least point me in the right direction? It would be highly appreciated. Here's the code:
AS3:
var dataSource:IDataInput;
function imageSelected1(event:MediaEvent) {
var imagePromise:MediaPromise = event.data;
dataSource = imagePromise.open();
if( imagePromise.isAsync ) {
var eventSource:IEventDispatcher = dataSource as IEventDispatcher;
eventSource.addEventListener( Event.COMPLETE, onDataComplete );
}
else {
readMediaData();
}
}
// PHP Connection //
// Database //
var gw2:NetConnection = new NetConnection();
gw2.connect(connectiongoeshere);
// Responder //
var pictureresponder:Responder = new Responder(onpicture);
function onpicture(pictureobj:Object) {
gotoAndStop(1);
}
function onDataComplete( event:Event ):void {
readMediaData();
}
function readMediaData() {
var imageBytes:ByteArray = new ByteArray();
//dataSource.readBytes( imageBytes );
dataSource.readBytes(imageBytes);
gw2.call("class.setData", pictureresponder, imageBytes);
}
PHP:
function setData($ba) {
// Connecting to the database //
mysql_pconnect("hi", "hi", "hi");
mysql_select_db("hi");
$result = mysql_query("UPDATE users set profilepicture2 ='$ba->data' WHERE email= 'email#gmail.com'");
return $result;
}

How to generate entity id for GAE datastore in php?

i am trying to insert new entity using PHP client library into datastore, i am using datastore_connect.php file from this example, https://github.com/amygdala/appengine_php_datastore_example
I want to insert entity with auto id, not the name. I see that there is function setId(), but i dont know how to generate proper id. Whats the best practice in doing so?
Thanks
function createKeyForTestItem () {
$path = new Google_Service_Datastore_KeyPathElement();
$path->setKind("testkind");
$path->setName("testkeyname");
//$path->setId(??)
$key = new Google_Service_Datastore_Key();
$key->setPath([$path]);
return $key;
}
You can have Cloud Datastore generate the ID for you by populating the insertAutoId field on the mutation instead of the upsert field.
Here's a code snippet (adapted from the datastore_connect.php file you posted):
function create_key() {
$path = new Google_Service_Datastore_KeyPathElement();
$path->setKind("testkind");
// Neither name nor ID is set.
$key = new Google_Service_Datastore_Key();
$key->setPath([$path]);
return $key;
}
function create_entity() {
$entity = new Google_Service_Datastore_Entity();
$entity->setKey(create_key());
// Add properties...
return $entity;
}
function create_commit_request() {
$entity = create_entity();
$mutation = new Google_Service_Datastore_Mutation();
$mutation->setInsertAutoId([$entity]); // Causes ID to be allocated.
$req = new Google_Service_Datastore_CommitRequest();
$req->setMode('NON_TRANSACTIONAL');
$req->setMutation($mutation);
return $req;
}
If you're looking for a PHP library to take away most of the headache of Cloud Datastore, you could try my new library, which sits on top of the official google-api-php-client:
https://github.com/tomwalder/php-gds
And here's a sample code snippet to create an Entity with an auto-generated ID
$obj_book = new GDS\Entity();
$obj_book->title = 'Romeo and Juliet';
$obj_book->author = 'William Shakespeare';
$obj_book->isbn = '1840224339';
// Write it to Datastore
$obj_book_store->upsert($obj_book);
More code snippets and documentation on GitHub.

ActionScript error when attempting call method within PHP file

I have been following a flash tutorial online and I have created a simple flash interface. I am trying to retrieve data from my SQL database via a PHP file and display. I get the following error when I compile:
Error #1009: Cannot access a property or method of a null object reference
var variables1:URLVariables = new URLVariables();
var varSend1:URLRequest = new URLRequest("databaseCall.php");
varSend1.method = URLRequestMethod.POST;
varSend1.data = variables1;
var varLoader1:URLLoader=new URLLoader();
varLoader1.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader1.addEventListener(Event.COMPLETE,completeHandler1);
variables1.comType = "requestEntries";
varLoader1.load(varSend1);
function completeHandler1(event:Event):void{
if(event.target.data.returnBody ==""){
gbOutput_txt.text = "No data coming through";
} else{
gbOutput_txt.condenseWhite = true;
gbOutput_txt.htmlText = "" +event.target.data.returnBody;
}
}
My code exactly matches the code that is used within the tutorial. I have modified the php file to simply return "" so the issue almost definitely lies within the action script...I think :S The compiler falls over when he completeHandler1 function is called. What do you think could be causing this?
Thanks in advance.
You need to declare the completeHandler1 function before you attempt to use it anywhere else.
Here is your code modified to describe what I am talking about.
var variables1:URLVariables = new URLVariables();
var varSend1:URLRequest = new URLRequest("databaseCall.php");
varSend1.method = URLRequestMethod.POST;
varSend1.data = variables1;
function completeHandler1(event:Event):void{
if(event.target.data.returnBody ==""){
gbOutput_txt.text = "No data coming through";
} else{
gbOutput_txt.condenseWhite = true;
gbOutput_txt.htmlText = "" +event.target.data.returnBody;
}
}
var varLoader1:URLLoader=new URLLoader();
varLoader1.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader1.addEventListener(Event.COMPLETE,completeHandler1);
variables1.comType = "requestEntries";
varLoader1.load(varSend1);
Give this a try and let me know if it works.

Categories