Esempio n. 1
0
 function update_from_API($archived = '')
 {
     global $beanFiles;
     require_once $beanFiles['TILKEE_PROJECTS'];
     $associated_project = new TILKEE_PROJECTS();
     if (!empty($this->tilkee_projects_id)) {
         $associated_project->retrieve($this->tilkee_projects_id);
         if (!empty($associated_project->tilkee_id)) {
             require_once 'custom/include/externalAPI/Tilkee/ExtAPITilkee.php';
             $tilkee = new ExtAPITilkee();
             $result = $tilkee->update_tilk($associated_project->tilkee_id, $this->tilkee_id, $this->name, $this->won, $this->archived);
             if ($result != -1 && !empty($result)) {
                 // project updated : init bean
                 $this->tilk_url = $result->url;
                 $this->won = $result->won;
                 $this->created_at = !empty($result->created_at) ? date('Y-m-d H:i:s', strtotime($result->created_at)) : '';
                 $this->archived_at = !empty($result->archived_at) ? date('Y-m-d H:i:s', strtotime($result->archived_at)) : '';
                 $this->last_sign_in_at = !empty($result->last_sign_in_at) ? date('Y-m-d H:i:s', strtotime($result->last_sign_in_at)) : '';
                 $this->archived = !empty($result->archived_at) ? 'true' : 'false';
                 $this->total_time = $this->convert_time($result->total_time);
                 $this->total_connexion = $result->total_connexion;
                 // tilkee_contact_id
                 // tilkee_contact
                 $this->save();
                 // UPDATE LINKED CONNEXIONS
                 $connexion_array = $result->connexions;
             } else {
                 global $mod_strings;
                 SugarApplication::appendErrorMessage($mod_strings['LBL_ERROR_UPDATE_ON_TILKEE']);
             }
         } else {
             // ERROR : Associated project is not created in TILKEE
         }
     }
     return 0;
 }
Esempio n. 2
0
         if ($_REQUEST['project_id_infos_tilk'] != '' && $_REQUEST['tilk_id_infos_tilk'] != '') {
             $result = $tilkee->infos_tilk($_REQUEST['project_id_infos_tilk'], $_REQUEST['tilk_id_infos_tilk']);
             $display_result = print_r($result, true);
             $display_title = "Infos Tillk";
         }
         break;
     case 'create_tilk':
         if ($_REQUEST['project_id_create_tilk'] != '') {
             $result = $tilkee->create_tilk($_REQUEST['project_id_create_tilk'], $_REQUEST['tilk_name_create']);
             $display_result = print_r($result, true);
             $display_title = "Create Tillk";
         }
         break;
     case 'update_tilk':
         if ($_REQUEST['project_id_update_tilk'] != '' && $_REQUEST['tilk_id_update_tilk'] != '') {
             $result = $tilkee->update_tilk($_REQUEST['project_id_update_tilk'], $_REQUEST['tilk_id_update_tilk'], $_REQUEST['tilk_name_update'], $_REQUEST['tilk_won'], $_REQUEST['tilk_archived']);
             $display_result = print_r($result, true);
             $display_title = "Update Tillk";
         }
         break;
     default:
         break;
 }
 /* 
  * Update admini parameters
  */
 if (isset($_REQUEST['url_tilkee'])) {
     $cfg->config['tilkee']['url_tilkee'] = $_REQUEST['url_tilkee'];
 }
 if (isset($_REQUEST['user_scheduler'])) {
     $cfg->config['tilkee']['user_scheduler'] = $_REQUEST['user_scheduler'];