示例#1
0
 /** This function should be overridden in each module.  It marks an item as deleted.
  * If it is not overridden, then marking this type of item is not allowed
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
  * All Rights Reserved..
  * Contributor(s): ______________________________________..
  */
 function mark_deleted($id)
 {
     global $log;
     $log->debug("Entering mark_deleted() method ...");
     $entityArr = getEntityTableById($id);
     $tablename = $entityArr["tablename"];
     $entityidfield = $entityArr["entityidfield"];
     $query = "UPDATE " . $tablename . " set deleted=1 where " . $entityidfield . "='{$id}'";
     $this->db->query($query, true, "Error marking record deleted: ");
     $log->debug("Exiting mark_deleted method ...");
 }
示例#2
0
/**
 * This function is used to get the days in between the current time and the modified time of an entity .
 * Takes the input parameter as $id - crmid  it will calculate the number of days in between the
 * the current time and the modified time from the ec_crmentity ec_table and return the result as a string.
 * The return format is updated <No of Days> day ago <(date when updated)>
 */
function updateInfo($id)
{
    global $log;
    $log->debug("Entering updateInfo() method ...");
    global $adb;
    global $app_strings;
    $entityArr = getEntityTableById($id);
    $tablename = $entityArr["tablename"];
    $entityidfield = $entityArr["entityidfield"];
    $update_info = "";
    if ($tablename != "") {
        $query = "select modifiedtime from " . $tablename . " where deleted=0 and " . $entityidfield . " ='" . $id . "'";
        $result = $adb->query($query);
        $rownum = $adb->num_rows($result);
        if ($rownum > 0) {
            $modifiedtime = $adb->query_result($result, 0, 'modifiedtime');
            $values = explode(' ', $modifiedtime);
            $date_info = explode('-', $values[0]);
            $time_info = explode(':', $values[1]);
            if (count($date_info) < 3 || count($time_info) < 3) {
                return "";
            }
            $date = $date_info[2] . ' ' . $app_strings[date("M", mktime(0, 0, 0, $date_info[1], $date_info[2], $date_info[0]))] . ' ' . $date_info[0];
            $time_modified = mktime($time_info[0], $time_info[1], $time_info[2], $date_info[1], $date_info[2], $date_info[0]);
            $time_now = time();
            $days_diff = (int) (($time_now - $time_modified) / (60 * 60 * 24));
            if ($days_diff == 0) {
                $update_info = $app_strings['LBL_UPDATED_TODAY'] . " (" . $modifiedtime . ")";
            } elseif ($days_diff == 1) {
                $update_info = $days_diff . $app_strings['LBL_DAY_AGO'] . $app_strings['LBL_UPDATED'] . " (" . $modifiedtime . ")";
            } else {
                $update_info = $days_diff . $app_strings['LBL_DAYS_AGO'] . $app_strings['LBL_UPDATED'] . " (" . $modifiedtime . ")";
            }
        }
    }
    $log->debug("Exiting updateInfo method ...");
    return $update_info;
}