Hello guys. Pardon me for having a help topic as a first post but
I have a problem with fetching mails. I have customized the ticket table for the requirements of the client. I have also customized the create() function in class.tickets.php for its database transaction. I can create tickets via e-mails just fine when I take out my modified database transaction for it, but I can't get it to work with the custom logic.
I've been going with this for hours and the problem still persists so I'm turning to you guys. I'm not particularly asking for code, although it may be nice, but assisstance on how I would tackle the problem would be greatly appreciated
Thank you in advance for your help
class.config.php
function create($var,&$errors,$origin,$autorespond=true,$alertstaff=true) {
global $cfg,$trl,$thisclient,$_FILES;
/* Coders never code so fully and joyfully as when they do it for free - Peter Rotich */
$id=0;
$fields=array();
$fields = array('type'=>'string', 'required'=>1, 'error'=>$trl->translate('ERROR_NAME_REQUIRED'));
$fields = array('type'=>'email', 'required'=>1, 'error'=>'Valid email required');
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Subject required');
$fields = array('type'=>'text', 'required'=>1, 'error'=>$trl->translate('ERROR_MESSAGE_REQUIRED'));
if(strcasecmp($origin,'web')==0) { //Help topic only applicable on web tickets.
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Select help topic');
}elseif(strcasecmp($origin,'staff')==0){ //tickets created by staff...e.g on callins.
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required');
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Indicate source');
$fields = array('type'=>'date', 'required'=>0, 'error'=>'Invalid date - must be MM/DD/YY');
}else { //Incoming emails
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Email unknown');
}
$fields = array('type'=>'int', 'required'=>0, 'error'=>'Invalid Priority');
$fields = array('type'=>'phone', 'required'=>0, 'error'=>'Valid phone # required');
if(!($origin == 'Email')){
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Address Required');
//and so on
}
...
/We are ready son...hold on to the rails.
$extId=Ticket:();
if($origin == 'Email'){
$date = 0000-00-00;
$address = "no address";
$invNo = 0;
$assetId = 0;
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
',ticketID='.db_input($extId).
',dept_id='.db_input($deptId).
',topic_id='.db_input($topicId).
',priority_id='.db_input($priorityId).
',email='.db_input($var).
',name='.db_input(Format:($var)).
',subject='.db_input(Format:($var)).
',helptopic='.db_input(Format:($topicDesc)).
',phone="'.db_input($var,false).'"'.
',phone_ext='.db_input($var?$var:'').
',ip_address='.db_input($ipaddress).
',source='.db_input($source).
',address='.db_input($address).
',invoiceNumber='.db_input($invNo).
',datePurchase='.$date.
',asset_id='.db_input($assetId);
}else{
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
',ticketID='.db_input($extId).
',dept_id='.db_input($deptId).
',topic_id='.db_input($topicId).
',priority_id='.db_input($priorityId).
',email='.db_input($var).
',name='.db_input(Format:($var)).
',subject='.db_input(Format:($var)).
',helptopic='.db_input(Format:($topicDesc)).
',phone="'.db_input($var,false).'"'.
',phone_ext='.db_input($var?$var:'').
',ip_address='.db_input($ipaddress).
',source='.db_input($source).
',address='.db_input($var).
',invoiceNumber='.db_input($var).
',datePurchase='.($var?db_input(date('Y-m-d G',Misc:($var.' 00'))):'NULL').
',asset_id='.$var;
}
error log in /api/error.txt
PHP Warning: Invalid argument supplied for foreach() in /home/xxx/xxx/osticket/include/class.mailfetch.php on line 126