[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 require_once ('config.php'); 12 require_once ('include/logging.php'); 13 require_once ('include/database/PearDatabase.php'); 14 require_once ('include/nusoap/nusoap.php'); 15 16 $log = &LoggerManager::getLogger('vtigerolservice'); 17 18 error_reporting(0); 19 20 $NAMESPACE = 'http://www.vtiger.com/products/crm'; 21 22 $server = new soap_server; 23 24 $server->configureWSDL('vtigerolservice'); 25 26 //ContactDetails SOAP Structure 27 $server->wsdl->addComplexType( 28 'contactdetail', 29 'complexType', 30 'struct', 31 'all', 32 '', 33 array( 34 'id' => array('name'=>'id','type'=>'xsd:string'), 35 'title' => array('name'=>'title','type'=>'xsd:string'), 36 'firstname' => array('name'=>'firstname','type'=>'xsd:string'), 37 'middlename' => array('name'=>'middlename','type'=>'xsd:string'), 38 'lastname' => array('name'=>'lastname','type'=>'xsd:string'), 39 'birthdate'=> array('name'=>'birthdate','type'=>'xsd:string'), 40 'emailaddress' => array('name'=>'emailaddress','type'=>'xsd:string'), 41 'jobtitle'=> array('name'=>'jobtitle','type'=>'xsd:string'), 42 'department'=> array('name'=>'department','type'=>'xsd:string'), 43 'accountname' => array('name'=>'accountname','type'=>'xsd:string'), 44 'officephone'=> array('name'=>'officephone','type'=>'xsd:string'), 45 'homephone'=> array('name'=>'homephone','type'=>'xsd:string'), 46 'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'), 47 'fax'=> array('name'=>'fax','type'=>'xsd:string'), 48 'mobile'=> array('name'=>'mobile','type'=>'xsd:string'), 49 'asstname'=> array('name'=>'asstname','type'=>'xsd:string'), 50 'asstphone'=> array('name'=>'asstphone','type'=>'xsd:string'), 51 'reportsto'=> array('name'=>'reportsto','type'=>'xsd:string'), 52 'mailingstreet'=> array('name'=>'mailingstreet','type'=>'xsd:string'), 53 'mailingcity'=> array('name'=>'mailingcity','type'=>'xsd:string'), 54 'mailingstate'=> array('name'=>'mailingstate','type'=>'xsd:string'), 55 'mailingzip'=> array('name'=>'mailingzip','type'=>'xsd:string'), 56 'mailingcountry'=> array('name'=>'mailingcountry','type'=>'xsd:string'), 57 'otherstreet'=> array('name'=>'otherstreet','type'=>'xsd:string'), 58 'othercity'=> array('name'=>'othercity','type'=>'xsd:string'), 59 'otherstate'=> array('name'=>'otherstate','type'=>'xsd:string'), 60 'otherzip'=> array('name'=>'otherzip','type'=>'xsd:string'), 61 'othercountry'=> array('name'=>'othercountry','type'=>'xsd:string'), 62 'description'=> array('name'=>'description','type'=>'xsd:string'), 63 'category'=> array('name'=>'category','type'=>'xsd:string'), 64 ) 65 ); 66 67 $server->wsdl->addComplexType( 68 'contactdetails', 69 'complexType', 70 'array', 71 '', 72 'SOAP-ENC:Array', 73 array(), 74 array( 75 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:contactdetail[]') 76 ), 77 'tns:contactdetail' 78 ); 79 80 $server->wsdl->addComplexType( 81 'taskdetail', 82 'complexType', 83 'struct', 84 'all', 85 '', 86 array( 87 'id'=>array('name'=>'id','type'=>'xsd:string'), 88 'subject'=>array('name'=>'subject','type'=>'xsd:string'), 89 'startdate'=>array('name'=>'startdate','type'=>'xsd:string'), 90 'duedate'=>array('name'=>'duedate','type'=>'xsd:string'), 91 'status'=> array('name'=>'status','type'=>'xsd:string'), 92 'priority'=>array('name'=>'priority','type'=>'xsd:string'), 93 'description'=>array('name'=>'description','type'=>'xsd:string'), 94 'contactname'=>array('name'=>'contactname','type'=>'xsd:string'), 95 'category'=>array('name'=>'category','type'=>'xsd:string'), 96 ) 97 ); 98 99 $server->wsdl->addComplexType( 100 'taskdetails', 101 'complexType', 102 'array', 103 '', 104 'SOAP-ENC:Array', 105 array(), 106 array( 107 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:taskdetail[]') 108 ), 109 'tns:taskdetail' 110 ); 111 112 $server->wsdl->addComplexType( 113 'clndrdetail', 114 'complexType', 115 'struct', 116 'all', 117 '', 118 array( 119 'id'=>array('name'=>'id','type'=>'xsd:string'), 120 'subject'=>array('name'=>'subject','type'=>'xsd:string'), 121 'startdate'=>array('name'=>'startdate','type'=>'xsd:string'), 122 'duedate'=>array('name'=>'duedate','type'=>'xsd:string'), 123 'location'=> array('name'=>'location','type'=>'xsd:string'), 124 'description'=>array('name'=>'description','type'=>'xsd:string'), 125 'contactname'=>array('name'=>'contactname','type'=>'xsd:string'), 126 'category'=>array('name'=>'category','type'=>'xsd:string'), 127 ) 128 ); 129 130 $server->wsdl->addComplexType( 131 'clndrdetails', 132 'complexType', 133 'array', 134 '', 135 'SOAP-ENC:Array', 136 array(), 137 array( 138 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:clndrdetail[]') 139 ), 140 'tns:clndrdetail' 141 ); 142 143 $server->wsdl->addComplexType( 144 'emailmsgdetail', 145 'complexType', 146 'struct', 147 'all', 148 '', 149 array( 150 'subject'=>array('name'=>'subject','type'=>'xsd:string'), 151 'body'=>array('name'=>'body','type'=>'xsd:string'), 152 'datesent'=>array('name'=>'datesent','type'=>'xsd:string'), 153 ) 154 ); 155 156 157 $server->register( 158 'LoginToVtiger', 159 array('userid'=>'xsd:string','password'=>'xsd:string'), 160 array('return'=>'xsd:string'), 161 $NAMESPACE); 162 163 $server->register( 164 'CheckEmailPermission', 165 array('username'=>'xsd:string'), 166 array('return'=>'xsd:string'), 167 $NAMESPACE); 168 169 $server->register( 170 'CheckContactPermission', 171 array('username'=>'xsd:string'), 172 array('return'=>'xsd:string'), 173 $NAMESPACE); 174 175 $server->register( 176 'CheckActivityPermission', 177 array('username'=>'xsd:string'), 178 array('return'=>'xsd:string'), 179 $NAMESPACE); 180 181 182 183 $server->register( 184 'SearchContactsByEmail', 185 array('username'=>'xsd:string','emailaddress'=>'xsd:string'), 186 array('return'=>'tns:contactdetails'), 187 $NAMESPACE); 188 189 $server->register( 190 'AddMessageToContact', 191 array('username'=>'xsd:string','contactid'=>'xsd:string','msgdtls'=>'tns:emailmsgdetail'), 192 array('return'=>'xsd:string'), 193 $NAMESPACE); 194 195 $server->register( 196 'AddEmailAttachment', 197 array('emailid'=>'xsd:string','filedata'=>'xsd:string', 198 'filename'=>'xsd:string','filesize'=>'xsd:string','filetype'=>'xsd:string', 199 'username'=>'xsd:string'), 200 array('return'=>'xsd:string'), 201 $NAMESPACE); 202 203 //For Contacts Sync 204 $server->register( 205 'GetContacts', 206 array('username'=>'xsd:string'), 207 array('return'=>'tns:contactdetails'), 208 $NAMESPACE); 209 210 $server->register( 211 'AddContacts', 212 array('username'=>'xsd:string','cntdtls'=>'tns:contactdetails'), 213 array('return'=>'xsd:string'), 214 $NAMESPACE); 215 216 $server->register( 217 'UpdateContacts', 218 array('username'=>'xsd:string','cntdtls'=>'tns:contactdetails'), 219 array('return'=>'xsd:string'), 220 $NAMESPACE); 221 222 $server->register( 223 'DeleteContacts', 224 array('username'=>'xsd:string','crmid'=>'xsd:string'), 225 array('return'=>'xsd:string'), 226 $NAMESPACE); 227 //End for Contacts Sync 228 229 //For Tasks Sync 230 $server->register( 231 'GetTasks', 232 array('username'=>'xsd:string'), 233 array('return'=>'tns:taskdetails'), 234 $NAMESPACE); 235 236 $server->register( 237 'AddTasks', 238 array('username'=>'xsd:string','taskdtls'=>'tns:taskdetails'), 239 array('return'=>'xsd:string'), 240 $NAMESPACE); 241 242 $server->register( 243 'UpdateTasks', 244 array('username'=>'xsd:string','taskdtls'=>'tns:taskdetails'), 245 array('return'=>'xsd:string'), 246 $NAMESPACE); 247 248 $server->register( 249 'DeleteTasks', 250 array('username'=>'xsd:string','crmid'=>'xsd:string'), 251 array('return'=>'xsd:string'), 252 $NAMESPACE); 253 //End for Tasks Sync 254 255 //For Calendar Sync 256 $server->register( 257 'GetClndr', 258 array('username'=>'xsd:string'), 259 array('return'=>'tns:clndrdetails'), 260 $NAMESPACE); 261 262 $server->register( 263 'AddClndr', 264 array('username'=>'xsd:string','clndrdtls'=>'tns:clndrdetails'), 265 array('return'=>'xsd:string'), 266 $NAMESPACE); 267 268 $server->register( 269 'UpdateClndr', 270 array('username'=>'xsd:string','clndrdtls'=>'tns:clndrdetails'), 271 array('return'=>'xsd:string'), 272 $NAMESPACE); 273 274 $server->register( 275 'DeleteClndr', 276 array('username'=>'xsd:string','crmid'=>'xsd:string'), 277 array('return'=>'xsd:string'), 278 $NAMESPACE); 279 //End for Calendar Sync 280 281 function SearchContactsByEmail($username,$emailaddress) 282 { 283 require_once ('modules/Contacts/Contacts.php'); 284 285 $seed_contact = new Contacts(); 286 $output_list = Array(); 287 288 $response = $seed_contact->get_searchbyemailid($username,$emailaddress); 289 $contactList = $response['list']; 290 291 // create a return array of names and email addresses. 292 foreach($contactList as $contact) 293 { 294 $output_list[] = Array( 295 "id" => $contact[contactid], 296 "firstname" => $contact[firstname], 297 "lastname" => $contact[lastname], 298 "accountname" => $contact[accountname], 299 "emailaddress" => $contact[email], 300 ); 301 } 302 303 //to remove an erroneous compiler warning 304 $seed_contact = $seed_contact; 305 return $output_list; 306 } 307 308 function AddMessageToContact($username,$contactid,$msgdtls) 309 { 310 global $adb; 311 require_once ('modules/Users/Users.php'); 312 require_once ('modules/Emails/Emails.php'); 313 314 $seed_user = new Users(); 315 $user_id = $seed_user->retrieve_user_id($username); 316 317 foreach($msgdtls as $msgdtl) 318 { 319 if(isset($msgdtl)) 320 { 321 $email = new Emails(); 322 //$log->debug($msgdtls['contactid']); 323 $email_body = str_replace("'", "''", $msgdtl['body']); 324 $email_subject = str_replace("'", "''",$msgdtl['subject']); 325 $date_sent = getDisplayDate($msgdtl['datesent']); 326 327 $email->column_fields[subject] = $email_subject; 328 $email->column_fields[assigned_user_id] = $user_id; 329 $email->column_fields[date_start] = $date_sent; 330 $email->column_fields[description] = $email_body; 331 $email->column_fields[activitytype] = 'Emails'; 332 $email->plugin_save = true; 333 $email->save("Emails"); 334 335 $email->set_emails_contact_invitee_relationship($email->id,$contactid); 336 $email->set_emails_se_invitee_relationship($email->id,$contactid); 337 $email->set_emails_user_invitee_relationship($email->id,$user_id); 338 $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contactid."'"; 339 $result = $adb->query($sql); 340 $camodulerow = $adb->fetch_array($result); 341 if(isset($camodulerow)) 342 { 343 $emailid = $camodulerow["email"]; 344 $query = 'insert into vtiger_emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$contactid."@77|".'","OUTLOOK")'; 345 $adb->query($query); 346 } 347 return $email->id; 348 } 349 else 350 { 351 return ""; 352 } 353 } 354 } 355 356 function LoginToVtiger($userid,$password) 357 { 358 global $adb; 359 require_once ('modules/Users/Users.php'); 360 361 $return_access = "FALSE"; 362 363 $objuser = new Users(); 364 365 if($password != "") 366 { 367 $objuser->column_fields['user_name'] = $userid; 368 $objuser->load_user($password); 369 if($objuser->is_authenticated()) 370 { 371 $return_access = "TRUE"; 372 }else 373 { 374 $return_access = "FALSE"; 375 } 376 }else 377 { 378 //$server->setError("Invalid username and/or password"); 379 $return_access = "FALSE"; 380 } 381 $objuser = $objuser; 382 return $return_access; 383 } 384 385 function CheckEmailPermission($username) 386 { 387 global $current_user,$log; 388 require_once ("modules/Users/Users.php"); 389 $seed_user=new Users(); 390 $user_id=$seed_user->retrieve_user_id($username); 391 $current_user=$seed_user; 392 $current_user->retrieve_entity_info($user_id, 'Users'); 393 394 if(isPermitted("Emails","EditView") == "yes") 395 { 396 return "allowed"; 397 }else 398 { 399 return "denied"; 400 } 401 } 402 403 function CheckContactPermission($username) 404 { 405 global $current_user; 406 require_once ("modules/Users/Users.php"); 407 $seed_user=new Users(); 408 $user_id=$seed_user->retrieve_user_id($username); 409 $current_user=$seed_user; 410 $current_user->retrieve_entity_info($user_id, 'Users'); 411 412 if(isPermitted("Contacts","Delete") == "yes") 413 { 414 return "allowed"; 415 }else 416 { 417 return "denied"; 418 } 419 } 420 421 function CheckActivityPermission($username) 422 { 423 global $current_user; 424 require_once ("modules/Users/Users.php"); 425 $seed_user=new Users(); 426 $user_id=$seed_user->retrieve_user_id($username); 427 $current_user=$seed_user; 428 $current_user->retrieve_entity_info($user_id, 'Users'); 429 430 if(isPermitted("Calendar","Delete") == "yes") 431 { 432 return "allowed"; 433 }else 434 { 435 return "denied"; 436 } 437 } 438 439 function AddEmailAttachment($emailid,$filedata,$filename,$filesize,$filetype,$username) 440 { 441 global $adb; 442 require_once ('modules/Users/Users.php'); 443 require_once ('include/utils/utils.php'); 444 445 $date_var = date('YmdHis'); 446 447 $seed_user = new Users(); 448 $user_id = $seed_user->retrieve_user_id($username); 449 450 $crmid = $adb->getUniqueID("vtiger_crmentity"); 451 452 $upload_file_path = decideFilePath(); 453 454 $handle = fopen($upload_file_path.$crmid."_".$filename,"wb"); 455 fwrite($handle,base64_decode($filedata),$filesize); 456 fclose($handle); 457 458 $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) 459 values(".$crmid.",".$user_id.",".$user_id.",'Emails Attachment',' ',".$adb->formatString("vtiger_crmentity","createdtime",$date_var).",".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var).")"; 460 461 $entityresult = $adb->query($sql1); 462 $filetype="application/octet-stream"; 463 464 if($entityresult != false) 465 { 466 $sql2="insert into vtiger_attachments(attachmentsid, name, description, type, path) 467 values(".$crmid.",'".$filename."',' ','".$filetype."','".$upload_file_path."')"; 468 469 $result=$adb->query($sql2); 470 471 $sql3='insert into vtiger_seattachmentsrel values('.$emailid.','.$crmid.')'; 472 $adb->query($sql3); 473 474 return $crmid; 475 } 476 else 477 { 478 //$server->setError("Invalid username and/or password"); 479 return ""; 480 } 481 } 482 483 function GetContacts($username) 484 { 485 global $adb; 486 require_once ('modules/Contacts/Contacts.php'); 487 488 $seed_contact = new Contacts(); 489 $output_list = Array(); 490 491 $query = $seed_contact->get_contactsforol($username); 492 $result = $adb->query($query); 493 494 while($contact = $adb->fetch_array($result)) 495 { 496 if($contact["birthdate"] == "0000-00-00") 497 { 498 $contact["birthdate"] = ""; 499 } 500 if($contact["salutation"] == "--None--") 501 { 502 $contact["salutation"] = ""; 503 } 504 505 $namelist = explode(" ", $contact["lastname"]); 506 $middlename = ""; 507 if(isset($namelist)) 508 { 509 if(count($namelist) >= 2) 510 { 511 $contact["lastname"] = $namelist[count($namelist)-1]; 512 for($i=0; $i<count($namelist)-2; $i++) 513 { 514 if($namelist[$i] != '') 515 $middlename[] = $namelist[$i]; 516 } 517 if(isset($middlename)) 518 { 519 $middlename = implode(" ",$middlename); 520 } 521 } 522 } 523 524 $output_list[] = Array( 525 "id" => $contact["id"], 526 "title" => $contact["salutation"], 527 "firstname" => $contact["firstname"], 528 "middlename" => trim($middlename), 529 "lastname" => trim($contact["lastname"]), 530 "birthdate" => $contact["birthday"], 531 "emailaddress" => $contact["email"], 532 "jobtitle" => $contact["title"], 533 "department" => $contact["department"], 534 "accountname" => $contact["accountname"], 535 "officephone" => $contact["phone"], 536 "homephone" => $contact["homephone"], 537 "otherphone" => $contact["otherphone"], 538 "fax" => $contact["fax"], 539 "mobile" => $contact["mobile"], 540 "asstname" => $contact["assistant"], 541 "asstphone" => $contact["assistantphone"], 542 "reportsto" => $contact["reports_to_name"], 543 "mailingstreet" => $contact["mailingstreet"], 544 "mailingcity" => $contact["mailingcity"], 545 "mailingstate" => $contact["mailingstate"], 546 "mailingzip" => $contact["mailingzip"], 547 "mailingcountry" => $contact["mailingcountry"], 548 "otherstreet" => $contact["otherstreet"], 549 "othercity" => $contact["othercity"], 550 "otherstate" => $contact["otherstate"], 551 "otherzip" => $contact["otherzip"], 552 "othercountry" => $contact["othercountry"], 553 "description" => "", 554 "category" => "", 555 ); 556 } 557 558 //to remove an erroneous compiler warning 559 $seed_contact = $seed_contact; 560 return $output_list; 561 } 562 563 function AddContacts($username,$cntdtls) 564 { 565 global $adb; 566 global $current_user; 567 require_once ('modules/Users/Users.php'); 568 require_once ('modules/Contacts/Contacts.php'); 569 570 $seed_user = new Users(); 571 $user_id = $seed_user->retrieve_user_id($username); 572 $current_user = $seed_user; 573 $current_user->retrieve_entity_info($user_id,"Users"); 574 575 $contact = new Contacts(); 576 577 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 578 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 579 580 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) 581 { 582 $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5"; 583 }else 584 { 585 $profileList = getCurrentUserProfileList(); 586 $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList; 587 } 588 $result1 = $adb->query($sql1); 589 for($i=0;$i < $adb->num_rows($result1);$i++) 590 { 591 $permitted_lists[] = $adb->query_result($result1,$i,'fieldname'); 592 } 593 594 foreach($cntdtls as $cntrow) 595 { 596 if(isset($cntrow)) 597 { 598 $contact->column_fields[salutation]=in_array('salutation',$permitted_lists) ? $cntrow["title"] : ""; 599 $contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $cntrow["firstname"] : ""; 600 601 if($cntrow["middlename"] != "") 602 { 603 $contact->column_fields[lastname]=$cntrow["middlename"]." ".$cntrow["lastname"]; 604 }elseif($cntrow["lastname"] != "") 605 { 606 $contact->column_fields[lastname]=$cntrow["lastname"]; 607 }else 608 { 609 $contact->column_fields[lastname]=$cntrow["firstname"]." ".$cntrow["middlename"]." ".$cntrow["lastname"]; 610 } 611 612 $contact->column_fields[birthday]= in_array('birthday',$permitted_lists) ? getDisplayDate($cntrow["birthdate"]) : ""; 613 $contact->column_fields[email]=in_array('email',$permitted_lists) ? $cntrow["emailaddress"] : ""; 614 $contact->column_fields[title]=in_array('title',$permitted_lists) ? $cntrow["jobtitle"] : ""; 615 $contact->column_fields[department]=in_array('department',$permitted_lists) ? $cntrow["department"] : ""; 616 $contact->column_fields[account_id]= in_array('account_id',$permitted_lists) ? retrieve_account_id($cntrow["accountname"],$user_id) : ""; 617 $contact->column_fields[phone]= in_array('phone',$permitted_lists) ? $cntrow["officephone"] : ""; 618 $contact->column_fields[homephone]= in_array('homephone',$permitted_lists) ? $cntrow["homephone"] : ""; 619 $contact->column_fields[otherphone]= in_array('otherphone',$permitted_lists) ? $cntrow["otherphone"] : ""; 620 $contact->column_fields[fax]= in_array('fax',$permitted_lists) ? $cntrow["fax"] : ""; 621 $contact->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $cntrow["mobile"] : ""; 622 $contact->column_fields[assistant]= in_array('assistant',$permitted_lists) ? $cntrow["asstname"] : ""; 623 $contact->column_fields[assistantphone]= in_array('assistantphone',$permitted_lists) ? $cntrow["asstphone"] : ""; 624 //$contact->column_fields[reports_to_id] =retrievereportsto($reportsto,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP 625 $contact->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $cntrow["mailingstreet"] : ""; 626 $contact->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $cntrow["mailingcity"] : ""; 627 $contact->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $cntrow["mailingstate"] : ""; 628 $contact->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $cntrow["mailingzip"] : ""; 629 $contact->column_fields[mailingcountry]=in_array('mailingcountry',$permitted_lists) ? $cntrow["mailingcountry"] : ""; 630 $contact->column_fields[otherstreet]=in_array('otherstreet',$permitted_lists) ? $cntrow["otherstreet"] : ""; 631 $contact->column_fields[othercity]=in_array('othercity',$permitted_lists) ? $cntrow["othercity"] : ""; 632 $contact->column_fields[otherstate]=in_array('otherstate',$permitted_lists) ? $cntrow["otherstate"] : ""; 633 $contact->column_fields[otherzip]=in_array('otherzip',$permitted_lists) ? $cntrow["otherzip"] : ""; 634 $contact->column_fields[othercountry]=in_array('othercountry',$permitted_lists) ? $cntrow["othercountry"] : ""; 635 $contact->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : ""; 636 $contact->column_fields[description]= in_array('description',$permitted_lists) ? $cntrow["description"] : ""; 637 $contact->save("Contacts"); 638 639 } 640 } 641 $contact = $contact; 642 return $contact->id; 643 } 644 645 function UpdateContacts($username,$cntdtls) 646 { 647 global $adb; 648 global $current_user; 649 require_once ('modules/Users/Users.php'); 650 require_once ('modules/Contacts/Contacts.php'); 651 652 $seed_user = new Users(); 653 $user_id = $seed_user->retrieve_user_id($username); 654 $current_user = $seed_user; 655 $current_user->retrieve_entity_info($user_id,"Users"); 656 657 $contact = new Contacts(); 658 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 659 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 660 661 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) 662 { 663 $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5"; 664 }else 665 { 666 $profileList = getCurrentUserProfileList(); 667 $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList; 668 } 669 $result1 = $adb->query($sql1); 670 for($i=0;$i < $adb->num_rows($result1);$i++) 671 { 672 $permitted_lists[] = $adb->query_result($result1,$i,'fieldname'); 673 } 674 675 foreach($cntdtls as $cntrow) 676 { 677 if(isset($cntrow)) 678 { 679 $contact->retrieve_entity_info($cntrow["id"],"Contacts"); 680 $contact->column_fields[salutation]=in_array('salutation',$permitted_lists) ? $cntrow["title"] : ""; 681 $contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $cntrow["firstname"] : ""; 682 if($cntrow["middlename"] != "") 683 { 684 $contact->column_fields[lastname]=$cntrow["middlename"]." ".$cntrow["lastname"]; 685 }elseif($cntrow["lastname"] != "") 686 { 687 $contact->column_fields[lastname]=$cntrow["lastname"]; 688 }else 689 { 690 $contact->column_fields[lastname]=$cntrow["firstname"]." ".$cntrow["middlename"]." ".$cntrow["lastname"]; 691 } 692 693 $contact->column_fields[birthday]= in_array('birthday',$permitted_lists) ? getDisplayDate($cntrow["birthdate"]) : ""; 694 $contact->column_fields[email]= in_array('email',$permitted_lists) ? $cntrow["emailaddress"] : ""; 695 $contact->column_fields[title]= in_array('title',$permitted_lists) ? $cntrow["jobtitle"] : ""; 696 $contact->column_fields[department]= in_array('department',$permitted_lists) ? $cntrow["department"] : ""; 697 $contact->column_fields[account_id]= in_array('account_id',$permitted_lists) ? retrieve_account_id($cntrow["accountname"],$user_id) : ""; 698 $contact->column_fields[phone]= in_array('phone',$permitted_lists) ? $cntrow["officephone"] : ""; 699 $contact->column_fields[homephone]= in_array('homephone',$permitted_lists) ? $cntrow["homephone"] : ""; 700 $contact->column_fields[otherphone]= in_array('otherphone',$permitted_lists) ? $cntrow["otherphone"] : ""; 701 $contact->column_fields[fax]= in_array('fax',$permitted_lists) ? $cntrow["fax"] : ""; 702 $contact->column_fields[mobile]= in_array('mobile',$permitted_lists) ? $cntrow["mobile"] : ""; 703 $contact->column_fields[assistant]= in_array('assistant',$permitted_lists) ? $cntrow["asstname"] : ""; 704 $contact->column_fields[assistantphone]= in_array('assistantphone',$permitted_lists) ? $cntrow["asstphone"] : ""; 705 //$contact->column_fields[reports_to_id] =retrievereportsto($reportsto,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP 706 $contact->column_fields[mailingstreet]= in_array('mailingstreet',$permitted_lists) ? $cntrow["mailingstreet"] : ""; 707 $contact->column_fields[mailingcity]= in_array('mailingcity',$permitted_lists) ? $cntrow["mailingcity"] : ""; 708 $contact->column_fields[mailingstate]= in_array('mailingstate',$permitted_lists) ? $cntrow["mailingstate"] : ""; 709 $contact->column_fields[mailingzip]= in_array('mailingzip',$permitted_lists) ? $cntrow["mailingzip"] : ""; 710 $contact->column_fields[mailingcountry]= in_array('mailingcountry',$permitted_lists) ? $cntrow["mailingcountry"] : ""; 711 $contact->column_fields[otherstreet]= in_array('otherstreet',$permitted_lists) ? $cntrow["otherstreet"] : ""; 712 $contact->column_fields[othercity]= in_array('othercity',$permitted_lists) ? $cntrow["othercity"] : ""; 713 $contact->column_fields[otherstate]= in_array('otherstate',$permitted_lists) ? $cntrow["otherstate"] : ""; 714 $contact->column_fields[otherzip]= in_array('otherzip',$permitted_lists) ? $cntrow["otherzip"] : ""; 715 $contact->column_fields[othercountry]= in_array('othercountry',$permitted_lists) ? $cntrow["othercountry"] : ""; 716 $contact->column_fields[assigned_user_id]= in_array('assigned_user_id',$permitted_lists) ? $user_id : ""; 717 $contact->column_fields[description]= in_array('description',$permitted_lists) ? $cntrow["description"] : ""; 718 $contact->id = $cntrow["id"]; 719 $contact->mode = "edit"; 720 $contact->save("Contacts"); 721 } 722 } 723 $contact = $contact; 724 return $contact->id; 725 } 726 727 function DeleteContacts($username,$crmid) 728 { 729 global $current_user; 730 require_once ('modules/Users/Users.php'); 731 require_once ('modules/Contacts/Contacts.php'); 732 733 $seed_user = new Users(); 734 $user_id = $seed_user->retrieve_user_id($username); 735 $current_user = $seed_user; 736 $current_user->retrieve_entity_info($user_id,"Users"); 737 738 $contact = new Contacts(); 739 $contact->id = $crmid; 740 $contact->mark_deleted($contact->id); 741 742 $contact = $contact; 743 return $contact->id; 744 } 745 746 function retrieve_account_id($account_name,$user_id) 747 { 748 749 if($account_name=="") 750 { 751 return null; 752 } 753 754 $query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'"; 755 756 757 $db = new PearDatabase(); 758 $result= $db->query($query) or die ("Not able to execute insert"); 759 760 $rows_count = $db->getRowCount($result); 761 if($rows_count==0) 762 { 763 require_once ('modules/Accounts/Accounts.php'); 764 $account = new Accounts(); 765 $account->column_fields[accountname] = $account_name; 766 $account->column_fields[assigned_user_id]=$user_id; 767 //$account->saveentity("Accounts"); 768 $account->save("Accounts"); 769 //mysql_close(); 770 return $account->id; 771 } 772 else if ($rows_count==1) 773 { 774 $row = $db->fetchByAssoc($result, 0); 775 //mysql_close(); 776 return $row["accountid"]; 777 } 778 else 779 { 780 $row = $db->fetchByAssoc($result, 0); 781 //mysql_close(); 782 return $row["accountid"]; 783 } 784 785 } 786 787 function GetTasks($username) 788 { 789 global $adb,$log; 790 require_once ('modules/Calendar/Activity.php'); 791 792 $seed_task = new Activity(); 793 $output_list = Array(); 794 795 $query = $seed_task->get_tasksforol($username); 796 $result = $adb->query($query); 797 798 while($task = $adb->fetch_array($result)) 799 { 800 if($task["date_start"] == "0000-00-00" || $task["date_start"] == NULL) 801 { 802 $task["date_start"] = ""; 803 } 804 if($task["due_date"] == "0000-00-00" || $task["due_date"] == NULL) 805 { 806 $task["due_date"] = ""; 807 } 808 809 if($task["status"] == "Not Started") 810 { 811 $task["status"] = "0"; 812 }else if($task["status"] == "In Progress") 813 { 814 $task["status"] = "1"; 815 }else if($task["status"] == "Completed") 816 { 817 $task["status"] = "2"; 818 }else if($task["status"] == "Deferred") 819 { 820 $task["status"] = "4"; 821 }else if($task["status"] == "Pending Input" || $task["status"] == "Planned") 822 { 823 $task["status"] = "3"; 824 }else 825 { 826 $task["status"] = "0"; 827 } 828 829 if($task["priority"] == "High") 830 { 831 $task["priority"] = "2"; 832 }else if($task["priority"] == "Low") 833 { 834 $task["priority"] = "0"; 835 }else if($task["priority"] == "Medium") 836 { 837 $task["priority"] = "1"; 838 } 839 840 $output_list[] = Array( 841 "id" => $task["taskid"], 842 "subject" => $task["subject"], 843 "startdate" => $task["date_start"], 844 "duedate" => $task["due_date"], 845 "status" => $task["status"], 846 "priority" => $task["priority"], 847 "description" => $task["description"], 848 "contactname" => $task["firstname"]." ".$task["lastname"], 849 "category" => "", 850 ); 851 } 852 $seed_task = $seed_task; 853 return $output_list; 854 } 855 856 function AddTasks($username,$taskdtls) 857 { 858 global $current_user,$adb; 859 require_once ('modules/Users/Users.php'); 860 require_once ('modules/Calendar/Activity.php'); 861 862 $seed_user = new Users(); 863 $user_id = $seed_user->retrieve_user_id($username); 864 $current_user = $seed_user; 865 $current_user->retrieve_entity_info($user_id,"Users"); 866 867 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 868 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 869 870 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) 871 { 872 $sql1 = "select fieldname,columnname from vtiger_field where tabid=9"; 873 }else 874 { 875 $profileList = getCurrentUserProfileList(); 876 $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList; 877 } 878 $result1 = $adb->query($sql1); 879 for($i=0;$i < $adb->num_rows($result1);$i++) 880 { 881 $permitted_lists[] = $adb->query_result($result1,$i,'fieldname'); 882 } 883 884 $task = new Activity(); 885 886 foreach($taskdtls as $taskrow) 887 { 888 //Currently only 3 status avail Note ************************************************ 889 if(isset($taskrow)) 890 { 891 if($taskrow["status"] == "0") 892 { 893 $taskrow["status"] = "Not Started"; 894 }else if($taskrow["status"] == "1") 895 { 896 $taskrow["status"] = "In Progress"; 897 }else if($taskrow["status"] == "2") 898 { 899 $taskrow["status"] = "Completed"; 900 }else if($taskrow["status"] == "4") 901 { 902 $taskrow["status"] = "Deferred"; 903 }else if($taskrow["status"] == "3") 904 { 905 $taskrow["status"] = "Planned"; 906 }else 907 { 908 $taskrow["status"] = "Not Started"; 909 } 910 911 if($taskrow["priority"] == "2") 912 { 913 $taskrow["priority"] = "High"; 914 }else if($taskrow["priority"] == "0") 915 { 916 $taskrow["priority"] = "Low"; 917 }else if($taskrow["priority"] == "1") 918 { 919 $taskrow["priority"] = "Medium"; 920 } 921 922 $task->column_fields[subject] = in_array('subject',$permitted_lists) ? $taskrow["subject"] : ""; 923 $task->column_fields[date_start]= in_array('date_start',$permitted_lists) ? getDisplayDate($taskrow["startdate"]) : ""; 924 $task->column_fields[due_date]= in_array('due_date',$permitted_lists) ? getDisplayDate($taskrow["duedate"]) : ""; 925 $task->column_fields[taskstatus]= in_array('taskstatus',$permitted_lists) ? $taskrow["status"] : ""; 926 $task->column_fields[taskpriority]= in_array('taskpriority',$permitted_lists) ? $taskrow["priority"] : ""; 927 $task->column_fields[description]= in_array('description',$permitted_lists) ? $taskrow["description"] : ""; 928 $task->column_fields[activitytype]="Task"; 929 //$task->column_fields[contact_id]= retrievereportsto($contact_name,$user_id,null); 930 $task->column_fields[assigned_user_id]= in_array('assigned_user_id',$permitted_lists) ? $user_id : ""; 931 $task->save("Calendar"); 932 } 933 } 934 return $task->id; 935 } 936 937 function UpdateTasks($username,$taskdtls) 938 { 939 global $current_user,$adb; 940 require_once ('modules/Users/Users.php'); 941 require_once ('modules/Calendar/Activity.php'); 942 943 $seed_user = new Users(); 944 $user_id = $seed_user->retrieve_user_id($username); 945 $current_user = $seed_user; 946 $current_user->retrieve_entity_info($user_id,"Users"); 947 948 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 949 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 950 951 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) 952 { 953 $sql1 = "select fieldname,columnname from vtiger_field where tabid=9"; 954 }else 955 { 956 $profileList = getCurrentUserProfileList(); 957 $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList; 958 } 959 $result1 = $adb->query($sql1); 960 for($i=0;$i < $adb->num_rows($result1);$i++) 961 { 962 $permitted_lists[] = $adb->query_result($result1,$i,'fieldname'); 963 } 964 965 $task = new Activity(); 966 967 foreach($taskdtls as $taskrow) 968 { 969 if(isset($taskrow)) 970 { 971 if($taskrow["status"] == "0") 972 { 973 $taskrow["status"] = "Not Started"; 974 }else if($taskrow["status"] == "1") 975 { 976 $taskrow["status"] = "In Progress"; 977 }else if($taskrow["status"] == "2") 978 { 979 $taskrow["status"] = "Completed"; 980 }else if($taskrow["status"] == "4") 981 { 982 $taskrow["status"] = "Deferred"; 983 }else if($taskrow["status"] == "3") 984 { 985 $taskrow["status"] = "Planned"; 986 }else 987 { 988 $taskrow["status"] = "Not Started"; 989 } 990 991 if($taskrow["priority"] == "2") 992 { 993 $taskrow["priority"] = "High"; 994 }else if($taskrow["priority"] == "0") 995 { 996 $taskrow["priority"] = "Low"; 997 }else if($taskrow["priority"] == "1") 998 { 999 $taskrow["priority"] = "Medium"; 1000 } 1001 1002 $task->retrieve_entity_info($taskrow["id"],"Calendar"); 1003 $task->column_fields[subject] = in_array('subject',$permitted_lists) ? $taskrow["subject"] : ""; 1004 $task->column_fields[date_start] = in_array('date_start',$permitted_lists) ? getDisplayDate($taskrow["startdate"]) : ""; 1005 $task->column_fields[due_date] = in_array('due_date',$permitted_lists) ? getDisplayDate($taskrow["duedate"]) : ""; 1006 $task->column_fields[taskstatus] = in_array('taskstatus',$permitted_lists) ? $taskrow["status"] : ""; 1007 $task->column_fields[taskpriority] = in_array('taskpriority',$permitted_lists) ? $taskrow["priority"] : ""; 1008 $task->column_fields[description] = in_array('description',$permitted_lists) ? $taskrow["description"] : ""; 1009 $task->column_fields[activitytype] = "Task"; 1010 //$task->column_fields[contact_id]= retrievereportsto($contact_name,$user_id,null); 1011 $task->column_fields[assigned_user_id] = in_array('assigned_user_id',$permitted_lists) ? $user_id : ""; 1012 1013 $task->id = $taskrow["id"]; 1014 $task->mode="edit"; 1015 1016 $task->save("Calendar"); 1017 } 1018 } 1019 return $task->id; 1020 } 1021 1022 function DeleteTasks($username,$crmid) 1023 { 1024 global $current_user; 1025 require_once ('modules/Users/Users.php'); 1026 require_once ('modules/Calendar/Activity.php'); 1027 1028 $seed_user = new Users(); 1029 $user_id = $seed_user->retrieve_user_id($username); 1030 $current_user = $seed_user; 1031 $current_user->retrieve_entity_info($user_id,"Users"); 1032 1033 $task = new Activity(); 1034 $task->id = $crmid; 1035 $task->mark_deleted($task->id); 1036 return $task->id; 1037 } 1038 1039 function GetClndr($username) 1040 { 1041 global $adb,$log; 1042 require_once ('modules/Calendar/Activity.php'); 1043 1044 $seed_clndr = new Activity(); 1045 $output_list = Array(); 1046 1047 $query = $seed_clndr->get_calendarsforol($username); 1048 $result = $adb->query($query); 1049 1050 while($clndr = $adb->fetch_array($result)) 1051 { 1052 if($clndr["date_start"] == "0000-00-00" || $clndr["date_start"] == NULL) 1053 { 1054 $clndr["date_start"] = ""; 1055 } 1056 if($clndr["due_date"] == "0000-00-00" || $clndr["due_date"] == NULL) 1057 { 1058 $clndr["due_date"] = ""; 1059 } 1060 1061 //this seperates the $$clndr["startdate"] into an array - YYYY-MM-DD 1062 $expldstartdate = explode("-", $clndr["date_start"]); 1063 $expldtimestart = explode(":", $clndr["time_start"]); 1064 1065 //this makes a timestamp out of the exploded date this number is in seconds 1066 $startdtm = mktime($expldtimestart[0], $expldtimestart[1], 0, $expldstartdate[1], $expldstartdate[2], $expldstartdate[0]); 1067 1068 $expldduedate = explode("-", $clndr["due_date"]); 1069 $expldtimeend = explode(":", $clndr["time_end"]); 1070 //this makes a timestamp out of the exploded date this number is in seconds 1071 $duedtm = mktime($expldtimeend[0], $expldtimeend[1], 0, $expldduedate[1], $expldduedate[2], $expldduedate[0]); 1072 1073 $clndr["date_start"] = date("Y-m-d H:i:s", $startdtm); 1074 $clndr["due_date"] = date("Y-m-d H:i:s", $duedtm); 1075 1076 $output_list[] = Array( 1077 "id" => $clndr["clndrid"], 1078 "subject" => $clndr["subject"], 1079 "startdate" => $clndr["date_start"], 1080 "duedate" => $clndr["due_date"], 1081 "location" => $clndr["location"], 1082 "description" => $clndr["description"], 1083 "contactname" => $clndr["firstname"]." ".$clndr["lastname"], 1084 "category" => "", 1085 ); 1086 } 1087 $seed_clndr = $seed_clndr; 1088 return $output_list; 1089 } 1090 1091 function AddClndr($username,$clndrdtls) 1092 { 1093 global $current_user,$adb; 1094 require_once ('modules/Users/Users.php'); 1095 require_once ('modules/Calendar/Activity.php'); 1096 1097 $seed_user = new Users(); 1098 $user_id = $seed_user->retrieve_user_id($username); 1099 $current_user = $seed_user; 1100 $current_user->retrieve_entity_info($user_id,"Users"); 1101 1102 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 1103 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 1104 1105 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) 1106 { 1107 $sql1 = "select fieldname,columnname from vtiger_field where tabid=16"; 1108 }else 1109 { 1110 $profileList = getCurrentUserProfileList(); 1111 $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=16 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList; 1112 } 1113 $result1 = $adb->query($sql1); 1114 for($i=0;$i < $adb->num_rows($result1);$i++) 1115 { 1116 $permitted_lists[] = $adb->query_result($result1,$i,'fieldname'); 1117 } 1118 1119 $clndr = new Activity(); 1120 1121 foreach($clndrdtls as $clndrow) 1122 { 1123 if(isset($clndrow)) 1124 { 1125 $astartdtm = explode(" ",$clndrow["startdate"]); 1126 $aduedtm = explode(" ",$clndrow["duedate"]); 1127 1128 $atimestart = explode(":",trim($astartdtm[1])); 1129 $atimedue = explode(":",trim($aduedtm[1])); 1130 1131 $stimestart = $atimestart[0].":".$atimestart[1]; 1132 $stimeend = $atimedue[0].":".$atimedue[1]; 1133 1134 /*if( $diff=@get_time_difference($stimestart, $stimeend) ) 1135 { 1136 $stimeduehr = sprintf('%02d',$diff['hours']); 1137 $stimeduemin = sprintf('%02d',$diff['minutes']); 1138 }*/ 1139 1140 $clndr->column_fields[subject] = in_array('subject',$permitted_lists) ? $clndrow["subject"] : ""; 1141 $clndr->column_fields[date_start]= in_array('date_start',$permitted_lists) ? getDisplayDate(trim($astartdtm[0])) : ""; 1142 $clndr->column_fields[due_date]= in_array('due_date',$permitted_lists) ? getDisplayDate(trim($aduedtm[0])) : ""; 1143 $clndr->column_fields[time_start]= in_array('time_start',$permitted_lists) ? $stimestart : ""; 1144 $clndr->column_fields[time_end]= in_array('time_end',$permitted_lists) ? $stimeend : ""; 1145 //$clndr->column_fields[duration_hours]= in_array('duration_hours',$permitted_lists) ? $stimeduehr : ""; 1146 //$clndr->column_fields[duration_minutes]= in_array('duration_minutes',$permitted_lists) ? $stimeduemin : ""; 1147 1148 $clndr->column_fields[location]= in_array('location',$permitted_lists) ? $clndrow["location"] : ""; 1149 $clndr->column_fields[description]= in_array('description',$permitted_lists) ? $clndrow["description"] : ""; 1150 $clndr->column_fields[activitytype]="Meeting"; 1151 $clndr->column_fields[assigned_user_id]= in_array('assigned_user_id',$permitted_lists) ? $user_id : ""; 1152 $clndr->save("Calendar"); 1153 } 1154 } 1155 return $clndr->id; 1156 } 1157 1158 function UpdateClndr($username,$clndrdtls) 1159 { 1160 global $current_user; 1161 global $adb,$log; 1162 require_once ('modules/Users/Users.php'); 1163 require_once ('modules/Calendar/Activity.php'); 1164 1165 $seed_user = new Users(); 1166 $user_id = $seed_user->retrieve_user_id($username); 1167 $current_user = $seed_user; 1168 $current_user->retrieve_entity_info($user_id,"Users"); 1169 1170 require('user_privileges/user_privileges_'.$current_user->id.'.php'); 1171 require('user_privileges/sharing_privileges_'.$current_user->id.'.php'); 1172 1173 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) 1174 { 1175 $sql1 = "select fieldname,columnname from vtiger_field where tabid=16"; 1176 }else 1177 { 1178 $profileList = getCurrentUserProfileList(); 1179 $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=16 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList; 1180 } 1181 $result1 = $adb->query($sql1); 1182 for($i=0;$i < $adb->num_rows($result1);$i++) 1183 { 1184 $permitted_lists[] = $adb->query_result($result1,$i,'fieldname'); 1185 } 1186 1187 $clndr = new Activity(); 1188 1189 foreach($clndrdtls as $clndrow) 1190 { 1191 if(isset($clndrow)) 1192 { 1193 $astartdtm = explode(" ",$clndrow["startdate"]); 1194 $aduedtm = explode(" ",$clndrow["duedate"]); 1195 1196 $atimestart = explode(":",trim($astartdtm[1])); 1197 $atimedue = explode(":",trim($aduedtm[1])); 1198 1199 $stimestart = $atimestart[0].":".$atimestart[1]; 1200 $stimeend = $atimedue[0].":".$atimedue[1]; 1201 1202 /*if( $diff=@get_time_difference($stimestart, $stimeend) ) 1203 { 1204 $stimeduehr = sprintf('%02d',$diff['hours']); 1205 $stimeduemin = sprintf('%02d',$diff['minutes']); 1206 }*/ 1207 1208 $clndr->retrieve_entity_info($clndrow["id"],"Calendar"); 1209 $clndr->column_fields[subject] = in_array('subject',$permitted_lists) ? $clndrow["subject"] : ""; 1210 $clndr->column_fields[date_start]= in_array('date_start',$permitted_lists) ? getDisplayDate(trim($astartdtm[0])) : ""; 1211 $clndr->column_fields[due_date]= in_array('due_date',$permitted_lists) ? getDisplayDate(trim($aduedtm[0])) : ""; 1212 $clndr->column_fields[time_start]= in_array('time_start',$permitted_lists) ? $stimestart : ""; 1213 $clndr->column_fields[time_end]= in_array('time_end',$permitted_lists) ? $stimeend : ""; 1214 //$clndr->column_fields[duration_hours]= in_array('duration_hours',$permitted_lists) ? $stimeduehr : ""; 1215 //$clndr->column_fields[duration_minutes]= in_array('duration_minutes',$permitted_lists) ? $stimeduemin : ""; 1216 $clndr->column_fields[location]= in_array('location',$permitted_lists) ? $clndrow["location"] : ""; 1217 $clndr->column_fields[description]= in_array('description',$permitted_lists) ? $clndrow["description"] : ""; 1218 $clndr->column_fields[activitytype]="Meeting"; 1219 $clndr->column_fields[assigned_user_id]= in_array('assigned_user_id',$permitted_lists) ? $user_id : ""; 1220 $clndr->id = $clndrow["id"]; 1221 $clndr->mode="edit"; 1222 $clndr->save("Calendar"); 1223 } 1224 } 1225 return $clndr->id; 1226 } 1227 1228 function DeleteClndr($username,$crmid) 1229 { 1230 global $current_user; 1231 require_once ('modules/Users/Users.php'); 1232 require_once ('modules/Calendar/Activity.php'); 1233 1234 $seed_user = new Users(); 1235 $user_id = $seed_user->retrieve_user_id($username); 1236 $current_user = $seed_user; 1237 $current_user->retrieve_entity_info($user_id,"Users"); 1238 1239 $clndr = new Activity(); 1240 $clndr->id = $crmid; 1241 $clndr->mark_deleted($clndr->id); 1242 return $clndr->id; 1243 } 1244 1245 //To find the Difference between time 1246 function get_time_difference( $start, $end ) 1247 { 1248 $uts['start'] = strtotime( $start ); 1249 $uts['end'] = strtotime( $end ); 1250 if( $uts['start']!==-1 && $uts['end']!==-1 ) 1251 { 1252 if( $uts['end'] >= $uts['start'] ) 1253 { 1254 $diff = $uts['end'] - $uts['start']; 1255 if( $days=intval((floor($diff/86400))) ) 1256 $diff = $diff % 86400; 1257 if( $hours=intval((floor($diff/3600))) ) 1258 $diff = $diff % 3600; 1259 if( $minutes=intval((floor($diff/60))) ) 1260 $diff = $diff % 60; 1261 $diff = intval( $diff ); 1262 return( array('days'=>$days, 'hours'=>$hours, 'minutes'=>$minutes, 'seconds'=>$diff) ); 1263 } 1264 } 1265 return( false ); 1266 } 1267 1268 $server->service(utf8_encode($HTTP_RAW_POST_DATA)); 1269 exit(); 1270 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |