skip to content

API - Add New Jobcard

URL: GenerateNewJobcard.php

JSON Option (recommended):

to use as JSON, append ?apiformat=json to the URL, then send through all variables as a JSON encoded string.

Required Fields:

username
password
status - string matching one of your jobcard statusses exactly

ClientID or these client related fields:

client_invoice_name (255 characters max)
client_email (255 characters max)

Optional Client Related Fields (If no ClientID is supplied):

client_vat_nr (255 characters max)
client_phone_nr (20 characters max)
client_phone_nr2 (20 characters max)
client_fax_nr (20 characters max)
client_postal_address1 (255 characters max)
client_postal_address2 (255 characters max)
client_postal_address3 (255 characters max)
client_postal_address4 (255 characters max)

Optional Fields:

The data array is your line items

data[$i][0] - prod_code
data[$i][1] - qty
data[$i][2] - description
data[$i][3] - amount
data[$i][4] - currency //As indicated under Settings -> Currencies. ZAR usually for SA businesses.
data[$i][5] - vat_applies //1 or 0
data[$i][6] - vat_percentage //decimal(20,2)
data[$i][7] - amount_includes_vat //1 or 0

BookedInItems[$i][0] - prod_code
BookedInItems[$i][1] - qty
BookedInItems[$i][2] - description
BookedInItems[$i][3] - problem
BookedInItems[$i][4] - serial number
BookedInItems[$i][5] - optional array of base64 encoded images

Note that Booked Out Items functionality must be enabled under Settings -> Documents -> Jobcards -> Enable Booked Out functionality.

BookedOutItems[$i][0] - prod_code
BookedOutItems[$i][1] - qty
BookedOutItems[$i][2] - description
BookedOutItems[$i][3] - notes
BookedOutItems[$i][4] - serial number
BookedOutItems[$i][5] - optional array of base64 encoded images

OrderNr (10 characters max)
AdditionalValue1 (32 characters max) //These are custom fields as specified under Settings -> Documents -> Invoices -> Custom Fields. Note that the amount you can use is limited by your account type.
AdditionalValue2 (32 characters max)
AdditionalValue3 (32 characters max)
AdditionalValue4 (32 characters max)
AdditionalValue5 (32 characters max)
AdditionalValue6 (32 characters max)
AdditionalValue7 (32 characters max)
AdditionalValue8 (32 characters max)
AdditionalValue9 (32 characters max)
AdditionalValue10 (32 characters max)
DiscountAmount (decimal(20,2))
DiscountPercentage (decimal(20,2))
prepend_nr (9 characters max)
append_nr (9 characters max)
EmailToClient (true or false)
data[$i][8] - custom_line_item_1 //as defined under Settings -> Documents -> Jobcards -> Custom Line Items
data[$i][9] - custom_line_item_2
data[$i][10] - custom_line_item_3
data[$i][11] - //not implemented
data[$i][12] - //not implemented
data[$i][13] - discount_percentage //Discount percentage only applicable for this line item. Ignored if Document has a discount percentage specified.
data[$i][14] - custom_line_item_4
data[$i][15] - custom_line_item_5

Returns:

JSON array containing:

$array[url] - the url where the document can be downloaded
$array[jobcard_nr] - the jobcard number
$array[document_nr] - the jobcard number
$array[document_id] - the global document id
$array[email_url] - url to open to have the document emailed to the client

Example PHP code

$param['username'] = '';
$param['password'] = '';
$param['ClientID'] = '';
$param['status'] = '';
$param['data'][0][0] = ''; //first product
$param['data'][0][1] = ''; 
$param['data'][0][2] = '';
$param['data'][0][3] = '';
$param['data'][0][4] = '';
$param['data'][0][5] = '';
$param['data'][0][6] = '';
$param['data'][0][7] = '';
$param['BookedInItems'][0][0] = ''; //booked in item
$param['BookedInItems'][0][1] = '';
$param['BookedInItems'][0][2] = '';
$param['BookedInItems'][0][3] = '';
$param['BookedInItems'][0][4] = '';
$param['BookedInItems'][0][5] = '';

	
$url = 'https://www.jobcardsonline.co.za/api/GenerateNewJobcard.php?apiformat=json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //set the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return as a variable
curl_setopt($ch, CURLOPT_POST, 1); //set POST method
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param)); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response

 

Updated: Fri, 16 October 2020