@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | return 1; |
| 107 | 107 | } |
| 108 | 108 | else |
| 109 | - { |
|
| 109 | + { |
|
| 110 | 110 | $this->db->free($resql); |
| 111 | 111 | return 0; |
| 112 | 112 | } |
@@ -176,30 +176,30 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | if ($qualified) |
| 178 | 178 | { |
| 179 | - $keyfortrans=''; |
|
| 180 | - $transcode=''; |
|
| 181 | - $code=$obj->code; |
|
| 182 | - if ($onlyautoornot > 0 && $code == 'AC_OTH') $code='AC_MANUAL'; |
|
| 183 | - if ($onlyautoornot > 0 && $code == 'AC_OTH_AUTO') $code='AC_AUTO'; |
|
| 184 | - if ($shortlabel) |
|
| 185 | - { |
|
| 186 | - $keyfortrans="Action".$code.'Short'; |
|
| 187 | - $transcode=$langs->trans($keyfortrans); |
|
| 188 | - } |
|
| 189 | - if (empty($keyfortrans) || $keyfortrans == $transcode) |
|
| 190 | - { |
|
| 191 | - $keyfortrans="Action".$code; |
|
| 192 | - $transcode=$langs->trans($keyfortrans); |
|
| 193 | - } |
|
| 194 | - $label = (($transcode!=$keyfortrans) ? $transcode : $langs->trans($obj->label)); |
|
| 179 | + $keyfortrans=''; |
|
| 180 | + $transcode=''; |
|
| 181 | + $code=$obj->code; |
|
| 182 | + if ($onlyautoornot > 0 && $code == 'AC_OTH') $code='AC_MANUAL'; |
|
| 183 | + if ($onlyautoornot > 0 && $code == 'AC_OTH_AUTO') $code='AC_AUTO'; |
|
| 184 | + if ($shortlabel) |
|
| 185 | + { |
|
| 186 | + $keyfortrans="Action".$code.'Short'; |
|
| 187 | + $transcode=$langs->trans($keyfortrans); |
|
| 188 | + } |
|
| 189 | + if (empty($keyfortrans) || $keyfortrans == $transcode) |
|
| 190 | + { |
|
| 191 | + $keyfortrans="Action".$code; |
|
| 192 | + $transcode=$langs->trans($keyfortrans); |
|
| 193 | + } |
|
| 194 | + $label = (($transcode!=$keyfortrans) ? $transcode : $langs->trans($obj->label)); |
|
| 195 | 195 | if ($onlyautoornot == -1 && ! empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! preg_match('/auto/i', $code)) |
| 196 | 196 | { |
| 197 | 197 | $label=' '.$label; |
| 198 | 198 | $repid[-99]=$langs->trans("ActionAC_MANUAL"); |
| 199 | 199 | $repcode['AC_NON_AUTO']=$langs->trans("ActionAC_MANUAL"); |
| 200 | 200 | } |
| 201 | - $repid[$obj->id] = $label; |
|
| 202 | - $repcode[$obj->code] = $label; |
|
| 201 | + $repid[$obj->id] = $label; |
|
| 202 | + $repcode[$obj->code] = $label; |
|
| 203 | 203 | if ($onlyautoornot > 0 && preg_match('/^module/',$obj->type) && $obj->module) $repcode[$obj->code].=' ('.$langs->trans("Module").': '.$obj->module.')'; |
| 204 | 204 | } |
| 205 | 205 | $i++; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @var string Error code (or message) |
| 33 | 33 | */ |
| 34 | - public $error=''; |
|
| 34 | + public $error = ''; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @var DoliDB Database handler. |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public $code; |
| 47 | 47 | public $type; |
| 48 | - public $libelle; // deprecated |
|
| 48 | + public $libelle; // deprecated |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @var string Type of agenda event label |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public $picto; |
| 62 | 62 | |
| 63 | - public $type_actions=array(); |
|
| 63 | + public $type_actions = array(); |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | function fetch($id) |
| 83 | 83 | { |
| 84 | 84 | $sql = "SELECT id, code, type, libelle as label, color, active, picto"; |
| 85 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
|
| 86 | - if (is_numeric($id)) $sql.= " WHERE id=".$id; |
|
| 87 | - else $sql.= " WHERE code='".$id."'"; |
|
| 85 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
|
| 86 | + if (is_numeric($id)) $sql .= " WHERE id=".$id; |
|
| 87 | + else $sql .= " WHERE code='".$id."'"; |
|
| 88 | 88 | |
| 89 | 89 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 90 | - $resql=$this->db->query($sql); |
|
| 90 | + $resql = $this->db->query($sql); |
|
| 91 | 91 | if ($resql) |
| 92 | 92 | { |
| 93 | 93 | if ($this->db->num_rows($resql)) |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $this->id = $obj->id; |
| 98 | 98 | $this->code = $obj->code; |
| 99 | 99 | $this->type = $obj->type; |
| 100 | - $this->libelle = $obj->label; // deprecated |
|
| 100 | + $this->libelle = $obj->label; // deprecated |
|
| 101 | 101 | $this->label = $obj->label; |
| 102 | 102 | $this->active = $obj->active; |
| 103 | 103 | $this->color = $obj->color; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | else |
| 115 | 115 | { |
| 116 | - $this->error=$this->db->error(); |
|
| 116 | + $this->error = $this->db->error(); |
|
| 117 | 117 | return -1; |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -130,25 +130,25 @@ discard block |
||
| 130 | 130 | * @param int $shortlabel 1=Get short label instead of long label |
| 131 | 131 | * @return mixed Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. |
| 132 | 132 | */ |
| 133 | - function liste_array($active='',$idorcode='id',$excludetype='',$onlyautoornot=0, $morefilter='', $shortlabel=0) |
|
| 133 | + function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0) |
|
| 134 | 134 | { |
| 135 | 135 | // phpcs:enable |
| 136 | - global $langs,$conf; |
|
| 136 | + global $langs, $conf; |
|
| 137 | 137 | $langs->load("commercial"); |
| 138 | 138 | |
| 139 | 139 | $repid = array(); |
| 140 | 140 | $repcode = array(); |
| 141 | 141 | |
| 142 | 142 | $sql = "SELECT id, code, libelle as label, module, type, color, picto"; |
| 143 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
|
| 144 | - $sql.= " WHERE 1=1"; |
|
| 145 | - if ($active != '') $sql.=" AND active=".$active; |
|
| 146 | - if (! empty($excludetype)) $sql.=" AND type <> '".$excludetype."'"; |
|
| 147 | - if ($morefilter) $sql.=" AND ".$morefilter; |
|
| 148 | - $sql.= " ORDER BY module, position, type"; |
|
| 143 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
|
| 144 | + $sql .= " WHERE 1=1"; |
|
| 145 | + if ($active != '') $sql .= " AND active=".$active; |
|
| 146 | + if (!empty($excludetype)) $sql .= " AND type <> '".$excludetype."'"; |
|
| 147 | + if ($morefilter) $sql .= " AND ".$morefilter; |
|
| 148 | + $sql .= " ORDER BY module, position, type"; |
|
| 149 | 149 | |
| 150 | 150 | dol_syslog(get_class($this)."::liste_array", LOG_DEBUG); |
| 151 | - $resql=$this->db->query($sql); |
|
| 151 | + $resql = $this->db->query($sql); |
|
| 152 | 152 | if ($resql) |
| 153 | 153 | { |
| 154 | 154 | $nump = $this->db->num_rows($resql); |
@@ -159,59 +159,59 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $obj = $this->db->fetch_object($resql); |
| 161 | 161 | |
| 162 | - $qualified=1; |
|
| 162 | + $qualified = 1; |
|
| 163 | 163 | |
| 164 | 164 | // $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto |
| 165 | - if ($qualified && $onlyautoornot > 0 && preg_match('/^system/',$obj->type) && ! preg_match('/^AC_OTH/',$obj->code)) $qualified=0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) |
|
| 165 | + if ($qualified && $onlyautoornot > 0 && preg_match('/^system/', $obj->type) && !preg_match('/^AC_OTH/', $obj->code)) $qualified = 0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) |
|
| 166 | 166 | |
| 167 | 167 | if ($qualified && $obj->module) |
| 168 | 168 | { |
| 169 | - if ($obj->module == 'invoice' && ! $conf->facture->enabled) $qualified=0; |
|
| 170 | - if ($obj->module == 'order' && ! $conf->commande->enabled) $qualified=0; |
|
| 171 | - if ($obj->module == 'propal' && ! $conf->propal->enabled) $qualified=0; |
|
| 172 | - if ($obj->module == 'invoice_supplier' && ! $conf->fournisseur->enabled) $qualified=0; |
|
| 173 | - if ($obj->module == 'order_supplier' && ! $conf->fournisseur->enabled) $qualified=0; |
|
| 174 | - if ($obj->module == 'shipping' && ! $conf->expedition->enabled) $qualified=0; |
|
| 169 | + if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified = 0; |
|
| 170 | + if ($obj->module == 'order' && !$conf->commande->enabled) $qualified = 0; |
|
| 171 | + if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified = 0; |
|
| 172 | + if ($obj->module == 'invoice_supplier' && !$conf->fournisseur->enabled) $qualified = 0; |
|
| 173 | + if ($obj->module == 'order_supplier' && !$conf->fournisseur->enabled) $qualified = 0; |
|
| 174 | + if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified = 0; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if ($qualified) |
| 178 | 178 | { |
| 179 | - $keyfortrans=''; |
|
| 180 | - $transcode=''; |
|
| 181 | - $code=$obj->code; |
|
| 182 | - if ($onlyautoornot > 0 && $code == 'AC_OTH') $code='AC_MANUAL'; |
|
| 183 | - if ($onlyautoornot > 0 && $code == 'AC_OTH_AUTO') $code='AC_AUTO'; |
|
| 179 | + $keyfortrans = ''; |
|
| 180 | + $transcode = ''; |
|
| 181 | + $code = $obj->code; |
|
| 182 | + if ($onlyautoornot > 0 && $code == 'AC_OTH') $code = 'AC_MANUAL'; |
|
| 183 | + if ($onlyautoornot > 0 && $code == 'AC_OTH_AUTO') $code = 'AC_AUTO'; |
|
| 184 | 184 | if ($shortlabel) |
| 185 | 185 | { |
| 186 | - $keyfortrans="Action".$code.'Short'; |
|
| 187 | - $transcode=$langs->trans($keyfortrans); |
|
| 186 | + $keyfortrans = "Action".$code.'Short'; |
|
| 187 | + $transcode = $langs->trans($keyfortrans); |
|
| 188 | 188 | } |
| 189 | 189 | if (empty($keyfortrans) || $keyfortrans == $transcode) |
| 190 | 190 | { |
| 191 | - $keyfortrans="Action".$code; |
|
| 192 | - $transcode=$langs->trans($keyfortrans); |
|
| 191 | + $keyfortrans = "Action".$code; |
|
| 192 | + $transcode = $langs->trans($keyfortrans); |
|
| 193 | 193 | } |
| 194 | - $label = (($transcode!=$keyfortrans) ? $transcode : $langs->trans($obj->label)); |
|
| 195 | - if ($onlyautoornot == -1 && ! empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! preg_match('/auto/i', $code)) |
|
| 194 | + $label = (($transcode != $keyfortrans) ? $transcode : $langs->trans($obj->label)); |
|
| 195 | + if ($onlyautoornot == -1 && !empty($conf->global->AGENDA_USE_EVENT_TYPE) && !preg_match('/auto/i', $code)) |
|
| 196 | 196 | { |
| 197 | - $label=' '.$label; |
|
| 198 | - $repid[-99]=$langs->trans("ActionAC_MANUAL"); |
|
| 199 | - $repcode['AC_NON_AUTO']=$langs->trans("ActionAC_MANUAL"); |
|
| 197 | + $label = ' '.$label; |
|
| 198 | + $repid[-99] = $langs->trans("ActionAC_MANUAL"); |
|
| 199 | + $repcode['AC_NON_AUTO'] = $langs->trans("ActionAC_MANUAL"); |
|
| 200 | 200 | } |
| 201 | 201 | $repid[$obj->id] = $label; |
| 202 | 202 | $repcode[$obj->code] = $label; |
| 203 | - if ($onlyautoornot > 0 && preg_match('/^module/',$obj->type) && $obj->module) $repcode[$obj->code].=' ('.$langs->trans("Module").': '.$obj->module.')'; |
|
| 203 | + if ($onlyautoornot > 0 && preg_match('/^module/', $obj->type) && $obj->module) $repcode[$obj->code] .= ' ('.$langs->trans("Module").': '.$obj->module.')'; |
|
| 204 | 204 | } |
| 205 | 205 | $i++; |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | - if ($idorcode == 'id') $this->liste_array=$repid; |
|
| 209 | - if ($idorcode == 'code') $this->liste_array=$repcode; |
|
| 208 | + if ($idorcode == 'id') $this->liste_array = $repid; |
|
| 209 | + if ($idorcode == 'code') $this->liste_array = $repcode; |
|
| 210 | 210 | return $this->liste_array; |
| 211 | 211 | } |
| 212 | 212 | else |
| 213 | 213 | { |
| 214 | - $this->error=$this->db->lasterror(); |
|
| 214 | + $this->error = $this->db->lasterror(); |
|
| 215 | 215 | return -1; |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -223,12 +223,12 @@ discard block |
||
| 223 | 223 | * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only |
| 224 | 224 | * @return string Label of action type |
| 225 | 225 | */ |
| 226 | - function getNomUrl($withpicto=0) |
|
| 226 | + function getNomUrl($withpicto = 0) |
|
| 227 | 227 | { |
| 228 | 228 | global $langs; |
| 229 | 229 | |
| 230 | 230 | // Check if translation available |
| 231 | - $transcode=$langs->trans("Action".$this->code); |
|
| 231 | + $transcode = $langs->trans("Action".$this->code); |
|
| 232 | 232 | if ($transcode != "Action".$this->code) return $transcode; |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -83,8 +83,11 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | $sql = "SELECT id, code, type, libelle as label, color, active, picto"; |
| 85 | 85 | $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
| 86 | - if (is_numeric($id)) $sql.= " WHERE id=".$id; |
|
| 87 | - else $sql.= " WHERE code='".$id."'"; |
|
| 86 | + if (is_numeric($id)) { |
|
| 87 | + $sql.= " WHERE id=".$id; |
|
| 88 | + } else { |
|
| 89 | + $sql.= " WHERE code='".$id."'"; |
|
| 90 | + } |
|
| 88 | 91 | |
| 89 | 92 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 90 | 93 | $resql=$this->db->query($sql); |
@@ -104,14 +107,12 @@ discard block |
||
| 104 | 107 | |
| 105 | 108 | $this->db->free($resql); |
| 106 | 109 | return 1; |
| 107 | - } |
|
| 108 | - else |
|
| 110 | + } else |
|
| 109 | 111 | { |
| 110 | 112 | $this->db->free($resql); |
| 111 | 113 | return 0; |
| 112 | 114 | } |
| 113 | - } |
|
| 114 | - else |
|
| 115 | + } else |
|
| 115 | 116 | { |
| 116 | 117 | $this->error=$this->db->error(); |
| 117 | 118 | return -1; |
@@ -142,9 +143,15 @@ discard block |
||
| 142 | 143 | $sql = "SELECT id, code, libelle as label, module, type, color, picto"; |
| 143 | 144 | $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
| 144 | 145 | $sql.= " WHERE 1=1"; |
| 145 | - if ($active != '') $sql.=" AND active=".$active; |
|
| 146 | - if (! empty($excludetype)) $sql.=" AND type <> '".$excludetype."'"; |
|
| 147 | - if ($morefilter) $sql.=" AND ".$morefilter; |
|
| 146 | + if ($active != '') { |
|
| 147 | + $sql.=" AND active=".$active; |
|
| 148 | + } |
|
| 149 | + if (! empty($excludetype)) { |
|
| 150 | + $sql.=" AND type <> '".$excludetype."'"; |
|
| 151 | + } |
|
| 152 | + if ($morefilter) { |
|
| 153 | + $sql.=" AND ".$morefilter; |
|
| 154 | + } |
|
| 148 | 155 | $sql.= " ORDER BY module, position, type"; |
| 149 | 156 | |
| 150 | 157 | dol_syslog(get_class($this)."::liste_array", LOG_DEBUG); |
@@ -162,16 +169,31 @@ discard block |
||
| 162 | 169 | $qualified=1; |
| 163 | 170 | |
| 164 | 171 | // $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto |
| 165 | - if ($qualified && $onlyautoornot > 0 && preg_match('/^system/',$obj->type) && ! preg_match('/^AC_OTH/',$obj->code)) $qualified=0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) |
|
| 172 | + if ($qualified && $onlyautoornot > 0 && preg_match('/^system/',$obj->type) && ! preg_match('/^AC_OTH/',$obj->code)) { |
|
| 173 | + $qualified=0; |
|
| 174 | + } |
|
| 175 | + // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) |
|
| 166 | 176 | |
| 167 | 177 | if ($qualified && $obj->module) |
| 168 | 178 | { |
| 169 | - if ($obj->module == 'invoice' && ! $conf->facture->enabled) $qualified=0; |
|
| 170 | - if ($obj->module == 'order' && ! $conf->commande->enabled) $qualified=0; |
|
| 171 | - if ($obj->module == 'propal' && ! $conf->propal->enabled) $qualified=0; |
|
| 172 | - if ($obj->module == 'invoice_supplier' && ! $conf->fournisseur->enabled) $qualified=0; |
|
| 173 | - if ($obj->module == 'order_supplier' && ! $conf->fournisseur->enabled) $qualified=0; |
|
| 174 | - if ($obj->module == 'shipping' && ! $conf->expedition->enabled) $qualified=0; |
|
| 179 | + if ($obj->module == 'invoice' && ! $conf->facture->enabled) { |
|
| 180 | + $qualified=0; |
|
| 181 | + } |
|
| 182 | + if ($obj->module == 'order' && ! $conf->commande->enabled) { |
|
| 183 | + $qualified=0; |
|
| 184 | + } |
|
| 185 | + if ($obj->module == 'propal' && ! $conf->propal->enabled) { |
|
| 186 | + $qualified=0; |
|
| 187 | + } |
|
| 188 | + if ($obj->module == 'invoice_supplier' && ! $conf->fournisseur->enabled) { |
|
| 189 | + $qualified=0; |
|
| 190 | + } |
|
| 191 | + if ($obj->module == 'order_supplier' && ! $conf->fournisseur->enabled) { |
|
| 192 | + $qualified=0; |
|
| 193 | + } |
|
| 194 | + if ($obj->module == 'shipping' && ! $conf->expedition->enabled) { |
|
| 195 | + $qualified=0; |
|
| 196 | + } |
|
| 175 | 197 | } |
| 176 | 198 | |
| 177 | 199 | if ($qualified) |
@@ -179,8 +201,12 @@ discard block |
||
| 179 | 201 | $keyfortrans=''; |
| 180 | 202 | $transcode=''; |
| 181 | 203 | $code=$obj->code; |
| 182 | - if ($onlyautoornot > 0 && $code == 'AC_OTH') $code='AC_MANUAL'; |
|
| 183 | - if ($onlyautoornot > 0 && $code == 'AC_OTH_AUTO') $code='AC_AUTO'; |
|
| 204 | + if ($onlyautoornot > 0 && $code == 'AC_OTH') { |
|
| 205 | + $code='AC_MANUAL'; |
|
| 206 | + } |
|
| 207 | + if ($onlyautoornot > 0 && $code == 'AC_OTH_AUTO') { |
|
| 208 | + $code='AC_AUTO'; |
|
| 209 | + } |
|
| 184 | 210 | if ($shortlabel) |
| 185 | 211 | { |
| 186 | 212 | $keyfortrans="Action".$code.'Short'; |
@@ -200,16 +226,21 @@ discard block |
||
| 200 | 226 | } |
| 201 | 227 | $repid[$obj->id] = $label; |
| 202 | 228 | $repcode[$obj->code] = $label; |
| 203 | - if ($onlyautoornot > 0 && preg_match('/^module/',$obj->type) && $obj->module) $repcode[$obj->code].=' ('.$langs->trans("Module").': '.$obj->module.')'; |
|
| 229 | + if ($onlyautoornot > 0 && preg_match('/^module/',$obj->type) && $obj->module) { |
|
| 230 | + $repcode[$obj->code].=' ('.$langs->trans("Module").': '.$obj->module.')'; |
|
| 231 | + } |
|
| 204 | 232 | } |
| 205 | 233 | $i++; |
| 206 | 234 | } |
| 207 | 235 | } |
| 208 | - if ($idorcode == 'id') $this->liste_array=$repid; |
|
| 209 | - if ($idorcode == 'code') $this->liste_array=$repcode; |
|
| 236 | + if ($idorcode == 'id') { |
|
| 237 | + $this->liste_array=$repid; |
|
| 238 | + } |
|
| 239 | + if ($idorcode == 'code') { |
|
| 240 | + $this->liste_array=$repcode; |
|
| 241 | + } |
|
| 210 | 242 | return $this->liste_array; |
| 211 | - } |
|
| 212 | - else |
|
| 243 | + } else |
|
| 213 | 244 | { |
| 214 | 245 | $this->error=$this->db->lasterror(); |
| 215 | 246 | return -1; |
@@ -229,6 +260,8 @@ discard block |
||
| 229 | 260 | |
| 230 | 261 | // Check if translation available |
| 231 | 262 | $transcode=$langs->trans("Action".$this->code); |
| 232 | - if ($transcode != "Action".$this->code) return $transcode; |
|
| 263 | + if ($transcode != "Action".$this->code) { |
|
| 264 | + return $transcode; |
|
| 265 | + } |
|
| 233 | 266 | } |
| 234 | 267 | } |
@@ -30,212 +30,212 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class ActionCommReminder extends CommonObject |
| 32 | 32 | { |
| 33 | - /** |
|
| 34 | - * @var string ID to identify managed object |
|
| 35 | - */ |
|
| 36 | - public $element = 'actioncomm_reminder'; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var string Name of table without prefix where object is stored |
|
| 40 | - */ |
|
| 41 | - public $table_element = 'actioncomm_reminder'; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var array Does actioncommreminder support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 45 | - */ |
|
| 46 | - public $ismultientitymanaged = 0; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var string String with name of icon for actioncommreminder. Must be the part after the 'object_' into object_actioncommreminder.png |
|
| 50 | - */ |
|
| 51 | - public $picto = 'generic'; |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * 'type' if the field format. |
|
| 56 | - * 'label' the translation key. |
|
| 57 | - * 'enabled' is a condition when the field must be managed. |
|
| 58 | - * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) |
|
| 59 | - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). |
|
| 60 | - * 'index' if we want an index in database. |
|
| 61 | - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). |
|
| 62 | - * 'position' is the sort order of field. |
|
| 63 | - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. |
|
| 64 | - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). |
|
| 65 | - * 'help' is a string visible as a tooltip on field |
|
| 66 | - * 'comment' is not used. You can store here any text of your choice. It is not used by application. |
|
| 67 | - * 'default' is a default value for creation (can still be replaced by the global setup of default values) |
|
| 68 | - * 'showoncombobox' if field must be shown into the label of combobox |
|
| 69 | - */ |
|
| 70 | - |
|
| 71 | - // BEGIN MODULEBUILDER PROPERTIES |
|
| 72 | - /** |
|
| 73 | - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
|
| 74 | - */ |
|
| 75 | - public $fields=array( |
|
| 76 | - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), |
|
| 77 | - 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), |
|
| 78 | - 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), |
|
| 79 | - 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), |
|
| 80 | - 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), |
|
| 81 | - 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"m, h, d, w",), |
|
| 82 | - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')), |
|
| 83 | - ); |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @var int ID |
|
| 87 | - */ |
|
| 88 | - public $rowid; |
|
| 89 | - |
|
| 90 | - public $dateremind; |
|
| 91 | - public $typeremind; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @var int User ID |
|
| 95 | - */ |
|
| 96 | - public $fk_user; |
|
| 97 | - |
|
| 98 | - public $offsetvalue; |
|
| 99 | - public $offsetunit; |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * @var int Status |
|
| 103 | - */ |
|
| 104 | - public $status; |
|
| 105 | - |
|
| 106 | - // END MODULEBUILDER PROPERTIES |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Constructor |
|
| 112 | - * |
|
| 113 | - * @param DoliDb $db Database handler |
|
| 114 | - */ |
|
| 115 | - public function __construct(DoliDB $db) |
|
| 116 | - { |
|
| 117 | - global $conf; |
|
| 118 | - |
|
| 119 | - $this->db = $db; |
|
| 120 | - |
|
| 121 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
| 122 | - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Create object into database |
|
| 127 | - * |
|
| 128 | - * @param User $user User that creates |
|
| 129 | - * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
| 130 | - * @return int <0 if KO, Id of created object if OK |
|
| 131 | - */ |
|
| 132 | - public function create(User $user, $notrigger = false) |
|
| 133 | - { |
|
| 134 | - return $this->createCommon($user, $notrigger); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Load object in memory from the database |
|
| 140 | - * |
|
| 141 | - * @param int $id Id object |
|
| 142 | - * @param string $ref Ref |
|
| 143 | - * @return int <0 if KO, 0 if not found, >0 if OK |
|
| 144 | - */ |
|
| 145 | - public function fetch($id, $ref = null) |
|
| 146 | - { |
|
| 147 | - $result = $this->fetchCommon($id, $ref); |
|
| 148 | - return $result; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Update object into database |
|
| 153 | - * |
|
| 154 | - * @param User $user User that modifies |
|
| 155 | - * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
| 156 | - * @return int <0 if KO, >0 if OK |
|
| 157 | - */ |
|
| 158 | - public function update(User $user, $notrigger = false) |
|
| 159 | - { |
|
| 160 | - return $this->updateCommon($user, $notrigger); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Delete object in database |
|
| 165 | - * |
|
| 166 | - * @param User $user User that deletes |
|
| 167 | - * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
| 168 | - * @return int <0 if KO, >0 if OK |
|
| 169 | - */ |
|
| 170 | - public function delete(User $user, $notrigger = false) |
|
| 171 | - { |
|
| 172 | - return $this->deleteCommon($user, $notrigger); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Retourne le libelle du status d'un user (actif, inactif) |
|
| 177 | - * |
|
| 178 | - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
|
| 179 | - * @return string Label of status |
|
| 180 | - */ |
|
| 181 | - function getLibStatut($mode=0) |
|
| 182 | - { |
|
| 183 | - return $this->LibStatut($this->status,$mode); |
|
| 184 | - } |
|
| 33 | + /** |
|
| 34 | + * @var string ID to identify managed object |
|
| 35 | + */ |
|
| 36 | + public $element = 'actioncomm_reminder'; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var string Name of table without prefix where object is stored |
|
| 40 | + */ |
|
| 41 | + public $table_element = 'actioncomm_reminder'; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var array Does actioncommreminder support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 45 | + */ |
|
| 46 | + public $ismultientitymanaged = 0; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var string String with name of icon for actioncommreminder. Must be the part after the 'object_' into object_actioncommreminder.png |
|
| 50 | + */ |
|
| 51 | + public $picto = 'generic'; |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * 'type' if the field format. |
|
| 56 | + * 'label' the translation key. |
|
| 57 | + * 'enabled' is a condition when the field must be managed. |
|
| 58 | + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) |
|
| 59 | + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). |
|
| 60 | + * 'index' if we want an index in database. |
|
| 61 | + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). |
|
| 62 | + * 'position' is the sort order of field. |
|
| 63 | + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. |
|
| 64 | + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). |
|
| 65 | + * 'help' is a string visible as a tooltip on field |
|
| 66 | + * 'comment' is not used. You can store here any text of your choice. It is not used by application. |
|
| 67 | + * 'default' is a default value for creation (can still be replaced by the global setup of default values) |
|
| 68 | + * 'showoncombobox' if field must be shown into the label of combobox |
|
| 69 | + */ |
|
| 70 | + |
|
| 71 | + // BEGIN MODULEBUILDER PROPERTIES |
|
| 72 | + /** |
|
| 73 | + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
|
| 74 | + */ |
|
| 75 | + public $fields=array( |
|
| 76 | + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), |
|
| 77 | + 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), |
|
| 78 | + 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), |
|
| 79 | + 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), |
|
| 80 | + 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), |
|
| 81 | + 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"m, h, d, w",), |
|
| 82 | + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')), |
|
| 83 | + ); |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @var int ID |
|
| 87 | + */ |
|
| 88 | + public $rowid; |
|
| 89 | + |
|
| 90 | + public $dateremind; |
|
| 91 | + public $typeremind; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @var int User ID |
|
| 95 | + */ |
|
| 96 | + public $fk_user; |
|
| 97 | + |
|
| 98 | + public $offsetvalue; |
|
| 99 | + public $offsetunit; |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * @var int Status |
|
| 103 | + */ |
|
| 104 | + public $status; |
|
| 105 | + |
|
| 106 | + // END MODULEBUILDER PROPERTIES |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Constructor |
|
| 112 | + * |
|
| 113 | + * @param DoliDb $db Database handler |
|
| 114 | + */ |
|
| 115 | + public function __construct(DoliDB $db) |
|
| 116 | + { |
|
| 117 | + global $conf; |
|
| 118 | + |
|
| 119 | + $this->db = $db; |
|
| 120 | + |
|
| 121 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
| 122 | + if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Create object into database |
|
| 127 | + * |
|
| 128 | + * @param User $user User that creates |
|
| 129 | + * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
| 130 | + * @return int <0 if KO, Id of created object if OK |
|
| 131 | + */ |
|
| 132 | + public function create(User $user, $notrigger = false) |
|
| 133 | + { |
|
| 134 | + return $this->createCommon($user, $notrigger); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Load object in memory from the database |
|
| 140 | + * |
|
| 141 | + * @param int $id Id object |
|
| 142 | + * @param string $ref Ref |
|
| 143 | + * @return int <0 if KO, 0 if not found, >0 if OK |
|
| 144 | + */ |
|
| 145 | + public function fetch($id, $ref = null) |
|
| 146 | + { |
|
| 147 | + $result = $this->fetchCommon($id, $ref); |
|
| 148 | + return $result; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Update object into database |
|
| 153 | + * |
|
| 154 | + * @param User $user User that modifies |
|
| 155 | + * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
| 156 | + * @return int <0 if KO, >0 if OK |
|
| 157 | + */ |
|
| 158 | + public function update(User $user, $notrigger = false) |
|
| 159 | + { |
|
| 160 | + return $this->updateCommon($user, $notrigger); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Delete object in database |
|
| 165 | + * |
|
| 166 | + * @param User $user User that deletes |
|
| 167 | + * @param bool $notrigger false=launch triggers after, true=disable triggers |
|
| 168 | + * @return int <0 if KO, >0 if OK |
|
| 169 | + */ |
|
| 170 | + public function delete(User $user, $notrigger = false) |
|
| 171 | + { |
|
| 172 | + return $this->deleteCommon($user, $notrigger); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Retourne le libelle du status d'un user (actif, inactif) |
|
| 177 | + * |
|
| 178 | + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
|
| 179 | + * @return string Label of status |
|
| 180 | + */ |
|
| 181 | + function getLibStatut($mode=0) |
|
| 182 | + { |
|
| 183 | + return $this->LibStatut($this->status,$mode); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
| 187 | - /** |
|
| 188 | - * Return the status |
|
| 189 | - * |
|
| 190 | - * @param int $status Id status |
|
| 191 | - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto |
|
| 192 | - * @return string Label of status |
|
| 193 | - */ |
|
| 194 | - static function LibStatut($status,$mode=0) |
|
| 195 | - { |
|
| 187 | + /** |
|
| 188 | + * Return the status |
|
| 189 | + * |
|
| 190 | + * @param int $status Id status |
|
| 191 | + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto |
|
| 192 | + * @return string Label of status |
|
| 193 | + */ |
|
| 194 | + static function LibStatut($status,$mode=0) |
|
| 195 | + { |
|
| 196 | 196 | // phpcs:enable |
| 197 | - global $langs; |
|
| 198 | - |
|
| 199 | - if ($mode == 0 || $mode == 1) |
|
| 200 | - { |
|
| 201 | - if ($status == 1) return $langs->trans('Done'); |
|
| 202 | - elseif ($status == 0) return $langs->trans('ToDo'); |
|
| 203 | - } |
|
| 204 | - elseif ($mode == 2) |
|
| 205 | - { |
|
| 206 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 207 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 208 | - } |
|
| 209 | - elseif ($mode == 3) |
|
| 210 | - { |
|
| 211 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4'); |
|
| 212 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5'); |
|
| 213 | - } |
|
| 214 | - elseif ($mode == 4) |
|
| 215 | - { |
|
| 216 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 217 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 218 | - } |
|
| 219 | - elseif ($mode == 5) |
|
| 220 | - { |
|
| 221 | - if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 222 | - elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 223 | - } |
|
| 224 | - elseif ($mode == 6) |
|
| 225 | - { |
|
| 226 | - if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 227 | - elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Initialise object with example values |
|
| 233 | - * Id must be 0 if object instance is a specimen |
|
| 234 | - * |
|
| 235 | - * @return void |
|
| 236 | - */ |
|
| 237 | - public function initAsSpecimen() |
|
| 238 | - { |
|
| 239 | - $this->initAsSpecimenCommon(); |
|
| 240 | - } |
|
| 197 | + global $langs; |
|
| 198 | + |
|
| 199 | + if ($mode == 0 || $mode == 1) |
|
| 200 | + { |
|
| 201 | + if ($status == 1) return $langs->trans('Done'); |
|
| 202 | + elseif ($status == 0) return $langs->trans('ToDo'); |
|
| 203 | + } |
|
| 204 | + elseif ($mode == 2) |
|
| 205 | + { |
|
| 206 | + if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 207 | + elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 208 | + } |
|
| 209 | + elseif ($mode == 3) |
|
| 210 | + { |
|
| 211 | + if ($status == 1) return img_picto($langs->trans('Done'),'statut4'); |
|
| 212 | + elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5'); |
|
| 213 | + } |
|
| 214 | + elseif ($mode == 4) |
|
| 215 | + { |
|
| 216 | + if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 217 | + elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 218 | + } |
|
| 219 | + elseif ($mode == 5) |
|
| 220 | + { |
|
| 221 | + if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 222 | + elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 223 | + } |
|
| 224 | + elseif ($mode == 6) |
|
| 225 | + { |
|
| 226 | + if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 227 | + elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Initialise object with example values |
|
| 233 | + * Id must be 0 if object instance is a specimen |
|
| 234 | + * |
|
| 235 | + * @return void |
|
| 236 | + */ |
|
| 237 | + public function initAsSpecimen() |
|
| 238 | + { |
|
| 239 | + $this->initAsSpecimenCommon(); |
|
| 240 | + } |
|
| 241 | 241 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | 24 | // Put here all includes required by your class file |
| 25 | -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; |
|
| 25 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | /** |
| 73 | 73 | * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
| 74 | 74 | */ |
| 75 | - public $fields=array( |
|
| 75 | + public $fields = array( |
|
| 76 | 76 | 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), |
| 77 | 77 | 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), |
| 78 | 78 | 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $this->db = $db; |
| 120 | 120 | |
| 121 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
| 122 | - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
| 121 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; |
|
| 122 | + if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
| 179 | 179 | * @return string Label of status |
| 180 | 180 | */ |
| 181 | - function getLibStatut($mode=0) |
|
| 181 | + function getLibStatut($mode = 0) |
|
| 182 | 182 | { |
| 183 | - return $this->LibStatut($this->status,$mode); |
|
| 183 | + return $this->LibStatut($this->status, $mode); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto |
| 192 | 192 | * @return string Label of status |
| 193 | 193 | */ |
| 194 | - static function LibStatut($status,$mode=0) |
|
| 194 | + static function LibStatut($status, $mode = 0) |
|
| 195 | 195 | { |
| 196 | 196 | // phpcs:enable |
| 197 | 197 | global $langs; |
@@ -203,28 +203,28 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | elseif ($mode == 2) |
| 205 | 205 | { |
| 206 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 207 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 206 | + if ($status == 1) return img_picto($langs->trans('Done'), 'statut4').' '.$langs->trans('Done'); |
|
| 207 | + elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5').' '.$langs->trans('ToDo'); |
|
| 208 | 208 | } |
| 209 | 209 | elseif ($mode == 3) |
| 210 | 210 | { |
| 211 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4'); |
|
| 212 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5'); |
|
| 211 | + if ($status == 1) return img_picto($langs->trans('Done'), 'statut4'); |
|
| 212 | + elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5'); |
|
| 213 | 213 | } |
| 214 | 214 | elseif ($mode == 4) |
| 215 | 215 | { |
| 216 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 217 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 216 | + if ($status == 1) return img_picto($langs->trans('Done'), 'statut4').' '.$langs->trans('Done'); |
|
| 217 | + elseif ($status == 0) return img_picto($langs->trans('ToDo'), 'statut5').' '.$langs->trans('ToDo'); |
|
| 218 | 218 | } |
| 219 | 219 | elseif ($mode == 5) |
| 220 | 220 | { |
| 221 | - if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 222 | - elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 221 | + if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'), 'statut4'); |
|
| 222 | + elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'), 'statut5'); |
|
| 223 | 223 | } |
| 224 | 224 | elseif ($mode == 6) |
| 225 | 225 | { |
| 226 | - if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 227 | - elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 226 | + if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'), 'statut4'); |
|
| 227 | + elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'), 'statut5'); |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
@@ -118,8 +118,12 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $this->db = $db; |
| 120 | 120 | |
| 121 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
| 122 | - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
| 121 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { |
|
| 122 | + $this->fields['rowid']['visible']=0; |
|
| 123 | + } |
|
| 124 | + if (empty($conf->multicompany->enabled)) { |
|
| 125 | + $this->fields['entity']['enabled']=0; |
|
| 126 | + } |
|
| 123 | 127 | } |
| 124 | 128 | |
| 125 | 129 | /** |
@@ -198,33 +202,46 @@ discard block |
||
| 198 | 202 | |
| 199 | 203 | if ($mode == 0 || $mode == 1) |
| 200 | 204 | { |
| 201 | - if ($status == 1) return $langs->trans('Done'); |
|
| 202 | - elseif ($status == 0) return $langs->trans('ToDo'); |
|
| 203 | - } |
|
| 204 | - elseif ($mode == 2) |
|
| 205 | + if ($status == 1) { |
|
| 206 | + return $langs->trans('Done'); |
|
| 207 | + } elseif ($status == 0) { |
|
| 208 | + return $langs->trans('ToDo'); |
|
| 209 | + } |
|
| 210 | + } elseif ($mode == 2) |
|
| 205 | 211 | { |
| 206 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 207 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 208 | - } |
|
| 209 | - elseif ($mode == 3) |
|
| 212 | + if ($status == 1) { |
|
| 213 | + return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 214 | + } elseif ($status == 0) { |
|
| 215 | + return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 216 | + } |
|
| 217 | + } elseif ($mode == 3) |
|
| 210 | 218 | { |
| 211 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4'); |
|
| 212 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5'); |
|
| 213 | - } |
|
| 214 | - elseif ($mode == 4) |
|
| 219 | + if ($status == 1) { |
|
| 220 | + return img_picto($langs->trans('Done'),'statut4'); |
|
| 221 | + } elseif ($status == 0) { |
|
| 222 | + return img_picto($langs->trans('ToDo'),'statut5'); |
|
| 223 | + } |
|
| 224 | + } elseif ($mode == 4) |
|
| 215 | 225 | { |
| 216 | - if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 217 | - elseif ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 218 | - } |
|
| 219 | - elseif ($mode == 5) |
|
| 226 | + if ($status == 1) { |
|
| 227 | + return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done'); |
|
| 228 | + } elseif ($status == 0) { |
|
| 229 | + return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo'); |
|
| 230 | + } |
|
| 231 | + } elseif ($mode == 5) |
|
| 220 | 232 | { |
| 221 | - if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 222 | - elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 223 | - } |
|
| 224 | - elseif ($mode == 6) |
|
| 233 | + if ($status == 1) { |
|
| 234 | + return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 235 | + } elseif ($status == 0) { |
|
| 236 | + return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 237 | + } |
|
| 238 | + } elseif ($mode == 6) |
|
| 225 | 239 | { |
| 226 | - if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 227 | - elseif ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 240 | + if ($status == 1) { |
|
| 241 | + return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4'); |
|
| 242 | + } elseif ($status == 0) { |
|
| 243 | + return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5'); |
|
| 244 | + } |
|
| 228 | 245 | } |
| 229 | 246 | } |
| 230 | 247 | |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | $tmparray=file($file); |
| 63 | 63 | if (is_array($tmparray)) |
| 64 | 64 | { |
| 65 | - $file_text = join("", $tmparray); //load file |
|
| 66 | - $file_text = preg_replace("/[\r\n]{1,} /","",$file_text); |
|
| 65 | + $file_text = join("", $tmparray); //load file |
|
| 66 | + $file_text = preg_replace("/[\r\n]{1,} /","",$file_text); |
|
| 67 | 67 | } |
| 68 | 68 | return $file_text; // return all text |
| 69 | 69 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin |
| 123 | 123 | list($key, $value) = $this->retun_key_value($text); |
| 124 | - //var_dump($text.' -> '.$key.' - '.$value); |
|
| 124 | + //var_dump($text.' -> '.$key.' - '.$value); |
|
| 125 | 125 | |
| 126 | 126 | switch ($text) // search special string |
| 127 | 127 | { |
@@ -167,30 +167,30 @@ discard block |
||
| 167 | 167 | break; |
| 168 | 168 | |
| 169 | 169 | default: // no special string (SUMMARY, DESCRIPTION, ...) |
| 170 | - if ($tmpvalue) |
|
| 171 | - { |
|
| 172 | - $tmpvalue .= $text; |
|
| 173 | - if (! preg_match('/=$/',$text)) // No more lines |
|
| 174 | - { |
|
| 175 | - $key=$tmpkey; |
|
| 176 | - $value=quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i','',$tmpvalue)); |
|
| 177 | - $tmpkey=''; |
|
| 178 | - $tmpvalue=''; |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i',$value)) |
|
| 182 | - { |
|
| 183 | - if (preg_match('/=$/',$value)) |
|
| 184 | - { |
|
| 185 | - $tmpkey=$key; |
|
| 186 | - $tmpvalue=$tmpvalue.preg_replace('/=$/',"",$value); // We must wait to have next line to have complete message |
|
| 187 | - } |
|
| 188 | - else |
|
| 189 | - { |
|
| 190 | - $value=quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i','',$tmpvalue.$value)); |
|
| 191 | - } |
|
| 192 | - } //$value=quotedPrintDecode($tmpvalue.$value); |
|
| 193 | - if (! $insidealarm && ! $tmpkey) $this->add_to_array($type, $key, $value); // add to array |
|
| 170 | + if ($tmpvalue) |
|
| 171 | + { |
|
| 172 | + $tmpvalue .= $text; |
|
| 173 | + if (! preg_match('/=$/',$text)) // No more lines |
|
| 174 | + { |
|
| 175 | + $key=$tmpkey; |
|
| 176 | + $value=quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i','',$tmpvalue)); |
|
| 177 | + $tmpkey=''; |
|
| 178 | + $tmpvalue=''; |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i',$value)) |
|
| 182 | + { |
|
| 183 | + if (preg_match('/=$/',$value)) |
|
| 184 | + { |
|
| 185 | + $tmpkey=$key; |
|
| 186 | + $tmpvalue=$tmpvalue.preg_replace('/=$/',"",$value); // We must wait to have next line to have complete message |
|
| 187 | + } |
|
| 188 | + else |
|
| 189 | + { |
|
| 190 | + $value=quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i','',$tmpvalue.$value)); |
|
| 191 | + } |
|
| 192 | + } //$value=quotedPrintDecode($tmpvalue.$value); |
|
| 193 | + if (! $insidealarm && ! $tmpkey) $this->add_to_array($type, $key, $value); // add to array |
|
| 194 | 194 | break; |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -231,14 +231,14 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | if (stristr($key,"DTSTART") || stristr($key,"DTEND") || stristr($key,"DTSTART;VALUE=DATE") || stristr($key,"DTEND;VALUE=DATE")) |
| 233 | 233 | { |
| 234 | - if (stristr($key,"DTSTART;VALUE=DATE") || stristr($key,"DTEND;VALUE=DATE")) |
|
| 235 | - { |
|
| 236 | - list($key,$value) = array($key,$value); |
|
| 237 | - } |
|
| 238 | - else |
|
| 239 | - { |
|
| 240 | - list($key,$value) = $this->ical_dt_date($key,$value); |
|
| 241 | - } |
|
| 234 | + if (stristr($key,"DTSTART;VALUE=DATE") || stristr($key,"DTEND;VALUE=DATE")) |
|
| 235 | + { |
|
| 236 | + list($key,$value) = array($key,$value); |
|
| 237 | + } |
|
| 238 | + else |
|
| 239 | + { |
|
| 240 | + list($key,$value) = $this->ical_dt_date($key,$value); |
|
| 241 | + } |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | switch ($type) |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | return $temp; |
| 378 | 378 | } |
| 379 | 379 | else |
| 380 | - { |
|
| 380 | + { |
|
| 381 | 381 | return false; |
| 382 | 382 | } |
| 383 | 383 | } |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | // phpcs:enable |
| 59 | 59 | $this->file = $file; |
| 60 | - $file_text=''; |
|
| 60 | + $file_text = ''; |
|
| 61 | 61 | |
| 62 | - $tmparray=file($file); |
|
| 62 | + $tmparray = file($file); |
|
| 63 | 63 | if (is_array($tmparray)) |
| 64 | 64 | { |
| 65 | 65 | $file_text = join("", $tmparray); //load file |
| 66 | - $file_text = preg_replace("/[\r\n]{1,} /","",$file_text); |
|
| 66 | + $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); |
|
| 67 | 67 | } |
| 68 | 68 | return $file_text; // return all text |
| 69 | 69 | } |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | $this->file_text = preg_split("[\n]", $this->file_text); |
| 111 | 111 | |
| 112 | 112 | // is this text vcalendar standart text ? on line 1 is BEGIN:VCALENDAR |
| 113 | - if (!stristr($this->file_text[0],'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; |
|
| 113 | + if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; |
|
| 114 | 114 | |
| 115 | - $insidealarm=0; |
|
| 116 | - $tmpkey='';$tmpvalue=''; $type=''; |
|
| 115 | + $insidealarm = 0; |
|
| 116 | + $tmpkey = ''; $tmpvalue = ''; $type = ''; |
|
| 117 | 117 | foreach ($this->file_text as $text) |
| 118 | 118 | { |
| 119 | 119 | $text = trim($text); // trim one line |
@@ -126,17 +126,17 @@ discard block |
||
| 126 | 126 | switch ($text) // search special string |
| 127 | 127 | { |
| 128 | 128 | case "BEGIN:VTODO": |
| 129 | - $this->todo_count = $this->todo_count+1; // new to do begin |
|
| 129 | + $this->todo_count = $this->todo_count + 1; // new to do begin |
|
| 130 | 130 | $type = "VTODO"; |
| 131 | 131 | break; |
| 132 | 132 | |
| 133 | 133 | case "BEGIN:VEVENT": |
| 134 | - $this->event_count = $this->event_count+1; // new event begin |
|
| 134 | + $this->event_count = $this->event_count + 1; // new event begin |
|
| 135 | 135 | $type = "VEVENT"; |
| 136 | 136 | break; |
| 137 | 137 | |
| 138 | 138 | case "BEGIN:VFREEBUSY": |
| 139 | - $this->freebusy_count = $this->freebusy_count+1; // new event begin |
|
| 139 | + $this->freebusy_count = $this->freebusy_count + 1; // new event begin |
|
| 140 | 140 | $type = "VFREEBUSY"; |
| 141 | 141 | break; |
| 142 | 142 | |
@@ -160,37 +160,37 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | // Manage VALARM that are inside a VEVENT to avoid fields of VALARM to overwrites fields of VEVENT |
| 162 | 162 | case "BEGIN:VALARM": |
| 163 | - $insidealarm=1; |
|
| 163 | + $insidealarm = 1; |
|
| 164 | 164 | break; |
| 165 | 165 | case "END:VALARM": |
| 166 | - $insidealarm=0; |
|
| 166 | + $insidealarm = 0; |
|
| 167 | 167 | break; |
| 168 | 168 | |
| 169 | 169 | default: // no special string (SUMMARY, DESCRIPTION, ...) |
| 170 | 170 | if ($tmpvalue) |
| 171 | 171 | { |
| 172 | 172 | $tmpvalue .= $text; |
| 173 | - if (! preg_match('/=$/',$text)) // No more lines |
|
| 173 | + if (!preg_match('/=$/', $text)) // No more lines |
|
| 174 | 174 | { |
| 175 | - $key=$tmpkey; |
|
| 176 | - $value=quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i','',$tmpvalue)); |
|
| 177 | - $tmpkey=''; |
|
| 178 | - $tmpvalue=''; |
|
| 175 | + $key = $tmpkey; |
|
| 176 | + $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue)); |
|
| 177 | + $tmpkey = ''; |
|
| 178 | + $tmpvalue = ''; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | - elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i',$value)) |
|
| 181 | + elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) |
|
| 182 | 182 | { |
| 183 | - if (preg_match('/=$/',$value)) |
|
| 183 | + if (preg_match('/=$/', $value)) |
|
| 184 | 184 | { |
| 185 | - $tmpkey=$key; |
|
| 186 | - $tmpvalue=$tmpvalue.preg_replace('/=$/',"",$value); // We must wait to have next line to have complete message |
|
| 185 | + $tmpkey = $key; |
|
| 186 | + $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message |
|
| 187 | 187 | } |
| 188 | 188 | else |
| 189 | 189 | { |
| 190 | - $value=quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i','',$tmpvalue.$value)); |
|
| 190 | + $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); |
|
| 191 | 191 | } |
| 192 | 192 | } //$value=quotedPrintDecode($tmpvalue.$value); |
| 193 | - if (! $insidealarm && ! $tmpkey) $this->add_to_array($type, $key, $value); // add to array |
|
| 193 | + if (!$insidealarm && !$tmpkey) $this->add_to_array($type, $key, $value); // add to array |
|
| 194 | 194 | break; |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -220,24 +220,24 @@ discard block |
||
| 220 | 220 | $key = $this->last_key; |
| 221 | 221 | switch ($type) |
| 222 | 222 | { |
| 223 | - case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value;break; |
|
| 224 | - case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value;break; |
|
| 225 | - case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value;break; |
|
| 223 | + case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break; |
|
| 224 | + case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; |
|
| 225 | + case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value; break; |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value); |
| 230 | 230 | //if ($key == "RRULE" ) $value = $this->ical_rrule($value); |
| 231 | 231 | |
| 232 | - if (stristr($key,"DTSTART") || stristr($key,"DTEND") || stristr($key,"DTSTART;VALUE=DATE") || stristr($key,"DTEND;VALUE=DATE")) |
|
| 232 | + if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) |
|
| 233 | 233 | { |
| 234 | - if (stristr($key,"DTSTART;VALUE=DATE") || stristr($key,"DTEND;VALUE=DATE")) |
|
| 234 | + if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) |
|
| 235 | 235 | { |
| 236 | - list($key,$value) = array($key,$value); |
|
| 236 | + list($key, $value) = array($key, $value); |
|
| 237 | 237 | } |
| 238 | 238 | else |
| 239 | 239 | { |
| 240 | - list($key,$value) = $this->ical_dt_date($key,$value); |
|
| 240 | + list($key, $value) = $this->ical_dt_date($key, $value); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $matches = array_splice($matches, 1, 2); |
| 285 | 285 | return $matches; |
| 286 | 286 | }*/ |
| 287 | - return explode(':',$text,2); |
|
| 287 | + return explode(':', $text, 2); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | { |
| 299 | 299 | // phpcs:enable |
| 300 | 300 | $result = array(); |
| 301 | - $rrule = explode(';',$value); |
|
| 301 | + $rrule = explode(';', $value); |
|
| 302 | 302 | foreach ($rrule as $line) |
| 303 | 303 | { |
| 304 | 304 | $rcontent = explode('=', $line); |
@@ -320,14 +320,14 @@ discard block |
||
| 320 | 320 | $ical_date = str_replace('T', '', $ical_date); |
| 321 | 321 | $ical_date = str_replace('Z', '', $ical_date); |
| 322 | 322 | |
| 323 | - $ntime=0; |
|
| 323 | + $ntime = 0; |
|
| 324 | 324 | // TIME LIMITED EVENT |
| 325 | 325 | if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) |
| 326 | - $ntime=dol_mktime($date[4], $date[5], $date[6], $date[2],$date[3], $date[1], true); |
|
| 326 | + $ntime = dol_mktime($date[4], $date[5], $date[6], $date[2], $date[3], $date[1], true); |
|
| 327 | 327 | |
| 328 | 328 | //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; |
| 329 | 329 | //print dol_print_date($ntime,'dayhour');exit; |
| 330 | - return $ntime; // ntime is a GTM time |
|
| 330 | + return $ntime; // ntime is a GTM time |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -345,12 +345,12 @@ discard block |
||
| 345 | 345 | $value = $this->ical_date_to_unix($value); |
| 346 | 346 | |
| 347 | 347 | // Analyse TZID |
| 348 | - $temp = explode(";",$key); |
|
| 348 | + $temp = explode(";", $key); |
|
| 349 | 349 | |
| 350 | 350 | if (empty($temp[1])) // not TZID |
| 351 | 351 | { |
| 352 | 352 | $value = str_replace('T', '', $value); |
| 353 | - return array($key,$value); |
|
| 353 | + return array($key, $value); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | $key = $temp[0]; |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | $return_value[$temp[0]] = $temp[1]; |
| 359 | 359 | $return_value['unixtime'] = $value; |
| 360 | 360 | |
| 361 | - return array($key,$return_value); |
|
| 361 | + return array($key, $return_value); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | function get_event_list() |
| 406 | 406 | { |
| 407 | 407 | // phpcs:enable |
| 408 | - return (! empty($this->cal['VEVENT'])?$this->cal['VEVENT']:''); |
|
| 408 | + return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : ''); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -110,7 +110,9 @@ discard block |
||
| 110 | 110 | $this->file_text = preg_split("[\n]", $this->file_text); |
| 111 | 111 | |
| 112 | 112 | // is this text vcalendar standart text ? on line 1 is BEGIN:VCALENDAR |
| 113 | - if (!stristr($this->file_text[0],'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; |
|
| 113 | + if (!stristr($this->file_text[0],'BEGIN:VCALENDAR')) { |
|
| 114 | + return 'error not VCALENDAR'; |
|
| 115 | + } |
|
| 114 | 116 | |
| 115 | 117 | $insidealarm=0; |
| 116 | 118 | $tmpkey='';$tmpvalue=''; $type=''; |
@@ -170,27 +172,30 @@ discard block |
||
| 170 | 172 | if ($tmpvalue) |
| 171 | 173 | { |
| 172 | 174 | $tmpvalue .= $text; |
| 173 | - if (! preg_match('/=$/',$text)) // No more lines |
|
| 175 | + if (! preg_match('/=$/',$text)) { |
|
| 176 | + // No more lines |
|
| 174 | 177 | { |
| 175 | 178 | $key=$tmpkey; |
| 179 | + } |
|
| 176 | 180 | $value=quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i','',$tmpvalue)); |
| 177 | 181 | $tmpkey=''; |
| 178 | 182 | $tmpvalue=''; |
| 179 | 183 | } |
| 180 | - } |
|
| 181 | - elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i',$value)) |
|
| 184 | + } elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i',$value)) |
|
| 182 | 185 | { |
| 183 | 186 | if (preg_match('/=$/',$value)) |
| 184 | 187 | { |
| 185 | 188 | $tmpkey=$key; |
| 186 | 189 | $tmpvalue=$tmpvalue.preg_replace('/=$/',"",$value); // We must wait to have next line to have complete message |
| 187 | - } |
|
| 188 | - else |
|
| 190 | + } else |
|
| 189 | 191 | { |
| 190 | 192 | $value=quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i','',$tmpvalue.$value)); |
| 191 | 193 | } |
| 192 | 194 | } //$value=quotedPrintDecode($tmpvalue.$value); |
| 193 | - if (! $insidealarm && ! $tmpkey) $this->add_to_array($type, $key, $value); // add to array |
|
| 195 | + if (! $insidealarm && ! $tmpkey) { |
|
| 196 | + $this->add_to_array($type, $key, $value); |
|
| 197 | + } |
|
| 198 | + // add to array |
|
| 194 | 199 | break; |
| 195 | 200 | } |
| 196 | 201 | } |
@@ -226,7 +231,9 @@ discard block |
||
| 226 | 231 | } |
| 227 | 232 | } |
| 228 | 233 | |
| 229 | - if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value); |
|
| 234 | + if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) { |
|
| 235 | + $value = $this->ical_date_to_unix($value); |
|
| 236 | + } |
|
| 230 | 237 | //if ($key == "RRULE" ) $value = $this->ical_rrule($value); |
| 231 | 238 | |
| 232 | 239 | if (stristr($key,"DTSTART") || stristr($key,"DTEND") || stristr($key,"DTSTART;VALUE=DATE") || stristr($key,"DTEND;VALUE=DATE")) |
@@ -234,8 +241,7 @@ discard block |
||
| 234 | 241 | if (stristr($key,"DTSTART;VALUE=DATE") || stristr($key,"DTEND;VALUE=DATE")) |
| 235 | 242 | { |
| 236 | 243 | list($key,$value) = array($key,$value); |
| 237 | - } |
|
| 238 | - else |
|
| 244 | + } else |
|
| 239 | 245 | { |
| 240 | 246 | list($key,$value) = $this->ical_dt_date($key,$value); |
| 241 | 247 | } |
@@ -322,8 +328,9 @@ discard block |
||
| 322 | 328 | |
| 323 | 329 | $ntime=0; |
| 324 | 330 | // TIME LIMITED EVENT |
| 325 | - if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) |
|
| 326 | - $ntime=dol_mktime($date[4], $date[5], $date[6], $date[2],$date[3], $date[1], true); |
|
| 331 | + if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) { |
|
| 332 | + $ntime=dol_mktime($date[4], $date[5], $date[6], $date[2],$date[3], $date[1], true); |
|
| 333 | + } |
|
| 327 | 334 | |
| 328 | 335 | //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; |
| 329 | 336 | //print dol_print_date($ntime,'dayhour');exit; |
@@ -347,9 +354,11 @@ discard block |
||
| 347 | 354 | // Analyse TZID |
| 348 | 355 | $temp = explode(";",$key); |
| 349 | 356 | |
| 350 | - if (empty($temp[1])) // not TZID |
|
| 357 | + if (empty($temp[1])) { |
|
| 358 | + // not TZID |
|
| 351 | 359 | { |
| 352 | 360 | $value = str_replace('T', '', $value); |
| 361 | + } |
|
| 353 | 362 | return array($key,$value); |
| 354 | 363 | } |
| 355 | 364 | |
@@ -375,8 +384,7 @@ discard block |
||
| 375 | 384 | { |
| 376 | 385 | usort($temp, array(&$this, "ical_dtstart_compare")); |
| 377 | 386 | return $temp; |
| 378 | - } |
|
| 379 | - else |
|
| 387 | + } else |
|
| 380 | 388 | { |
| 381 | 389 | return false; |
| 382 | 390 | } |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | - use Luracast\Restler\RestException; |
|
| 19 | + use Luracast\Restler\RestException; |
|
| 20 | 20 | |
| 21 | - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 21 | + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * API class for Agenda Events |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param int $id ID of Agenda Events |
| 60 | 60 | * @return array|mixed Data without useless information |
| 61 | - * |
|
| 61 | + * |
|
| 62 | 62 | * @throws RestException |
| 63 | 63 | */ |
| 64 | 64 | function get($id) |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id,'actioncomm','','fk_soc','id')) { |
|
| 80 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 81 | - } |
|
| 79 | + if ( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id,'actioncomm','','fk_soc','id')) { |
|
| 80 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $result = $this->actioncomm->fetch_optionals(); |
|
| 83 | + $result = $this->actioncomm->fetch_optionals(); |
|
| 84 | 84 | |
| 85 | 85 | $this->actioncomm->fetchObjectLinked(); |
| 86 | - return $this->_cleanObjectDatas($this->actioncomm); |
|
| 86 | + return $this->_cleanObjectDatas($this->actioncomm); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | // If the internal user must only see his customers, force searching by him |
| 117 | 117 | $search_sale = 0; |
| 118 | 118 | if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
| 119 | - if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists |
|
| 119 | + if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists |
|
| 120 | 120 | |
| 121 | 121 | $sql = "SELECT t.id as rowid"; |
| 122 | 122 | if (! empty($conf->societe->enabled)) |
| 123 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 123 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 124 | 124 | $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; |
| 125 | 125 | if (! empty($conf->societe->enabled)) |
| 126 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 126 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 127 | 127 | $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; |
| 128 | 128 | if (! empty($conf->societe->enabled)) |
| 129 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 129 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 130 | 130 | if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; |
| 131 | 131 | if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; |
| 132 | 132 | // Insert sale filter |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | { |
| 142 | 142 | throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
| 143 | 143 | } |
| 144 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 144 | + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 145 | 145 | $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | if ($result) |
| 162 | 162 | { |
| 163 | - $i=0; |
|
| 163 | + $i=0; |
|
| 164 | 164 | $num = $db->num_rows($result); |
| 165 | 165 | $min = min($num, ($limit <= 0 ? $num : $limit)); |
| 166 | 166 | while ($i < $min) |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | if ( ! count($obj_ret)) { |
| 180 | 180 | throw new RestException(404, 'No Agenda Event found'); |
| 181 | 181 | } |
| 182 | - return $obj_ret; |
|
| 182 | + return $obj_ret; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -190,12 +190,12 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | function post($request_data = null) |
| 192 | 192 | { |
| 193 | - if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { |
|
| 194 | - throw new RestException(401, "Insuffisant rights to create your Agenda Event"); |
|
| 195 | - } |
|
| 196 | - if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { |
|
| 197 | - throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); |
|
| 198 | - } |
|
| 193 | + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { |
|
| 194 | + throw new RestException(401, "Insuffisant rights to create your Agenda Event"); |
|
| 195 | + } |
|
| 196 | + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { |
|
| 197 | + throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | 200 | // Check mandatory fields |
| 201 | 201 | $result = $this->_validate($request_data); |
@@ -266,22 +266,22 @@ discard block |
||
| 266 | 266 | function delete($id) |
| 267 | 267 | { |
| 268 | 268 | if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { |
| 269 | - throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); |
|
| 270 | - } |
|
| 269 | + throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $result = $this->actioncomm->fetch($id); |
|
| 272 | + $result = $this->actioncomm->fetch($id); |
|
| 273 | 273 | |
| 274 | 274 | if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { |
| 275 | - throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); |
|
| 276 | - } |
|
| 275 | + throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - if( ! $result ) { |
|
| 278 | + if( ! $result ) { |
|
| 279 | 279 | throw new RestException(404, 'Agenda Event not found'); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) { |
|
| 283 | - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 284 | - } |
|
| 282 | + if( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) { |
|
| 283 | + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | 286 | if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) { |
| 287 | 287 | throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); |
@@ -322,48 +322,48 @@ discard block |
||
| 322 | 322 | function _cleanObjectDatas($object) |
| 323 | 323 | { |
| 324 | 324 | |
| 325 | - $object = parent::_cleanObjectDatas($object); |
|
| 326 | - |
|
| 327 | - unset($object->usermod); |
|
| 328 | - unset($object->libelle); |
|
| 329 | - unset($object->context); |
|
| 330 | - unset($object->canvas); |
|
| 331 | - unset($object->contact); |
|
| 332 | - unset($object->contact_id); |
|
| 333 | - unset($object->thirdparty); |
|
| 334 | - unset($object->user); |
|
| 335 | - unset($object->origin); |
|
| 336 | - unset($object->origin_id); |
|
| 337 | - unset($object->ref_ext); |
|
| 338 | - unset($object->statut); |
|
| 339 | - unset($object->country); |
|
| 340 | - unset($object->country_id); |
|
| 341 | - unset($object->country_code); |
|
| 342 | - unset($object->barcode_type); |
|
| 343 | - unset($object->barcode_type_code); |
|
| 344 | - unset($object->barcode_type_label); |
|
| 345 | - unset($object->barcode_type_coder); |
|
| 346 | - unset($object->mode_reglement_id); |
|
| 347 | - unset($object->cond_reglement_id); |
|
| 348 | - unset($object->cond_reglement); |
|
| 349 | - unset($object->fk_delivery_address); |
|
| 350 | - unset($object->shipping_method_id); |
|
| 351 | - unset($object->fk_account); |
|
| 352 | - unset($object->total_ht); |
|
| 353 | - unset($object->total_tva); |
|
| 354 | - unset($object->total_localtax1); |
|
| 355 | - unset($object->total_localtax2); |
|
| 356 | - unset($object->total_ttc); |
|
| 357 | - unset($object->fk_incoterms); |
|
| 358 | - unset($object->libelle_incoterms); |
|
| 359 | - unset($object->location_incoterms); |
|
| 360 | - unset($object->name); |
|
| 361 | - unset($object->lastname); |
|
| 362 | - unset($object->firstname); |
|
| 363 | - unset($object->civility_id); |
|
| 364 | - unset($object->contact); |
|
| 365 | - unset($object->societe); |
|
| 366 | - |
|
| 367 | - return $object; |
|
| 325 | + $object = parent::_cleanObjectDatas($object); |
|
| 326 | + |
|
| 327 | + unset($object->usermod); |
|
| 328 | + unset($object->libelle); |
|
| 329 | + unset($object->context); |
|
| 330 | + unset($object->canvas); |
|
| 331 | + unset($object->contact); |
|
| 332 | + unset($object->contact_id); |
|
| 333 | + unset($object->thirdparty); |
|
| 334 | + unset($object->user); |
|
| 335 | + unset($object->origin); |
|
| 336 | + unset($object->origin_id); |
|
| 337 | + unset($object->ref_ext); |
|
| 338 | + unset($object->statut); |
|
| 339 | + unset($object->country); |
|
| 340 | + unset($object->country_id); |
|
| 341 | + unset($object->country_code); |
|
| 342 | + unset($object->barcode_type); |
|
| 343 | + unset($object->barcode_type_code); |
|
| 344 | + unset($object->barcode_type_label); |
|
| 345 | + unset($object->barcode_type_coder); |
|
| 346 | + unset($object->mode_reglement_id); |
|
| 347 | + unset($object->cond_reglement_id); |
|
| 348 | + unset($object->cond_reglement); |
|
| 349 | + unset($object->fk_delivery_address); |
|
| 350 | + unset($object->shipping_method_id); |
|
| 351 | + unset($object->fk_account); |
|
| 352 | + unset($object->total_ht); |
|
| 353 | + unset($object->total_tva); |
|
| 354 | + unset($object->total_localtax1); |
|
| 355 | + unset($object->total_localtax2); |
|
| 356 | + unset($object->total_ttc); |
|
| 357 | + unset($object->fk_incoterms); |
|
| 358 | + unset($object->libelle_incoterms); |
|
| 359 | + unset($object->location_incoterms); |
|
| 360 | + unset($object->name); |
|
| 361 | + unset($object->lastname); |
|
| 362 | + unset($object->firstname); |
|
| 363 | + unset($object->civility_id); |
|
| 364 | + unset($object->contact); |
|
| 365 | + unset($object->societe); |
|
| 366 | + |
|
| 367 | + return $object; |
|
| 368 | 368 | } |
| 369 | 369 | } |
@@ -63,20 +63,20 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | function get($id) |
| 65 | 65 | { |
| 66 | - if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { |
|
| 66 | + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { |
|
| 67 | 67 | throw new RestException(401, "Insuffisant rights to read an event"); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $result = $this->actioncomm->fetch($id); |
| 71 | - if ( ! $result ) { |
|
| 71 | + if (!$result) { |
|
| 72 | 72 | throw new RestException(404, 'Agenda Events not found'); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if (! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { |
|
| 75 | + if (!DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { |
|
| 76 | 76 | throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id,'actioncomm','','fk_soc','id')) { |
|
| 79 | + if (!DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { |
|
| 80 | 80 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -105,30 +105,30 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $obj_ret = array(); |
| 107 | 107 | |
| 108 | - if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { |
|
| 108 | + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { |
|
| 109 | 109 | throw new RestException(401, "Insuffisant rights to read events"); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // case of external user |
| 113 | 113 | $socid = 0; |
| 114 | - if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; |
|
| 114 | + if (!empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; |
|
| 115 | 115 | |
| 116 | 116 | // If the internal user must only see his customers, force searching by him |
| 117 | 117 | $search_sale = 0; |
| 118 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
|
| 119 | - if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists |
|
| 118 | + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
|
| 119 | + if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists |
|
| 120 | 120 | |
| 121 | 121 | $sql = "SELECT t.id as rowid"; |
| 122 | - if (! empty($conf->societe->enabled)) |
|
| 122 | + if (!empty($conf->societe->enabled)) |
|
| 123 | 123 | if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
| 124 | - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; |
|
| 125 | - if (! empty($conf->societe->enabled)) |
|
| 126 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 127 | - $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; |
|
| 128 | - if (! empty($conf->societe->enabled)) |
|
| 129 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 130 | - if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; |
|
| 131 | - if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; |
|
| 124 | + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; |
|
| 125 | + if (!empty($conf->societe->enabled)) |
|
| 126 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 127 | + $sql .= ' WHERE t.entity IN ('.getEntity('agenda').')'; |
|
| 128 | + if (!empty($conf->societe->enabled)) |
|
| 129 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; |
|
| 130 | + if ($user_ids) $sql .= " AND t.fk_user_action IN (".$user_ids.")"; |
|
| 131 | + if ($socid > 0) $sql .= " AND t.fk_soc = ".$socid; |
|
| 132 | 132 | // Insert sale filter |
| 133 | 133 | if ($search_sale > 0) |
| 134 | 134 | { |
@@ -137,30 +137,30 @@ discard block |
||
| 137 | 137 | // Add sql filters |
| 138 | 138 | if ($sqlfilters) |
| 139 | 139 | { |
| 140 | - if (! DolibarrApi::_checkFilters($sqlfilters)) |
|
| 140 | + if (!DolibarrApi::_checkFilters($sqlfilters)) |
|
| 141 | 141 | { |
| 142 | 142 | throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); |
| 143 | 143 | } |
| 144 | - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 145 | - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 144 | + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 145 | + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $sql.= $db->order($sortfield, $sortorder); |
|
| 149 | - if ($limit) { |
|
| 148 | + $sql .= $db->order($sortfield, $sortorder); |
|
| 149 | + if ($limit) { |
|
| 150 | 150 | if ($page < 0) |
| 151 | 151 | { |
| 152 | 152 | $page = 0; |
| 153 | 153 | } |
| 154 | 154 | $offset = $limit * $page; |
| 155 | 155 | |
| 156 | - $sql.= $db->plimit($limit + 1, $offset); |
|
| 156 | + $sql .= $db->plimit($limit + 1, $offset); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $result = $db->query($sql); |
| 160 | 160 | |
| 161 | 161 | if ($result) |
| 162 | 162 | { |
| 163 | - $i=0; |
|
| 163 | + $i = 0; |
|
| 164 | 164 | $num = $db->num_rows($result); |
| 165 | 165 | $min = min($num, ($limit <= 0 ? $num : $limit)); |
| 166 | 166 | while ($i < $min) |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | else { |
| 177 | 177 | throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror()); |
| 178 | 178 | } |
| 179 | - if ( ! count($obj_ret)) { |
|
| 179 | + if (!count($obj_ret)) { |
|
| 180 | 180 | throw new RestException(404, 'No Agenda Event found'); |
| 181 | 181 | } |
| 182 | 182 | return $obj_ret; |
@@ -190,17 +190,17 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | function post($request_data = null) |
| 192 | 192 | { |
| 193 | - if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { |
|
| 193 | + if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { |
|
| 194 | 194 | throw new RestException(401, "Insuffisant rights to create your Agenda Event"); |
| 195 | 195 | } |
| 196 | - if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { |
|
| 196 | + if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { |
|
| 197 | 197 | throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // Check mandatory fields |
| 201 | 201 | $result = $this->_validate($request_data); |
| 202 | 202 | |
| 203 | - foreach($request_data as $field => $value) { |
|
| 203 | + foreach ($request_data as $field => $value) { |
|
| 204 | 204 | $this->actioncomm->$field = $value; |
| 205 | 205 | } |
| 206 | 206 | /*if (isset($request_data["lines"])) { |
@@ -265,25 +265,25 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | function delete($id) |
| 267 | 267 | { |
| 268 | - if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { |
|
| 268 | + if (!DolibarrApiAccess::$user->rights->agenda->myactions->delete) { |
|
| 269 | 269 | throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | $result = $this->actioncomm->fetch($id); |
| 273 | 273 | |
| 274 | - if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { |
|
| 274 | + if (!DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { |
|
| 275 | 275 | throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if( ! $result ) { |
|
| 278 | + if (!$result) { |
|
| 279 | 279 | throw new RestException(404, 'Agenda Event not found'); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) { |
|
| 282 | + if (!DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { |
|
| 283 | 283 | throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) { |
|
| 286 | + if (!$this->actioncomm->delete(DolibarrApiAccess::$user)) { |
|
| 287 | 287 | throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); |
| 288 | 288 | } |
| 289 | 289 | |
@@ -111,24 +111,40 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | // case of external user |
| 113 | 113 | $socid = 0; |
| 114 | - if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; |
|
| 114 | + if (! empty(DolibarrApiAccess::$user->socid)) { |
|
| 115 | + $socid = DolibarrApiAccess::$user->socid; |
|
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | // If the internal user must only see his customers, force searching by him |
| 117 | 119 | $search_sale = 0; |
| 118 | - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; |
|
| 119 | - if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists |
|
| 120 | + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { |
|
| 121 | + $search_sale = DolibarrApiAccess::$user->id; |
|
| 122 | + } |
|
| 123 | + if (empty($conf->societe->enabled)) { |
|
| 124 | + $search_sale = 0; |
|
| 125 | + } |
|
| 126 | + // If module thirdparty not enabled, sale representative is something that does not exists |
|
| 120 | 127 | |
| 121 | 128 | $sql = "SELECT t.id as rowid"; |
| 122 | - if (! empty($conf->societe->enabled)) |
|
| 123 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 129 | + if (! empty($conf->societe->enabled)) { |
|
| 130 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; |
|
| 131 | + } |
|
| 132 | + // We need these fields in order to filter by sale (including the case where the user can only see his prospects) |
|
| 124 | 133 | $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; |
| 125 | - if (! empty($conf->societe->enabled)) |
|
| 126 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale |
|
| 134 | + if (! empty($conf->societe->enabled)) { |
|
| 135 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 136 | + } |
|
| 137 | + // We need this table joined to the select in order to filter by sale |
|
| 127 | 138 | $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; |
| 128 | - if (! empty($conf->societe->enabled)) |
|
| 129 | - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 130 | - if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; |
|
| 131 | - if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; |
|
| 139 | + if (! empty($conf->societe->enabled)) { |
|
| 140 | + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; |
|
| 141 | + } |
|
| 142 | + if ($user_ids) { |
|
| 143 | + $sql.=" AND t.fk_user_action IN (".$user_ids.")"; |
|
| 144 | + } |
|
| 145 | + if ($socid > 0) { |
|
| 146 | + $sql.= " AND t.fk_soc = ".$socid; |
|
| 147 | + } |
|
| 132 | 148 | // Insert sale filter |
| 133 | 149 | if ($search_sale > 0) |
| 134 | 150 | { |
@@ -172,8 +188,7 @@ discard block |
||
| 172 | 188 | } |
| 173 | 189 | $i++; |
| 174 | 190 | } |
| 175 | - } |
|
| 176 | - else { |
|
| 191 | + } else { |
|
| 177 | 192 | throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror()); |
| 178 | 193 | } |
| 179 | 194 | if ( ! count($obj_ret)) { |
@@ -306,8 +321,9 @@ discard block |
||
| 306 | 321 | { |
| 307 | 322 | $event = array(); |
| 308 | 323 | foreach (AgendaEvents::$FIELDS as $field) { |
| 309 | - if (!isset($data[$field])) |
|
| 310 | - throw new RestException(400, "$field field missing"); |
|
| 324 | + if (!isset($data[$field])) { |
|
| 325 | + throw new RestException(400, "$field field missing"); |
|
| 326 | + } |
|
| 311 | 327 | $event[$field] = $data[$field]; |
| 312 | 328 | } |
| 313 | 329 | return $event; |
@@ -41,8 +41,8 @@ |
||
| 41 | 41 | // Security check |
| 42 | 42 | if ($user->societe_id > 0) |
| 43 | 43 | { |
| 44 | - $action = ''; |
|
| 45 | - $socid = $user->societe_id; |
|
| 44 | + $action = ''; |
|
| 45 | + $socid = $user->societe_id; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); |
@@ -95,7 +95,9 @@ |
||
| 95 | 95 | $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
| 96 | 96 | $morehtmlref.=$proj->ref; |
| 97 | 97 | $morehtmlref.='</a>'; |
| 98 | - if ($proj->title) $morehtmlref.=' - '.$proj->title; |
|
| 98 | + if ($proj->title) { |
|
| 99 | + $morehtmlref.=' - '.$proj->title; |
|
| 100 | + } |
|
| 99 | 101 | } else { |
| 100 | 102 | $morehtmlref.=''; |
| 101 | 103 | } |
@@ -25,21 +25,21 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 27 | 27 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 28 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 28 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 29 | 29 | require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; |
| 30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 32 | 32 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
| 34 | -if (! empty($conf->projet->enabled)) { |
|
| 35 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
| 36 | - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
| 34 | +if (!empty($conf->projet->enabled)) { |
|
| 35 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 36 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Load translation files required by the page |
| 40 | 40 | $langs->load("commercial"); |
| 41 | 41 | |
| 42 | -$id = GETPOST('id','int'); |
|
| 42 | +$id = GETPOST('id', 'int'); |
|
| 43 | 43 | |
| 44 | 44 | // Security check |
| 45 | 45 | if ($user->societe_id > 0) |
@@ -55,57 +55,57 @@ discard block |
||
| 55 | 55 | * View |
| 56 | 56 | */ |
| 57 | 57 | |
| 58 | -$form=new Form($db); |
|
| 58 | +$form = new Form($db); |
|
| 59 | 59 | |
| 60 | -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; |
|
| 61 | -llxHeader('',$langs->trans("Agenda"),$help_url); |
|
| 60 | +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; |
|
| 61 | +llxHeader('', $langs->trans("Agenda"), $help_url); |
|
| 62 | 62 | |
| 63 | 63 | $object = new ActionComm($db); |
| 64 | 64 | $object->fetch($id); |
| 65 | 65 | $object->info($object->id); |
| 66 | 66 | |
| 67 | -$head=actions_prepare_head($object); |
|
| 67 | +$head = actions_prepare_head($object); |
|
| 68 | 68 | dol_fiche_head($head, 'info', $langs->trans("Action"), -1, 'action'); |
| 69 | 69 | |
| 70 | -$linkback = img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"'); |
|
| 71 | -$linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php">'.$langs->trans("BackToList").'</a>'; |
|
| 70 | +$linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); |
|
| 71 | +$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php">'.$langs->trans("BackToList").'</a>'; |
|
| 72 | 72 | |
| 73 | 73 | // Link to other agenda views |
| 74 | -$out=''; |
|
| 75 | -$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); |
|
| 76 | -$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>'; |
|
| 77 | -$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); |
|
| 78 | -$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>'; |
|
| 79 | -$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); |
|
| 80 | -$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>'; |
|
| 81 | -$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); |
|
| 82 | -$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>'; |
|
| 83 | - |
|
| 84 | -$linkback.=$out; |
|
| 85 | - |
|
| 86 | -$morehtmlref='<div class="refidno">'; |
|
| 74 | +$out = ''; |
|
| 75 | +$out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); |
|
| 76 | +$out .= '<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewPerUser").'</a>'; |
|
| 77 | +$out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); |
|
| 78 | +$out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewCal").'</a>'; |
|
| 79 | +$out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); |
|
| 80 | +$out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewWeek").'</a>'; |
|
| 81 | +$out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); |
|
| 82 | +$out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewDay").'</a>'; |
|
| 83 | + |
|
| 84 | +$linkback .= $out; |
|
| 85 | + |
|
| 86 | +$morehtmlref = '<div class="refidno">'; |
|
| 87 | 87 | // Thirdparty |
| 88 | 88 | //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
| 89 | 89 | // Project |
| 90 | -if (! empty($conf->projet->enabled)) |
|
| 90 | +if (!empty($conf->projet->enabled)) |
|
| 91 | 91 | { |
| 92 | 92 | $langs->load("projects"); |
| 93 | 93 | //$morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
| 94 | - $morehtmlref.=$langs->trans('Project') . ': '; |
|
| 95 | - if (! empty($object->fk_project)) { |
|
| 94 | + $morehtmlref .= $langs->trans('Project').': '; |
|
| 95 | + if (!empty($object->fk_project)) { |
|
| 96 | 96 | $proj = new Project($db); |
| 97 | 97 | $proj->fetch($object->fk_project); |
| 98 | - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 99 | - $morehtmlref.=$proj->ref; |
|
| 100 | - $morehtmlref.='</a>'; |
|
| 101 | - if ($proj->title) $morehtmlref.=' - '.$proj->title; |
|
| 98 | + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
| 99 | + $morehtmlref .= $proj->ref; |
|
| 100 | + $morehtmlref .= '</a>'; |
|
| 101 | + if ($proj->title) $morehtmlref .= ' - '.$proj->title; |
|
| 102 | 102 | } else { |
| 103 | - $morehtmlref.=''; |
|
| 103 | + $morehtmlref .= ''; |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | -$morehtmlref.='</div>'; |
|
| 106 | +$morehtmlref .= '</div>'; |
|
| 107 | 107 | |
| 108 | -dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref); |
|
| 108 | +dol_banner_tab($object, 'id', $linkback, ($user->societe_id ? 0 : 1), 'id', 'ref', $morehtmlref); |
|
| 109 | 109 | |
| 110 | 110 | print '<div class="underbanner clearboth"></div>'; |
| 111 | 111 | |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | if ($user->societe_id) $socid=$user->societe_id; |
| 49 | 49 | if ($user->societe_id > 0) |
| 50 | 50 | { |
| 51 | - unset($_GET["action"]); |
|
| 52 | - $action=''; |
|
| 51 | + unset($_GET["action"]); |
|
| 52 | + $action=''; |
|
| 53 | 53 | } |
| 54 | 54 | $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); |
| 55 | 55 | |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | if ($id > 0) |
| 59 | 59 | { |
| 60 | - $ret = $object->fetch($id); |
|
| 61 | - $object->fetch_thirdparty(); |
|
| 60 | + $ret = $object->fetch($id); |
|
| 61 | + $object->fetch_thirdparty(); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Get parameters |
@@ -94,178 +94,178 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | if ($object->id > 0) |
| 96 | 96 | { |
| 97 | - $result1=$object->fetch($id); |
|
| 98 | - $result2=$object->fetch_thirdparty(); |
|
| 99 | - $result3=$object->fetch_contact(); |
|
| 100 | - $result4=$object->fetch_userassigned(); |
|
| 101 | - $result5=$object->fetch_optionals(); |
|
| 102 | - |
|
| 103 | - if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) |
|
| 104 | - { |
|
| 105 | - dol_print_error($db,$object->error); |
|
| 106 | - exit; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - if ($object->authorid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->authorid); $object->author=$tmpuser; } |
|
| 110 | - if ($object->usermodid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermodid); $object->usermod=$tmpuser; } |
|
| 111 | - |
|
| 112 | - $author=new User($db); |
|
| 113 | - $author->fetch($object->author->id); |
|
| 114 | - $object->author=$author; |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - $head=actions_prepare_head($object); |
|
| 118 | - |
|
| 119 | - $now=dol_now(); |
|
| 120 | - $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; |
|
| 121 | - |
|
| 122 | - dol_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); |
|
| 123 | - |
|
| 124 | - $linkback = img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"'); |
|
| 125 | - $linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php">'.$langs->trans("BackToList").'</a>'; |
|
| 126 | - |
|
| 127 | - // Link to other agenda views |
|
| 128 | - $out=''; |
|
| 129 | - $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); |
|
| 130 | - $out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>'; |
|
| 131 | - $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); |
|
| 132 | - $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>'; |
|
| 133 | - $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); |
|
| 134 | - $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>'; |
|
| 135 | - $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); |
|
| 136 | - $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>'; |
|
| 137 | - |
|
| 138 | - $linkback.=$out; |
|
| 139 | - |
|
| 140 | - $morehtmlref='<div class="refidno">'; |
|
| 141 | - // Thirdparty |
|
| 142 | - //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
| 143 | - // Project |
|
| 144 | - if (! empty($conf->projet->enabled)) |
|
| 145 | - { |
|
| 146 | - $langs->load("projects"); |
|
| 147 | - //$morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 148 | - $morehtmlref.=$langs->trans('Project') . ': '; |
|
| 149 | - if (! empty($object->fk_project)) { |
|
| 150 | - $proj = new Project($db); |
|
| 151 | - $proj->fetch($object->fk_project); |
|
| 152 | - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 153 | - $morehtmlref.=$proj->ref; |
|
| 154 | - $morehtmlref.='</a>'; |
|
| 155 | - if ($proj->title) $morehtmlref.=' - '.$proj->title; |
|
| 156 | - } else { |
|
| 157 | - $morehtmlref.=''; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - $morehtmlref.='</div>'; |
|
| 161 | - |
|
| 162 | - dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref); |
|
| 163 | - |
|
| 164 | - print '<div class="fichecenter">'; |
|
| 165 | - |
|
| 166 | - print '<div class="underbanner clearboth"></div>'; |
|
| 167 | - |
|
| 168 | - // Affichage fiche action en mode visu |
|
| 169 | - print '<table class="border" width="100%">'; |
|
| 170 | - |
|
| 171 | - // Type |
|
| 172 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 173 | - { |
|
| 174 | - print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>'; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // Full day event |
|
| 178 | - print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>'; |
|
| 179 | - |
|
| 180 | - // Date start |
|
| 181 | - print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">'; |
|
| 182 | - if (! $object->fulldayevent) print dol_print_date($object->datep,'dayhour'); |
|
| 183 | - else print dol_print_date($object->datep,'day'); |
|
| 184 | - if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); |
|
| 185 | - print '</td>'; |
|
| 186 | - print '</tr>'; |
|
| 187 | - |
|
| 188 | - // Date end |
|
| 189 | - print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">'; |
|
| 190 | - if (! $object->fulldayevent) print dol_print_date($object->datef,'dayhour'); |
|
| 191 | - else print dol_print_date($object->datef,'day'); |
|
| 192 | - if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); |
|
| 193 | - print '</td></tr>'; |
|
| 194 | - |
|
| 195 | - // Location |
|
| 196 | - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) |
|
| 197 | - { |
|
| 198 | - print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>'; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // Assigned to |
|
| 202 | - print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">'; |
|
| 203 | - $listofuserid=array(); |
|
| 204 | - if (empty($donotclearsession)) |
|
| 205 | - { |
|
| 206 | - if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first |
|
| 207 | - if (! empty($object->userassigned)) // Now concat assigned users |
|
| 208 | - { |
|
| 209 | - // Restore array with key with same value than param 'id' |
|
| 210 | - $tmplist1=$object->userassigned; $tmplist2=array(); |
|
| 211 | - foreach($tmplist1 as $key => $val) |
|
| 212 | - { |
|
| 213 | - if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - $_SESSION['assignedtouser']=json_encode($listofuserid); |
|
| 217 | - } |
|
| 218 | - else |
|
| 219 | - { |
|
| 220 | - if (!empty($_SESSION['assignedtouser'])) |
|
| 221 | - { |
|
| 222 | - $listofuserid=json_decode($_SESSION['assignedtouser'], true); |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - $listofcontactid=array(); // not used yet |
|
| 226 | - $listofotherid=array(); // not used yet |
|
| 227 | - print '<div class="assignedtouser">'; |
|
| 228 | - print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid); |
|
| 229 | - print '</div>'; |
|
| 230 | - /*if (in_array($user->id,array_keys($listofuserid))) |
|
| 97 | + $result1=$object->fetch($id); |
|
| 98 | + $result2=$object->fetch_thirdparty(); |
|
| 99 | + $result3=$object->fetch_contact(); |
|
| 100 | + $result4=$object->fetch_userassigned(); |
|
| 101 | + $result5=$object->fetch_optionals(); |
|
| 102 | + |
|
| 103 | + if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) |
|
| 104 | + { |
|
| 105 | + dol_print_error($db,$object->error); |
|
| 106 | + exit; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + if ($object->authorid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->authorid); $object->author=$tmpuser; } |
|
| 110 | + if ($object->usermodid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermodid); $object->usermod=$tmpuser; } |
|
| 111 | + |
|
| 112 | + $author=new User($db); |
|
| 113 | + $author->fetch($object->author->id); |
|
| 114 | + $object->author=$author; |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + $head=actions_prepare_head($object); |
|
| 118 | + |
|
| 119 | + $now=dol_now(); |
|
| 120 | + $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; |
|
| 121 | + |
|
| 122 | + dol_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); |
|
| 123 | + |
|
| 124 | + $linkback = img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"'); |
|
| 125 | + $linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php">'.$langs->trans("BackToList").'</a>'; |
|
| 126 | + |
|
| 127 | + // Link to other agenda views |
|
| 128 | + $out=''; |
|
| 129 | + $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); |
|
| 130 | + $out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>'; |
|
| 131 | + $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); |
|
| 132 | + $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>'; |
|
| 133 | + $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); |
|
| 134 | + $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>'; |
|
| 135 | + $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); |
|
| 136 | + $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>'; |
|
| 137 | + |
|
| 138 | + $linkback.=$out; |
|
| 139 | + |
|
| 140 | + $morehtmlref='<div class="refidno">'; |
|
| 141 | + // Thirdparty |
|
| 142 | + //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
| 143 | + // Project |
|
| 144 | + if (! empty($conf->projet->enabled)) |
|
| 145 | + { |
|
| 146 | + $langs->load("projects"); |
|
| 147 | + //$morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
| 148 | + $morehtmlref.=$langs->trans('Project') . ': '; |
|
| 149 | + if (! empty($object->fk_project)) { |
|
| 150 | + $proj = new Project($db); |
|
| 151 | + $proj->fetch($object->fk_project); |
|
| 152 | + $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 153 | + $morehtmlref.=$proj->ref; |
|
| 154 | + $morehtmlref.='</a>'; |
|
| 155 | + if ($proj->title) $morehtmlref.=' - '.$proj->title; |
|
| 156 | + } else { |
|
| 157 | + $morehtmlref.=''; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + $morehtmlref.='</div>'; |
|
| 161 | + |
|
| 162 | + dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref); |
|
| 163 | + |
|
| 164 | + print '<div class="fichecenter">'; |
|
| 165 | + |
|
| 166 | + print '<div class="underbanner clearboth"></div>'; |
|
| 167 | + |
|
| 168 | + // Affichage fiche action en mode visu |
|
| 169 | + print '<table class="border" width="100%">'; |
|
| 170 | + |
|
| 171 | + // Type |
|
| 172 | + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 173 | + { |
|
| 174 | + print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>'; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // Full day event |
|
| 178 | + print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>'; |
|
| 179 | + |
|
| 180 | + // Date start |
|
| 181 | + print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">'; |
|
| 182 | + if (! $object->fulldayevent) print dol_print_date($object->datep,'dayhour'); |
|
| 183 | + else print dol_print_date($object->datep,'day'); |
|
| 184 | + if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); |
|
| 185 | + print '</td>'; |
|
| 186 | + print '</tr>'; |
|
| 187 | + |
|
| 188 | + // Date end |
|
| 189 | + print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">'; |
|
| 190 | + if (! $object->fulldayevent) print dol_print_date($object->datef,'dayhour'); |
|
| 191 | + else print dol_print_date($object->datef,'day'); |
|
| 192 | + if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); |
|
| 193 | + print '</td></tr>'; |
|
| 194 | + |
|
| 195 | + // Location |
|
| 196 | + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) |
|
| 197 | + { |
|
| 198 | + print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>'; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // Assigned to |
|
| 202 | + print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">'; |
|
| 203 | + $listofuserid=array(); |
|
| 204 | + if (empty($donotclearsession)) |
|
| 205 | + { |
|
| 206 | + if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first |
|
| 207 | + if (! empty($object->userassigned)) // Now concat assigned users |
|
| 208 | + { |
|
| 209 | + // Restore array with key with same value than param 'id' |
|
| 210 | + $tmplist1=$object->userassigned; $tmplist2=array(); |
|
| 211 | + foreach($tmplist1 as $key => $val) |
|
| 212 | + { |
|
| 213 | + if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + $_SESSION['assignedtouser']=json_encode($listofuserid); |
|
| 217 | + } |
|
| 218 | + else |
|
| 219 | + { |
|
| 220 | + if (!empty($_SESSION['assignedtouser'])) |
|
| 221 | + { |
|
| 222 | + $listofuserid=json_decode($_SESSION['assignedtouser'], true); |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + $listofcontactid=array(); // not used yet |
|
| 226 | + $listofotherid=array(); // not used yet |
|
| 227 | + print '<div class="assignedtouser">'; |
|
| 228 | + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid); |
|
| 229 | + print '</div>'; |
|
| 230 | + /*if (in_array($user->id,array_keys($listofuserid))) |
|
| 231 | 231 | { |
| 232 | 232 | print '<div class="myavailability">'; |
| 233 | 233 | print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody |
| 234 | 234 | print '</div>'; |
| 235 | 235 | }*/ |
| 236 | - print ' </td></tr>'; |
|
| 236 | + print ' </td></tr>'; |
|
| 237 | 237 | |
| 238 | - print '</table>'; |
|
| 238 | + print '</table>'; |
|
| 239 | 239 | |
| 240 | - print '<table class="border" width="100%">'; |
|
| 240 | + print '<table class="border" width="100%">'; |
|
| 241 | 241 | |
| 242 | - // Build file list |
|
| 243 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
| 244 | - $totalsize=0; |
|
| 245 | - foreach($filearray as $key => $file) |
|
| 246 | - { |
|
| 247 | - $totalsize+=$file['size']; |
|
| 248 | - } |
|
| 242 | + // Build file list |
|
| 243 | + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
| 244 | + $totalsize=0; |
|
| 245 | + foreach($filearray as $key => $file) |
|
| 246 | + { |
|
| 247 | + $totalsize+=$file['size']; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | - print '<tr><td class="titlefield" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; |
|
| 252 | - print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; |
|
| 251 | + print '<tr><td class="titlefield" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; |
|
| 252 | + print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; |
|
| 253 | 253 | |
| 254 | - print '</table>'; |
|
| 254 | + print '</table>'; |
|
| 255 | 255 | |
| 256 | 256 | print '</div>'; |
| 257 | 257 | |
| 258 | 258 | dol_fiche_end(); |
| 259 | 259 | |
| 260 | 260 | |
| 261 | - $modulepart = 'actions'; |
|
| 262 | - $permission = $user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create; |
|
| 263 | - $param = '&id=' . $object->id; |
|
| 264 | - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 261 | + $modulepart = 'actions'; |
|
| 262 | + $permission = $user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create; |
|
| 263 | + $param = '&id=' . $object->id; |
|
| 264 | + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 265 | 265 | } |
| 266 | 266 | else |
| 267 | 267 | { |
| 268 | - print $langs->trans("ErrorUnknown"); |
|
| 268 | + print $langs->trans("ErrorUnknown"); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // End of page |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 35 | 35 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
| 36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
| 37 | -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 37 | +if (! empty($conf->projet->enabled)) { |
|
| 38 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 39 | +} |
|
| 38 | 40 | |
| 39 | 41 | // Load translation files required by the page |
| 40 | 42 | $langs->loadLangs(array('companies', 'commercial', 'other', 'bills')); |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | |
| 46 | 48 | // Security check |
| 47 | 49 | $socid = GETPOST('socid','int'); |
| 48 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 50 | +if ($user->societe_id) { |
|
| 51 | + $socid=$user->societe_id; |
|
| 52 | +} |
|
| 49 | 53 | if ($user->societe_id > 0) |
| 50 | 54 | { |
| 51 | 55 | unset($_GET["action"]); |
@@ -69,8 +73,12 @@ discard block |
||
| 69 | 73 | $offset = $conf->liste_limit * $page; |
| 70 | 74 | $pageprev = $page - 1; |
| 71 | 75 | $pagenext = $page + 1; |
| 72 | -if (! $sortorder) $sortorder="ASC"; |
|
| 73 | -if (! $sortfield) $sortfield="name"; |
|
| 76 | +if (! $sortorder) { |
|
| 77 | + $sortorder="ASC"; |
|
| 78 | +} |
|
| 79 | +if (! $sortfield) { |
|
| 80 | + $sortfield="name"; |
|
| 81 | +} |
|
| 74 | 82 | |
| 75 | 83 | $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); |
| 76 | 84 | $modulepart='actions'; |
@@ -152,7 +160,9 @@ discard block |
||
| 152 | 160 | $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
| 153 | 161 | $morehtmlref.=$proj->ref; |
| 154 | 162 | $morehtmlref.='</a>'; |
| 155 | - if ($proj->title) $morehtmlref.=' - '.$proj->title; |
|
| 163 | + if ($proj->title) { |
|
| 164 | + $morehtmlref.=' - '.$proj->title; |
|
| 165 | + } |
|
| 156 | 166 | } else { |
| 157 | 167 | $morehtmlref.=''; |
| 158 | 168 | } |
@@ -179,17 +189,27 @@ discard block |
||
| 179 | 189 | |
| 180 | 190 | // Date start |
| 181 | 191 | print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">'; |
| 182 | - if (! $object->fulldayevent) print dol_print_date($object->datep,'dayhour'); |
|
| 183 | - else print dol_print_date($object->datep,'day'); |
|
| 184 | - if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); |
|
| 192 | + if (! $object->fulldayevent) { |
|
| 193 | + print dol_print_date($object->datep,'dayhour'); |
|
| 194 | + } else { |
|
| 195 | + print dol_print_date($object->datep,'day'); |
|
| 196 | + } |
|
| 197 | + if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) { |
|
| 198 | + print img_warning($langs->trans("Late")); |
|
| 199 | + } |
|
| 185 | 200 | print '</td>'; |
| 186 | 201 | print '</tr>'; |
| 187 | 202 | |
| 188 | 203 | // Date end |
| 189 | 204 | print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">'; |
| 190 | - if (! $object->fulldayevent) print dol_print_date($object->datef,'dayhour'); |
|
| 191 | - else print dol_print_date($object->datef,'day'); |
|
| 192 | - if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); |
|
| 205 | + if (! $object->fulldayevent) { |
|
| 206 | + print dol_print_date($object->datef,'dayhour'); |
|
| 207 | + } else { |
|
| 208 | + print dol_print_date($object->datef,'day'); |
|
| 209 | + } |
|
| 210 | + if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) { |
|
| 211 | + print img_warning($langs->trans("Late")); |
|
| 212 | + } |
|
| 193 | 213 | print '</td></tr>'; |
| 194 | 214 | |
| 195 | 215 | // Location |
@@ -203,19 +223,26 @@ discard block |
||
| 203 | 223 | $listofuserid=array(); |
| 204 | 224 | if (empty($donotclearsession)) |
| 205 | 225 | { |
| 206 | - if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first |
|
| 207 | - if (! empty($object->userassigned)) // Now concat assigned users |
|
| 226 | + if ($object->userownerid > 0) { |
|
| 227 | + $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); |
|
| 228 | + } |
|
| 229 | + // Owner first |
|
| 230 | + if (! empty($object->userassigned)) { |
|
| 231 | + // Now concat assigned users |
|
| 208 | 232 | { |
| 209 | 233 | // Restore array with key with same value than param 'id' |
| 210 | - $tmplist1=$object->userassigned; $tmplist2=array(); |
|
| 234 | + $tmplist1=$object->userassigned; |
|
| 235 | + } |
|
| 236 | + $tmplist2=array(); |
|
| 211 | 237 | foreach($tmplist1 as $key => $val) |
| 212 | 238 | { |
| 213 | - if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; |
|
| 239 | + if ($val['id'] && $val['id'] != $object->userownerid) { |
|
| 240 | + $listofuserid[$val['id']]=$val; |
|
| 241 | + } |
|
| 214 | 242 | } |
| 215 | 243 | } |
| 216 | 244 | $_SESSION['assignedtouser']=json_encode($listofuserid); |
| 217 | - } |
|
| 218 | - else |
|
| 245 | + } else |
|
| 219 | 246 | { |
| 220 | 247 | if (!empty($_SESSION['assignedtouser'])) |
| 221 | 248 | { |
@@ -262,8 +289,7 @@ discard block |
||
| 262 | 289 | $permission = $user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create; |
| 263 | 290 | $param = '&id=' . $object->id; |
| 264 | 291 | include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
| 265 | -} |
|
| 266 | -else |
|
| 292 | +} else |
|
| 267 | 293 | { |
| 268 | 294 | print $langs->trans("ErrorUnknown"); |
| 269 | 295 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 31 | 31 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 32 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 32 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; |
| 34 | 34 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 35 | 35 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
@@ -37,22 +37,22 @@ discard block |
||
| 37 | 37 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
| 39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
| 40 | -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 40 | +if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
| 41 | 41 | |
| 42 | 42 | // Load translation files required by the page |
| 43 | 43 | $langs->loadLangs(array('companies', 'commercial', 'other', 'bills')); |
| 44 | 44 | |
| 45 | 45 | $id = GETPOST('id', 'int'); |
| 46 | -$action=GETPOST('action', 'alpha'); |
|
| 46 | +$action = GETPOST('action', 'alpha'); |
|
| 47 | 47 | $confirm = GETPOST('confirm', 'alpha'); |
| 48 | 48 | |
| 49 | 49 | // Security check |
| 50 | -$socid = GETPOST('socid','int'); |
|
| 51 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 50 | +$socid = GETPOST('socid', 'int'); |
|
| 51 | +if ($user->societe_id) $socid = $user->societe_id; |
|
| 52 | 52 | if ($user->societe_id > 0) |
| 53 | 53 | { |
| 54 | 54 | unset($_GET["action"]); |
| 55 | - $action=''; |
|
| 55 | + $action = ''; |
|
| 56 | 56 | } |
| 57 | 57 | $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); |
| 58 | 58 | |
@@ -65,24 +65,24 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Get parameters |
| 68 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
| 69 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
| 70 | -$page = GETPOST("page",'int'); |
|
| 68 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
| 69 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
| 70 | +$page = GETPOST("page", 'int'); |
|
| 71 | 71 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 72 | 72 | $offset = $conf->liste_limit * $page; |
| 73 | 73 | $pageprev = $page - 1; |
| 74 | 74 | $pagenext = $page + 1; |
| 75 | -if (! $sortorder) $sortorder="ASC"; |
|
| 76 | -if (! $sortfield) $sortfield="name"; |
|
| 75 | +if (!$sortorder) $sortorder = "ASC"; |
|
| 76 | +if (!$sortfield) $sortfield = "name"; |
|
| 77 | 77 | |
| 78 | 78 | $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); |
| 79 | -$modulepart='actions'; |
|
| 79 | +$modulepart = 'actions'; |
|
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | /* |
| 83 | 83 | * Actions |
| 84 | 84 | */ |
| 85 | -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; |
|
| 85 | +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | /* |
@@ -91,78 +91,78 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $form = new Form($db); |
| 93 | 93 | |
| 94 | -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; |
|
| 95 | -llxHeader('',$langs->trans("Agenda"),$help_url); |
|
| 94 | +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; |
|
| 95 | +llxHeader('', $langs->trans("Agenda"), $help_url); |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | if ($object->id > 0) |
| 99 | 99 | { |
| 100 | - $result1=$object->fetch($id); |
|
| 101 | - $result2=$object->fetch_thirdparty(); |
|
| 102 | - $result3=$object->fetch_contact(); |
|
| 103 | - $result4=$object->fetch_userassigned(); |
|
| 104 | - $result5=$object->fetch_optionals(); |
|
| 100 | + $result1 = $object->fetch($id); |
|
| 101 | + $result2 = $object->fetch_thirdparty(); |
|
| 102 | + $result3 = $object->fetch_contact(); |
|
| 103 | + $result4 = $object->fetch_userassigned(); |
|
| 104 | + $result5 = $object->fetch_optionals(); |
|
| 105 | 105 | |
| 106 | 106 | if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) |
| 107 | 107 | { |
| 108 | - dol_print_error($db,$object->error); |
|
| 108 | + dol_print_error($db, $object->error); |
|
| 109 | 109 | exit; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ($object->authorid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->authorid); $object->author=$tmpuser; } |
|
| 113 | - if ($object->usermodid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermodid); $object->usermod=$tmpuser; } |
|
| 112 | + if ($object->authorid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser; } |
|
| 113 | + if ($object->usermodid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser; } |
|
| 114 | 114 | |
| 115 | - $author=new User($db); |
|
| 115 | + $author = new User($db); |
|
| 116 | 116 | $author->fetch($object->author->id); |
| 117 | - $object->author=$author; |
|
| 117 | + $object->author = $author; |
|
| 118 | 118 | |
| 119 | 119 | |
| 120 | - $head=actions_prepare_head($object); |
|
| 120 | + $head = actions_prepare_head($object); |
|
| 121 | 121 | |
| 122 | - $now=dol_now(); |
|
| 123 | - $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; |
|
| 122 | + $now = dol_now(); |
|
| 123 | + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; |
|
| 124 | 124 | |
| 125 | 125 | dol_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); |
| 126 | 126 | |
| 127 | - $linkback = img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"'); |
|
| 128 | - $linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php">'.$langs->trans("BackToList").'</a>'; |
|
| 127 | + $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); |
|
| 128 | + $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php">'.$langs->trans("BackToList").'</a>'; |
|
| 129 | 129 | |
| 130 | 130 | // Link to other agenda views |
| 131 | - $out=''; |
|
| 132 | - $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); |
|
| 133 | - $out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>'; |
|
| 134 | - $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); |
|
| 135 | - $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>'; |
|
| 136 | - $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); |
|
| 137 | - $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>'; |
|
| 138 | - $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); |
|
| 139 | - $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>'; |
|
| 140 | - |
|
| 141 | - $linkback.=$out; |
|
| 142 | - |
|
| 143 | - $morehtmlref='<div class="refidno">'; |
|
| 131 | + $out = ''; |
|
| 132 | + $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); |
|
| 133 | + $out .= '<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewPerUser").'</a>'; |
|
| 134 | + $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); |
|
| 135 | + $out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewCal").'</a>'; |
|
| 136 | + $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); |
|
| 137 | + $out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewWeek").'</a>'; |
|
| 138 | + $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); |
|
| 139 | + $out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewDay").'</a>'; |
|
| 140 | + |
|
| 141 | + $linkback .= $out; |
|
| 142 | + |
|
| 143 | + $morehtmlref = '<div class="refidno">'; |
|
| 144 | 144 | // Thirdparty |
| 145 | 145 | //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
| 146 | 146 | // Project |
| 147 | - if (! empty($conf->projet->enabled)) |
|
| 147 | + if (!empty($conf->projet->enabled)) |
|
| 148 | 148 | { |
| 149 | 149 | $langs->load("projects"); |
| 150 | 150 | //$morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
| 151 | - $morehtmlref.=$langs->trans('Project') . ': '; |
|
| 152 | - if (! empty($object->fk_project)) { |
|
| 151 | + $morehtmlref .= $langs->trans('Project').': '; |
|
| 152 | + if (!empty($object->fk_project)) { |
|
| 153 | 153 | $proj = new Project($db); |
| 154 | 154 | $proj->fetch($object->fk_project); |
| 155 | - $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
| 156 | - $morehtmlref.=$proj->ref; |
|
| 157 | - $morehtmlref.='</a>'; |
|
| 158 | - if ($proj->title) $morehtmlref.=' - '.$proj->title; |
|
| 155 | + $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
| 156 | + $morehtmlref .= $proj->ref; |
|
| 157 | + $morehtmlref .= '</a>'; |
|
| 158 | + if ($proj->title) $morehtmlref .= ' - '.$proj->title; |
|
| 159 | 159 | } else { |
| 160 | - $morehtmlref.=''; |
|
| 160 | + $morehtmlref .= ''; |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | - $morehtmlref.='</div>'; |
|
| 163 | + $morehtmlref .= '</div>'; |
|
| 164 | 164 | |
| 165 | - dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref); |
|
| 165 | + dol_banner_tab($object, 'id', $linkback, ($user->societe_id ? 0 : 1), 'id', 'ref', $morehtmlref); |
|
| 166 | 166 | |
| 167 | 167 | print '<div class="fichecenter">'; |
| 168 | 168 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | print '<table class="border" width="100%">'; |
| 173 | 173 | |
| 174 | 174 | // Type |
| 175 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 175 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 176 | 176 | { |
| 177 | 177 | print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>'; |
| 178 | 178 | } |
@@ -182,17 +182,17 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | // Date start |
| 184 | 184 | print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">'; |
| 185 | - if (! $object->fulldayevent) print dol_print_date($object->datep,'dayhour'); |
|
| 186 | - else print dol_print_date($object->datep,'day'); |
|
| 185 | + if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); |
|
| 186 | + else print dol_print_date($object->datep, 'day'); |
|
| 187 | 187 | if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); |
| 188 | 188 | print '</td>'; |
| 189 | 189 | print '</tr>'; |
| 190 | 190 | |
| 191 | 191 | // Date end |
| 192 | 192 | print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">'; |
| 193 | - if (! $object->fulldayevent) print dol_print_date($object->datef,'dayhour'); |
|
| 194 | - else print dol_print_date($object->datef,'day'); |
|
| 195 | - if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); |
|
| 193 | + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); |
|
| 194 | + else print dol_print_date($object->datef, 'day'); |
|
| 195 | + if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); |
|
| 196 | 196 | print '</td></tr>'; |
| 197 | 197 | |
| 198 | 198 | // Location |
@@ -203,32 +203,32 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | // Assigned to |
| 205 | 205 | print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">'; |
| 206 | - $listofuserid=array(); |
|
| 206 | + $listofuserid = array(); |
|
| 207 | 207 | if (empty($donotclearsession)) |
| 208 | 208 | { |
| 209 | - if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first |
|
| 210 | - if (! empty($object->userassigned)) // Now concat assigned users |
|
| 209 | + if ($object->userownerid > 0) $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first |
|
| 210 | + if (!empty($object->userassigned)) // Now concat assigned users |
|
| 211 | 211 | { |
| 212 | 212 | // Restore array with key with same value than param 'id' |
| 213 | - $tmplist1=$object->userassigned; $tmplist2=array(); |
|
| 214 | - foreach($tmplist1 as $key => $val) |
|
| 213 | + $tmplist1 = $object->userassigned; $tmplist2 = array(); |
|
| 214 | + foreach ($tmplist1 as $key => $val) |
|
| 215 | 215 | { |
| 216 | - if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val; |
|
| 216 | + if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val; |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | - $_SESSION['assignedtouser']=json_encode($listofuserid); |
|
| 219 | + $_SESSION['assignedtouser'] = json_encode($listofuserid); |
|
| 220 | 220 | } |
| 221 | 221 | else |
| 222 | 222 | { |
| 223 | 223 | if (!empty($_SESSION['assignedtouser'])) |
| 224 | 224 | { |
| 225 | - $listofuserid=json_decode($_SESSION['assignedtouser'], true); |
|
| 225 | + $listofuserid = json_decode($_SESSION['assignedtouser'], true); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | - $listofcontactid=array(); // not used yet |
|
| 229 | - $listofotherid=array(); // not used yet |
|
| 228 | + $listofcontactid = array(); // not used yet |
|
| 229 | + $listofotherid = array(); // not used yet |
|
| 230 | 230 | print '<div class="assignedtouser">'; |
| 231 | - print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid); |
|
| 231 | + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid); |
|
| 232 | 232 | print '</div>'; |
| 233 | 233 | /*if (in_array($user->id,array_keys($listofuserid))) |
| 234 | 234 | { |
@@ -243,11 +243,11 @@ discard block |
||
| 243 | 243 | print '<table class="border" width="100%">'; |
| 244 | 244 | |
| 245 | 245 | // Build file list |
| 246 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
| 247 | - $totalsize=0; |
|
| 248 | - foreach($filearray as $key => $file) |
|
| 246 | + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); |
|
| 247 | + $totalsize = 0; |
|
| 248 | + foreach ($filearray as $key => $file) |
|
| 249 | 249 | { |
| 250 | - $totalsize+=$file['size']; |
|
| 250 | + $totalsize += $file['size']; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | |
| 264 | 264 | $modulepart = 'actions'; |
| 265 | - $permission = $user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create; |
|
| 266 | - $param = '&id=' . $object->id; |
|
| 267 | - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 265 | + $permission = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create; |
|
| 266 | + $param = '&id='.$object->id; |
|
| 267 | + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; |
|
| 268 | 268 | } |
| 269 | 269 | else |
| 270 | 270 | { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | // If not choice done on calendar owner, we filter on user. |
| 52 | 52 | if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) |
| 53 | 53 | { |
| 54 | - $filtert=$user->id; |
|
| 54 | + $filtert=$user->id; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $sortfield = GETPOST("sortfield",'alpha'); |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); |
| 104 | 104 | if ($dateselect > 0) |
| 105 | 105 | { |
| 106 | - $day=GETPOST('dateselectday','int'); |
|
| 107 | - $month=GETPOST('dateselectmonth','int'); |
|
| 108 | - $year=GETPOST('dateselectyear','int'); |
|
| 106 | + $day=GETPOST('dateselectday','int'); |
|
| 107 | + $month=GETPOST('dateselectmonth','int'); |
|
| 108 | + $year=GETPOST('dateselectyear','int'); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; |
@@ -288,53 +288,53 @@ discard block |
||
| 288 | 288 | // Legend |
| 289 | 289 | if ($conf->use_javascript_ajax) |
| 290 | 290 | { |
| 291 | - $s=''; |
|
| 292 | - $s.='<script type="text/javascript">' . "\n"; |
|
| 293 | - $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 294 | - $s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n"; |
|
| 295 | - $s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n"; |
|
| 296 | - $s.='jQuery(".family_birthday").toggle();' . "\n"; |
|
| 297 | - if ($action=="show_week" || $action=="show_month" || empty($action)) |
|
| 298 | - { |
|
| 299 | - $s.='jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; |
|
| 300 | - $s.='var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; |
|
| 301 | - } |
|
| 302 | - $s.='});' . "\n"; |
|
| 303 | - $s.='</script>' . "\n"; |
|
| 304 | - if (! empty($conf->use_javascript_ajax)) |
|
| 305 | - { |
|
| 306 | - $s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>'; |
|
| 307 | - if (is_array($showextcals) && count($showextcals) > 0) |
|
| 308 | - { |
|
| 309 | - foreach ($showextcals as $val) |
|
| 310 | - { |
|
| 311 | - $htmlname = md5($val['name']); |
|
| 312 | - $s.='<script type="text/javascript">' . "\n"; |
|
| 313 | - $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 314 | - $s.=' jQuery("#check_ext' . $htmlname . '").click(function() {'; |
|
| 315 | - $s.=' /* alert("'.$htmlname.'"); */'; |
|
| 316 | - $s.=' jQuery(".family_ext' . $htmlname . '").toggle();'; |
|
| 317 | - $s.=' });' . "\n"; |
|
| 318 | - $s.='});' . "\n"; |
|
| 319 | - $s.='</script>' . "\n"; |
|
| 320 | - $s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val ['name'] . ' </div>'; |
|
| 321 | - } |
|
| 322 | - } |
|
| 291 | + $s=''; |
|
| 292 | + $s.='<script type="text/javascript">' . "\n"; |
|
| 293 | + $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 294 | + $s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n"; |
|
| 295 | + $s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n"; |
|
| 296 | + $s.='jQuery(".family_birthday").toggle();' . "\n"; |
|
| 297 | + if ($action=="show_week" || $action=="show_month" || empty($action)) |
|
| 298 | + { |
|
| 299 | + $s.='jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; |
|
| 300 | + $s.='var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; |
|
| 301 | + } |
|
| 302 | + $s.='});' . "\n"; |
|
| 303 | + $s.='</script>' . "\n"; |
|
| 304 | + if (! empty($conf->use_javascript_ajax)) |
|
| 305 | + { |
|
| 306 | + $s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>'; |
|
| 307 | + if (is_array($showextcals) && count($showextcals) > 0) |
|
| 308 | + { |
|
| 309 | + foreach ($showextcals as $val) |
|
| 310 | + { |
|
| 311 | + $htmlname = md5($val['name']); |
|
| 312 | + $s.='<script type="text/javascript">' . "\n"; |
|
| 313 | + $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 314 | + $s.=' jQuery("#check_ext' . $htmlname . '").click(function() {'; |
|
| 315 | + $s.=' /* alert("'.$htmlname.'"); */'; |
|
| 316 | + $s.=' jQuery(".family_ext' . $htmlname . '").toggle();'; |
|
| 317 | + $s.=' });' . "\n"; |
|
| 318 | + $s.='});' . "\n"; |
|
| 319 | + $s.='</script>' . "\n"; |
|
| 320 | + $s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val ['name'] . ' </div>'; |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>'; |
|
| 324 | + //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>'; |
|
| 325 | 325 | |
| 326 | - // Calendars from hooks |
|
| 327 | - $parameters=array(); $object=null; |
|
| 328 | - $reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action); |
|
| 329 | - if (empty($reshook)) |
|
| 330 | - { |
|
| 331 | - $s.= $hookmanager->resPrint; |
|
| 332 | - } |
|
| 333 | - elseif ($reshook > 1) |
|
| 334 | - { |
|
| 335 | - $s = $hookmanager->resPrint; |
|
| 336 | - } |
|
| 337 | - } |
|
| 326 | + // Calendars from hooks |
|
| 327 | + $parameters=array(); $object=null; |
|
| 328 | + $reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action); |
|
| 329 | + if (empty($reshook)) |
|
| 330 | + { |
|
| 331 | + $s.= $hookmanager->resPrint; |
|
| 332 | + } |
|
| 333 | + elseif ($reshook > 1) |
|
| 334 | + { |
|
| 335 | + $s = $hookmanager->resPrint; |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | // Discard auto action if option is on |
| 453 | 453 | if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') |
| 454 | 454 | { |
| 455 | - $i++; |
|
| 456 | - continue; |
|
| 455 | + $i++; |
|
| 456 | + continue; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | $datep=$db->jdate($obj->datep); |
@@ -487,15 +487,15 @@ discard block |
||
| 487 | 487 | // They are date start and end of action but modified to not be outside calendar view. |
| 488 | 488 | if ($event->percentage <= 0) |
| 489 | 489 | { |
| 490 | - $event->date_start_in_calendar=$datep; |
|
| 491 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 492 | - else $event->date_end_in_calendar=$datep; |
|
| 490 | + $event->date_start_in_calendar=$datep; |
|
| 491 | + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 492 | + else $event->date_end_in_calendar=$datep; |
|
| 493 | 493 | } |
| 494 | 494 | else |
| 495 | 495 | { |
| 496 | - $event->date_start_in_calendar=$datep; |
|
| 497 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 498 | - else $event->date_end_in_calendar=$datep; |
|
| 496 | + $event->date_start_in_calendar=$datep; |
|
| 497 | + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 498 | + else $event->date_end_in_calendar=$datep; |
|
| 499 | 499 | } |
| 500 | 500 | // Define ponctual property |
| 501 | 501 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) |
@@ -508,14 +508,14 @@ discard block |
||
| 508 | 508 | $event->date_start_in_calendar >= $lastdaytoshow) |
| 509 | 509 | { |
| 510 | 510 | // This record is out of visible range |
| 511 | - unset($event); |
|
| 511 | + unset($event); |
|
| 512 | 512 | } |
| 513 | 513 | else |
| 514 | - { |
|
| 515 | - //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
|
| 516 | - $event->fetch_userassigned(); // This load $event->userassigned |
|
| 514 | + { |
|
| 515 | + //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
|
| 516 | + $event->fetch_userassigned(); // This load $event->userassigned |
|
| 517 | 517 | |
| 518 | - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; |
|
| 518 | + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; |
|
| 519 | 519 | if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); |
| 520 | 520 | |
| 521 | 521 | // Add an entry in actionarray for each day |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | $loop=true; $j=0; |
| 529 | 529 | $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); |
| 530 | 530 | do |
| 531 | - { |
|
| 531 | + { |
|
| 532 | 532 | //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>'; |
| 533 | 533 | |
| 534 | 534 | $eventarray[$daykey][]=$event; |
@@ -603,9 +603,9 @@ discard block |
||
| 603 | 603 | $i=0; |
| 604 | 604 | for ($h = $begin_d; $h < $end_d; $h++) |
| 605 | 605 | { |
| 606 | - echo '<td align="center">'; |
|
| 607 | - print '<small style="font-family: courier">'.sprintf("%02d",$h).'</small>'; |
|
| 608 | - print "</td>"; |
|
| 606 | + echo '<td align="center">'; |
|
| 607 | + print '<small style="font-family: courier">'.sprintf("%02d",$h).'</small>'; |
|
| 608 | + print "</td>"; |
|
| 609 | 609 | } |
| 610 | 610 | echo "</td>\n"; |
| 611 | 611 | echo "</tr>\n"; |
@@ -620,8 +620,8 @@ discard block |
||
| 620 | 620 | $resql=$db->query($sql); |
| 621 | 621 | while ($obj = $db->fetch_object($resql)) |
| 622 | 622 | { |
| 623 | - $colorsbytype[$obj->code]=$obj->color; |
|
| 624 | - $labelbytype[$obj->code]=$obj->libelle; |
|
| 623 | + $colorsbytype[$obj->code]=$obj->color; |
|
| 624 | + $labelbytype[$obj->code]=$obj->libelle; |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | // Loop on each user to show calendar |
@@ -631,40 +631,40 @@ discard block |
||
| 631 | 631 | $var = false; |
| 632 | 632 | foreach ($typeofevents as $typeofevent) |
| 633 | 633 | { |
| 634 | - $var = ! $var; |
|
| 635 | - echo "<tr>"; |
|
| 636 | - echo '<td class="cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">' . $username->getNomUrl(1). '</td>'; |
|
| 637 | - $tmpday = $sav; |
|
| 638 | - |
|
| 639 | - // Lopp on each day of week |
|
| 640 | - $i = 0; |
|
| 641 | - for ($iter_day = 0; $iter_day < 8; $iter_day++) |
|
| 642 | - { |
|
| 643 | - if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
|
| 644 | - { |
|
| 645 | - $i++; |
|
| 646 | - continue; |
|
| 647 | - } |
|
| 634 | + $var = ! $var; |
|
| 635 | + echo "<tr>"; |
|
| 636 | + echo '<td class="cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">' . $username->getNomUrl(1). '</td>'; |
|
| 637 | + $tmpday = $sav; |
|
| 638 | + |
|
| 639 | + // Lopp on each day of week |
|
| 640 | + $i = 0; |
|
| 641 | + for ($iter_day = 0; $iter_day < 8; $iter_day++) |
|
| 642 | + { |
|
| 643 | + if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
|
| 644 | + { |
|
| 645 | + $i++; |
|
| 646 | + continue; |
|
| 647 | + } |
|
| 648 | 648 | |
| 649 | 649 | // Show days of the current week |
| 650 | - $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); |
|
| 651 | - $tmparray = dol_getdate($curtime,'fast'); |
|
| 652 | - $tmpday = $tmparray['mday']; |
|
| 653 | - $tmpmonth = $tmparray['mon']; |
|
| 654 | - $tmpyear = $tmparray['year']; |
|
| 655 | - |
|
| 656 | - $style='cal_current_month'; |
|
| 657 | - if ($iter_day == 6) $style.=' cal_other_month'; |
|
| 658 | - $today=0; |
|
| 659 | - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; |
|
| 660 | - if ($today) $style='cal_today_peruser'; |
|
| 661 | - |
|
| 662 | - show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
|
| 663 | - |
|
| 664 | - $i++; |
|
| 665 | - } |
|
| 666 | - echo "</tr>\n"; |
|
| 667 | - $showheader = false; |
|
| 650 | + $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); |
|
| 651 | + $tmparray = dol_getdate($curtime,'fast'); |
|
| 652 | + $tmpday = $tmparray['mday']; |
|
| 653 | + $tmpmonth = $tmparray['mon']; |
|
| 654 | + $tmpyear = $tmparray['year']; |
|
| 655 | + |
|
| 656 | + $style='cal_current_month'; |
|
| 657 | + if ($iter_day == 6) $style.=' cal_other_month'; |
|
| 658 | + $today=0; |
|
| 659 | + if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; |
|
| 660 | + if ($today) $style='cal_today_peruser'; |
|
| 661 | + |
|
| 662 | + show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
|
| 663 | + |
|
| 664 | + $i++; |
|
| 665 | + } |
|
| 666 | + echo "</tr>\n"; |
|
| 667 | + $showheader = false; |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | echo "</table>\n"; |
@@ -672,23 +672,23 @@ discard block |
||
| 672 | 672 | |
| 673 | 673 | if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 674 | 674 | { |
| 675 | - $langs->load("commercial"); |
|
| 676 | - print '<br>'.$langs->trans("Legend").': <br>'; |
|
| 677 | - foreach($colorsbytype as $code => $color) |
|
| 678 | - { |
|
| 679 | - if ($color) |
|
| 680 | - { |
|
| 681 | - print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color?'background: #'.$color.';':'').'width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 682 | - print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code]; |
|
| 683 | - //print $code; |
|
| 684 | - print '</div>'; |
|
| 685 | - } |
|
| 686 | - } |
|
| 687 | - //$color=sprintf("%02x%02x%02x",$theme_datacolor[0][0],$theme_datacolor[0][1],$theme_datacolor[0][2]); |
|
| 688 | - print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 689 | - print $langs->trans("Other"); |
|
| 690 | - print '</div>'; |
|
| 691 | - /* TODO Show this if at least one cumulated event |
|
| 675 | + $langs->load("commercial"); |
|
| 676 | + print '<br>'.$langs->trans("Legend").': <br>'; |
|
| 677 | + foreach($colorsbytype as $code => $color) |
|
| 678 | + { |
|
| 679 | + if ($color) |
|
| 680 | + { |
|
| 681 | + print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color?'background: #'.$color.';':'').'width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 682 | + print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code]; |
|
| 683 | + //print $code; |
|
| 684 | + print '</div>'; |
|
| 685 | + } |
|
| 686 | + } |
|
| 687 | + //$color=sprintf("%02x%02x%02x",$theme_datacolor[0][0],$theme_datacolor[0][1],$theme_datacolor[0][2]); |
|
| 688 | + print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 689 | + print $langs->trans("Other"); |
|
| 690 | + print '</div>'; |
|
| 691 | + /* TODO Show this if at least one cumulated event |
|
| 692 | 692 | print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #222222; width:16px; float: left; margin-right: 4px;"> </div>'; |
| 693 | 693 | print $langs->trans("SeveralEvents"); |
| 694 | 694 | print '</div>'; |
@@ -759,298 +759,298 @@ discard block |
||
| 759 | 759 | */ |
| 760 | 760 | function show_day_events_pertype($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false) |
| 761 | 761 | { |
| 762 | - global $db; |
|
| 763 | - global $user, $conf, $langs, $hookmanager, $action; |
|
| 764 | - global $filter, $filtert, $status, $actioncode; // Filters used into search form |
|
| 765 | - global $theme_datacolor; // Array with a list of different we can use (come from theme) |
|
| 766 | - global $cachethirdparties, $cachecontacts, $cacheprojects, $colorindexused; |
|
| 767 | - global $begin_h, $end_h; |
|
| 762 | + global $db; |
|
| 763 | + global $user, $conf, $langs, $hookmanager, $action; |
|
| 764 | + global $filter, $filtert, $status, $actioncode; // Filters used into search form |
|
| 765 | + global $theme_datacolor; // Array with a list of different we can use (come from theme) |
|
| 766 | + global $cachethirdparties, $cachecontacts, $cacheprojects, $colorindexused; |
|
| 767 | + global $begin_h, $end_h; |
|
| 768 | 768 | |
| 769 | - $cases1 = array(); // Color first half hour |
|
| 770 | - $cases2 = array(); // Color second half hour |
|
| 769 | + $cases1 = array(); // Color first half hour |
|
| 770 | + $cases2 = array(); // Color second half hour |
|
| 771 | 771 | |
| 772 | - $curtime = dol_mktime(0, 0, 0, $month, $day, $year); |
|
| 772 | + $curtime = dol_mktime(0, 0, 0, $month, $day, $year); |
|
| 773 | 773 | |
| 774 | - $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); |
|
| 775 | - $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); |
|
| 774 | + $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); |
|
| 775 | + $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); |
|
| 776 | 776 | |
| 777 | - $nextindextouse=count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ... |
|
| 778 | - //if ($username->id && $day==1) var_dump($eventarray); |
|
| 777 | + $nextindextouse=count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ... |
|
| 778 | + //if ($username->id && $day==1) var_dump($eventarray); |
|
| 779 | 779 | |
| 780 | - // We are in a particular day for $username, now we scan all events |
|
| 781 | - foreach ($eventarray as $daykey => $notused) |
|
| 782 | - { |
|
| 783 | - $annee = date('Y',$daykey); |
|
| 784 | - $mois = date('m',$daykey); |
|
| 785 | - $jour = date('d',$daykey); |
|
| 786 | - //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n"; |
|
| 780 | + // We are in a particular day for $username, now we scan all events |
|
| 781 | + foreach ($eventarray as $daykey => $notused) |
|
| 782 | + { |
|
| 783 | + $annee = date('Y',$daykey); |
|
| 784 | + $mois = date('m',$daykey); |
|
| 785 | + $jour = date('d',$daykey); |
|
| 786 | + //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n"; |
|
| 787 | 787 | |
| 788 | - if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? |
|
| 789 | - { |
|
| 790 | - // Scan all event for this date |
|
| 791 | - foreach ($eventarray[$daykey] as $index => $event) |
|
| 792 | - { |
|
| 793 | - //var_dump($event); |
|
| 794 | - |
|
| 795 | - $keysofuserassigned=array_keys($event->userassigned); |
|
| 796 | - if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 797 | - //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
|
| 798 | - |
|
| 799 | - $parameters=array(); |
|
| 800 | - $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks |
|
| 801 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 802 | - |
|
| 803 | - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); |
|
| 804 | - |
|
| 805 | - // Define $color (Hex string like '0088FF') and $cssclass of event |
|
| 806 | - $color=-1; $cssclass=''; $colorindex=-1; |
|
| 807 | - if (in_array($user->id, $keysofuserassigned)) |
|
| 808 | - { |
|
| 809 | - $nummytasks++; $cssclass='family_mytasks'; |
|
| 810 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; |
|
| 811 | - } |
|
| 812 | - else if ($event->type_code == 'ICALEVENT') |
|
| 813 | - { |
|
| 814 | - $numical++; |
|
| 815 | - if (! empty($event->icalname)) |
|
| 816 | - { |
|
| 817 | - if (! isset($numicals[dol_string_nospecial($event->icalname)])) { |
|
| 818 | - $numicals[dol_string_nospecial($event->icalname)] = 0; |
|
| 819 | - } |
|
| 820 | - $numicals[dol_string_nospecial($event->icalname)]++; |
|
| 821 | - } |
|
| 822 | - |
|
| 823 | - $color=$event->icalcolor; |
|
| 824 | - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); |
|
| 825 | - } |
|
| 826 | - else if ($event->type_code == 'BIRTHDAY') |
|
| 827 | - { |
|
| 828 | - $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 829 | - } |
|
| 830 | - else |
|
| 831 | - { |
|
| 832 | - $numother++; $cssclass='family_other'; |
|
| 833 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; |
|
| 834 | - } |
|
| 835 | - |
|
| 836 | - if ($color < 0) // Color was not forced. Set color according to color index. |
|
| 837 | - { |
|
| 838 | - // Define color index if not yet defined |
|
| 839 | - $idusertouse=($event->userownerid?$event->userownerid:0); |
|
| 840 | - if (isset($colorindexused[$idusertouse])) |
|
| 841 | - { |
|
| 842 | - $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user |
|
| 843 | - } |
|
| 844 | - else |
|
| 845 | - { |
|
| 846 | - $colorindex=$nextindextouse; |
|
| 847 | - $colorindexused[$idusertouse]=$colorindex; |
|
| 848 | - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color |
|
| 849 | - } |
|
| 850 | - // Define color |
|
| 851 | - $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 852 | - } |
|
| 853 | - //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; |
|
| 854 | - |
|
| 855 | - // Define all rects with event (cases1 is first half hour, cases2 is second half hour) |
|
| 856 | - for ($h = $begin_h; $h < $end_h; $h++) |
|
| 857 | - { |
|
| 858 | - //if ($username->id == 1 && $day==1) print 'h='.$h; |
|
| 859 | - $newcolor = ''; //init |
|
| 860 | - if (empty($event->fulldayevent)) |
|
| 861 | - { |
|
| 862 | - $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0); |
|
| 863 | - $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0); |
|
| 864 | - $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); |
|
| 865 | - |
|
| 866 | - $dateendtouse=$event->date_end_in_calendar; |
|
| 867 | - if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; |
|
| 868 | - |
|
| 869 | - //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
|
| 870 | - |
|
| 871 | - if ($event->date_start_in_calendar < $b && $dateendtouse > $a) |
|
| 872 | - { |
|
| 873 | - $busy=$event->transparency; |
|
| 874 | - $cases1[$h][$event->id]['busy']=$busy; |
|
| 875 | - $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 876 | - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
|
| 877 | - { |
|
| 878 | - $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 879 | - $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 880 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 881 | - else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 882 | - } |
|
| 883 | - $cases1[$h][$event->id]['string'].=' - '.$event->label; |
|
| 884 | - $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 885 | - $cases1[$h][$event->id]['color']=$color; |
|
| 886 | - if ($event->fk_project > 0) |
|
| 887 | - { |
|
| 888 | - if (empty($cacheprojects[$event->fk_project])) |
|
| 889 | - { |
|
| 890 | - $tmpproj=new Project($db); |
|
| 891 | - $tmpproj->fetch($event->fk_project); |
|
| 892 | - $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 893 | - } |
|
| 894 | - $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 895 | - } |
|
| 896 | - if ($event->socid > 0) |
|
| 897 | - { |
|
| 898 | - if (empty($cachethirdparties[$event->socid])) |
|
| 899 | - { |
|
| 900 | - $tmpthirdparty=new Societe($db); |
|
| 901 | - $tmpthirdparty->fetch($event->socid); |
|
| 902 | - $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 903 | - } |
|
| 904 | - $cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 905 | - } |
|
| 906 | - if ($event->contactid > 0) |
|
| 907 | - { |
|
| 908 | - if (empty($cachecontacts[$event->contactid])) |
|
| 909 | - { |
|
| 910 | - $tmpcontact=new Contact($db); |
|
| 911 | - $tmpcontact->fetch($event->contactid); |
|
| 912 | - $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 913 | - } |
|
| 914 | - $cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 915 | - } |
|
| 916 | - } |
|
| 917 | - if ($event->date_start_in_calendar < $c && $dateendtouse > $b) |
|
| 918 | - { |
|
| 919 | - $busy=$event->transparency; |
|
| 920 | - $cases2[$h][$event->id]['busy']=$busy; |
|
| 921 | - $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 922 | - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
|
| 923 | - { |
|
| 924 | - $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 925 | - $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 926 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 927 | - else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 928 | - } |
|
| 929 | - $cases2[$h][$event->id]['string'].=' - '.$event->label; |
|
| 930 | - $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 931 | - $cases2[$h][$event->id]['color']=$color; |
|
| 932 | - if ($event->fk_project > 0) |
|
| 933 | - { |
|
| 934 | - if (empty($cacheprojects[$event->fk_project])) |
|
| 935 | - { |
|
| 936 | - $tmpproj=new Project($db); |
|
| 937 | - $tmpproj->fetch($event->fk_project); |
|
| 938 | - $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 939 | - } |
|
| 940 | - $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 941 | - } |
|
| 942 | - if ($event->socid > 0) |
|
| 943 | - { |
|
| 944 | - if (empty($cachethirdparties[$event->socid])) |
|
| 945 | - { |
|
| 946 | - $tmpthirdparty=new Societe($db); |
|
| 947 | - $tmpthirdparty->fetch($event->socid); |
|
| 948 | - $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 949 | - } |
|
| 950 | - $cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 951 | - } |
|
| 952 | - if ($event->contactid > 0) |
|
| 953 | - { |
|
| 954 | - if (empty($cachecontacts[$event->contactid])) |
|
| 955 | - { |
|
| 956 | - $tmpcontact=new Contact($db); |
|
| 957 | - $tmpcontact->fetch($event->contactid); |
|
| 958 | - $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 959 | - } |
|
| 960 | - $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 961 | - } |
|
| 962 | - } |
|
| 963 | - } |
|
| 964 | - else |
|
| 965 | - { |
|
| 966 | - $busy=$event->transparency; |
|
| 967 | - $cases1[$h][$event->id]['busy']=$busy; |
|
| 968 | - $cases2[$h][$event->id]['busy']=$busy; |
|
| 969 | - $cases1[$h][$event->id]['string']=$event->label; |
|
| 970 | - $cases2[$h][$event->id]['string']=$event->label; |
|
| 971 | - $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 972 | - $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 973 | - $cases1[$h][$event->id]['color']=$color; |
|
| 974 | - $cases2[$h][$event->id]['color']=$color; |
|
| 975 | - } |
|
| 976 | - } |
|
| 977 | - $i++; |
|
| 978 | - } |
|
| 979 | - |
|
| 980 | - break; // We found the date we were looking for. No need to search anymore. |
|
| 981 | - } |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - // Now output $casesX |
|
| 985 | - for ($h = $begin_h; $h < $end_h; $h++) |
|
| 986 | - { |
|
| 987 | - $color1='';$color2=''; |
|
| 988 | - $style1='';$style2=''; |
|
| 989 | - $string1=' ';$string2=' '; |
|
| 990 | - $title1='';$title2=''; |
|
| 991 | - if (isset($cases1[$h]) && $cases1[$h] != '') |
|
| 992 | - { |
|
| 993 | - //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 994 | - if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 995 | - $string1=' '; |
|
| 996 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; |
|
| 997 | - else $style1='peruser_busy'; |
|
| 998 | - foreach($cases1[$h] as $id => $ev) |
|
| 999 | - { |
|
| 1000 | - if ($ev['busy']) $style1='peruser_busy'; |
|
| 1001 | - } |
|
| 1002 | - } |
|
| 1003 | - if (isset($cases2[$h]) && $cases2[$h] != '') |
|
| 1004 | - { |
|
| 1005 | - //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1006 | - if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1007 | - $string2=' '; |
|
| 1008 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; |
|
| 1009 | - else $style2='peruser_busy'; |
|
| 1010 | - foreach($cases2[$h] as $id => $ev) |
|
| 1011 | - { |
|
| 1012 | - if ($ev['busy']) $style2='peruser_busy'; |
|
| 1013 | - } |
|
| 1014 | - } |
|
| 788 | + if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? |
|
| 789 | + { |
|
| 790 | + // Scan all event for this date |
|
| 791 | + foreach ($eventarray[$daykey] as $index => $event) |
|
| 792 | + { |
|
| 793 | + //var_dump($event); |
|
| 794 | + |
|
| 795 | + $keysofuserassigned=array_keys($event->userassigned); |
|
| 796 | + if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 797 | + //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
|
| 798 | + |
|
| 799 | + $parameters=array(); |
|
| 800 | + $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks |
|
| 801 | + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 802 | + |
|
| 803 | + $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); |
|
| 804 | + |
|
| 805 | + // Define $color (Hex string like '0088FF') and $cssclass of event |
|
| 806 | + $color=-1; $cssclass=''; $colorindex=-1; |
|
| 807 | + if (in_array($user->id, $keysofuserassigned)) |
|
| 808 | + { |
|
| 809 | + $nummytasks++; $cssclass='family_mytasks'; |
|
| 810 | + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; |
|
| 811 | + } |
|
| 812 | + else if ($event->type_code == 'ICALEVENT') |
|
| 813 | + { |
|
| 814 | + $numical++; |
|
| 815 | + if (! empty($event->icalname)) |
|
| 816 | + { |
|
| 817 | + if (! isset($numicals[dol_string_nospecial($event->icalname)])) { |
|
| 818 | + $numicals[dol_string_nospecial($event->icalname)] = 0; |
|
| 819 | + } |
|
| 820 | + $numicals[dol_string_nospecial($event->icalname)]++; |
|
| 821 | + } |
|
| 822 | + |
|
| 823 | + $color=$event->icalcolor; |
|
| 824 | + $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); |
|
| 825 | + } |
|
| 826 | + else if ($event->type_code == 'BIRTHDAY') |
|
| 827 | + { |
|
| 828 | + $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 829 | + } |
|
| 830 | + else |
|
| 831 | + { |
|
| 832 | + $numother++; $cssclass='family_other'; |
|
| 833 | + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; |
|
| 834 | + } |
|
| 835 | + |
|
| 836 | + if ($color < 0) // Color was not forced. Set color according to color index. |
|
| 837 | + { |
|
| 838 | + // Define color index if not yet defined |
|
| 839 | + $idusertouse=($event->userownerid?$event->userownerid:0); |
|
| 840 | + if (isset($colorindexused[$idusertouse])) |
|
| 841 | + { |
|
| 842 | + $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user |
|
| 843 | + } |
|
| 844 | + else |
|
| 845 | + { |
|
| 846 | + $colorindex=$nextindextouse; |
|
| 847 | + $colorindexused[$idusertouse]=$colorindex; |
|
| 848 | + if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color |
|
| 849 | + } |
|
| 850 | + // Define color |
|
| 851 | + $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 852 | + } |
|
| 853 | + //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; |
|
| 854 | + |
|
| 855 | + // Define all rects with event (cases1 is first half hour, cases2 is second half hour) |
|
| 856 | + for ($h = $begin_h; $h < $end_h; $h++) |
|
| 857 | + { |
|
| 858 | + //if ($username->id == 1 && $day==1) print 'h='.$h; |
|
| 859 | + $newcolor = ''; //init |
|
| 860 | + if (empty($event->fulldayevent)) |
|
| 861 | + { |
|
| 862 | + $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0); |
|
| 863 | + $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0); |
|
| 864 | + $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); |
|
| 865 | + |
|
| 866 | + $dateendtouse=$event->date_end_in_calendar; |
|
| 867 | + if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; |
|
| 868 | + |
|
| 869 | + //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
|
| 870 | + |
|
| 871 | + if ($event->date_start_in_calendar < $b && $dateendtouse > $a) |
|
| 872 | + { |
|
| 873 | + $busy=$event->transparency; |
|
| 874 | + $cases1[$h][$event->id]['busy']=$busy; |
|
| 875 | + $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 876 | + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
|
| 877 | + { |
|
| 878 | + $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 879 | + $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 880 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 881 | + else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 882 | + } |
|
| 883 | + $cases1[$h][$event->id]['string'].=' - '.$event->label; |
|
| 884 | + $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 885 | + $cases1[$h][$event->id]['color']=$color; |
|
| 886 | + if ($event->fk_project > 0) |
|
| 887 | + { |
|
| 888 | + if (empty($cacheprojects[$event->fk_project])) |
|
| 889 | + { |
|
| 890 | + $tmpproj=new Project($db); |
|
| 891 | + $tmpproj->fetch($event->fk_project); |
|
| 892 | + $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 893 | + } |
|
| 894 | + $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 895 | + } |
|
| 896 | + if ($event->socid > 0) |
|
| 897 | + { |
|
| 898 | + if (empty($cachethirdparties[$event->socid])) |
|
| 899 | + { |
|
| 900 | + $tmpthirdparty=new Societe($db); |
|
| 901 | + $tmpthirdparty->fetch($event->socid); |
|
| 902 | + $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 903 | + } |
|
| 904 | + $cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 905 | + } |
|
| 906 | + if ($event->contactid > 0) |
|
| 907 | + { |
|
| 908 | + if (empty($cachecontacts[$event->contactid])) |
|
| 909 | + { |
|
| 910 | + $tmpcontact=new Contact($db); |
|
| 911 | + $tmpcontact->fetch($event->contactid); |
|
| 912 | + $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 913 | + } |
|
| 914 | + $cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 915 | + } |
|
| 916 | + } |
|
| 917 | + if ($event->date_start_in_calendar < $c && $dateendtouse > $b) |
|
| 918 | + { |
|
| 919 | + $busy=$event->transparency; |
|
| 920 | + $cases2[$h][$event->id]['busy']=$busy; |
|
| 921 | + $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 922 | + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
|
| 923 | + { |
|
| 924 | + $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 925 | + $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 926 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 927 | + else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 928 | + } |
|
| 929 | + $cases2[$h][$event->id]['string'].=' - '.$event->label; |
|
| 930 | + $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 931 | + $cases2[$h][$event->id]['color']=$color; |
|
| 932 | + if ($event->fk_project > 0) |
|
| 933 | + { |
|
| 934 | + if (empty($cacheprojects[$event->fk_project])) |
|
| 935 | + { |
|
| 936 | + $tmpproj=new Project($db); |
|
| 937 | + $tmpproj->fetch($event->fk_project); |
|
| 938 | + $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 939 | + } |
|
| 940 | + $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 941 | + } |
|
| 942 | + if ($event->socid > 0) |
|
| 943 | + { |
|
| 944 | + if (empty($cachethirdparties[$event->socid])) |
|
| 945 | + { |
|
| 946 | + $tmpthirdparty=new Societe($db); |
|
| 947 | + $tmpthirdparty->fetch($event->socid); |
|
| 948 | + $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 949 | + } |
|
| 950 | + $cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 951 | + } |
|
| 952 | + if ($event->contactid > 0) |
|
| 953 | + { |
|
| 954 | + if (empty($cachecontacts[$event->contactid])) |
|
| 955 | + { |
|
| 956 | + $tmpcontact=new Contact($db); |
|
| 957 | + $tmpcontact->fetch($event->contactid); |
|
| 958 | + $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 959 | + } |
|
| 960 | + $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 961 | + } |
|
| 962 | + } |
|
| 963 | + } |
|
| 964 | + else |
|
| 965 | + { |
|
| 966 | + $busy=$event->transparency; |
|
| 967 | + $cases1[$h][$event->id]['busy']=$busy; |
|
| 968 | + $cases2[$h][$event->id]['busy']=$busy; |
|
| 969 | + $cases1[$h][$event->id]['string']=$event->label; |
|
| 970 | + $cases2[$h][$event->id]['string']=$event->label; |
|
| 971 | + $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 972 | + $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 973 | + $cases1[$h][$event->id]['color']=$color; |
|
| 974 | + $cases2[$h][$event->id]['color']=$color; |
|
| 975 | + } |
|
| 976 | + } |
|
| 977 | + $i++; |
|
| 978 | + } |
|
| 1015 | 979 | |
| 1016 | - $ids1='';$ids2=''; |
|
| 1017 | - if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h])); |
|
| 1018 | - if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h])); |
|
| 980 | + break; // We found the date we were looking for. No need to search anymore. |
|
| 981 | + } |
|
| 982 | + } |
|
| 1019 | 983 | |
| 1020 | - if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1021 | - else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1022 | - if (count($cases1[$h]) == 1) // only 1 event |
|
| 1023 | - { |
|
| 1024 | - $output = array_slice($cases1[$h], 0, 1); |
|
| 1025 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1026 | - if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1027 | - if ($output[0]['color']) $color1 = $output[0]['color']; |
|
| 1028 | - } |
|
| 1029 | - else if (count($cases1[$h]) > 1) |
|
| 1030 | - { |
|
| 1031 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1032 | - $color1='222222'; |
|
| 1033 | - } |
|
| 984 | + // Now output $casesX |
|
| 985 | + for ($h = $begin_h; $h < $end_h; $h++) |
|
| 986 | + { |
|
| 987 | + $color1='';$color2=''; |
|
| 988 | + $style1='';$style2=''; |
|
| 989 | + $string1=' ';$string2=' '; |
|
| 990 | + $title1='';$title2=''; |
|
| 991 | + if (isset($cases1[$h]) && $cases1[$h] != '') |
|
| 992 | + { |
|
| 993 | + //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 994 | + if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 995 | + $string1=' '; |
|
| 996 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; |
|
| 997 | + else $style1='peruser_busy'; |
|
| 998 | + foreach($cases1[$h] as $id => $ev) |
|
| 999 | + { |
|
| 1000 | + if ($ev['busy']) $style1='peruser_busy'; |
|
| 1001 | + } |
|
| 1002 | + } |
|
| 1003 | + if (isset($cases2[$h]) && $cases2[$h] != '') |
|
| 1004 | + { |
|
| 1005 | + //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1006 | + if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1007 | + $string2=' '; |
|
| 1008 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; |
|
| 1009 | + else $style2='peruser_busy'; |
|
| 1010 | + foreach($cases2[$h] as $id => $ev) |
|
| 1011 | + { |
|
| 1012 | + if ($ev['busy']) $style2='peruser_busy'; |
|
| 1013 | + } |
|
| 1014 | + } |
|
| 1034 | 1015 | |
| 1035 | - if (count($cases2[$h]) == 1) // only 1 event |
|
| 1036 | - { |
|
| 1037 | - $output = array_slice($cases2[$h], 0, 1); |
|
| 1038 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1039 | - if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1040 | - if ($output[0]['color']) $color2 = $output[0]['color']; |
|
| 1041 | - } |
|
| 1042 | - else if (count($cases2[$h]) > 1) |
|
| 1043 | - { |
|
| 1044 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1045 | - $color2='222222'; |
|
| 1046 | - } |
|
| 1047 | - print '<table class="nobordernopadding" width="100%">'; |
|
| 1048 | - print '<tr><td '.($color1?'style="background: #'.$color1.';"':'').'class="'.($style1?$style1.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>'; |
|
| 1049 | - print $string1; |
|
| 1050 | - print '</td><td '.($color2?'style="background: #'.$color2.';"':'').'class="'.($style2?$style2.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>'; |
|
| 1051 | - print $string2; |
|
| 1052 | - print '</td></tr>'; |
|
| 1053 | - print '</table>'; |
|
| 1054 | - print '</td>'; |
|
| 1055 | - } |
|
| 1016 | + $ids1='';$ids2=''; |
|
| 1017 | + if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h])); |
|
| 1018 | + if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h])); |
|
| 1019 | + |
|
| 1020 | + if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1021 | + else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1022 | + if (count($cases1[$h]) == 1) // only 1 event |
|
| 1023 | + { |
|
| 1024 | + $output = array_slice($cases1[$h], 0, 1); |
|
| 1025 | + $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1026 | + if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1027 | + if ($output[0]['color']) $color1 = $output[0]['color']; |
|
| 1028 | + } |
|
| 1029 | + else if (count($cases1[$h]) > 1) |
|
| 1030 | + { |
|
| 1031 | + $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1032 | + $color1='222222'; |
|
| 1033 | + } |
|
| 1034 | + |
|
| 1035 | + if (count($cases2[$h]) == 1) // only 1 event |
|
| 1036 | + { |
|
| 1037 | + $output = array_slice($cases2[$h], 0, 1); |
|
| 1038 | + $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1039 | + if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1040 | + if ($output[0]['color']) $color2 = $output[0]['color']; |
|
| 1041 | + } |
|
| 1042 | + else if (count($cases2[$h]) > 1) |
|
| 1043 | + { |
|
| 1044 | + $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1045 | + $color2='222222'; |
|
| 1046 | + } |
|
| 1047 | + print '<table class="nobordernopadding" width="100%">'; |
|
| 1048 | + print '<tr><td '.($color1?'style="background: #'.$color1.';"':'').'class="'.($style1?$style1.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>'; |
|
| 1049 | + print $string1; |
|
| 1050 | + print '</td><td '.($color2?'style="background: #'.$color2.';"':'').'class="'.($style2?$style2.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>'; |
|
| 1051 | + print $string2; |
|
| 1052 | + print '</td></tr>'; |
|
| 1053 | + print '</table>'; |
|
| 1054 | + print '</td>'; |
|
| 1055 | + } |
|
| 1056 | 1056 | } |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 40 | 40 | |
| 41 | 41 | |
| 42 | -if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; |
|
| 42 | +if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { |
|
| 43 | + $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; |
|
| 44 | +} |
|
| 43 | 45 | |
| 44 | 46 | $filter = GETPOST("filter",'alpha',3); |
| 45 | 47 | $filtert = GETPOST("filtert","int",3); |
@@ -60,22 +62,36 @@ discard block |
||
| 60 | 62 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 61 | 63 | $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
| 62 | 64 | $offset = $limit * $page; |
| 63 | -if (! $sortorder) $sortorder="ASC"; |
|
| 64 | -if (! $sortfield) $sortfield="a.datec"; |
|
| 65 | +if (! $sortorder) { |
|
| 66 | + $sortorder="ASC"; |
|
| 67 | +} |
|
| 68 | +if (! $sortfield) { |
|
| 69 | + $sortfield="a.datec"; |
|
| 70 | +} |
|
| 65 | 71 | |
| 66 | 72 | // Security check |
| 67 | 73 | $socid = GETPOST("socid","int"); |
| 68 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 74 | +if ($user->societe_id) { |
|
| 75 | + $socid=$user->societe_id; |
|
| 76 | +} |
|
| 69 | 77 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
| 70 | -if ($socid < 0) $socid=''; |
|
| 78 | +if ($socid < 0) { |
|
| 79 | + $socid=''; |
|
| 80 | +} |
|
| 71 | 81 | |
| 72 | 82 | $canedit=1; |
| 73 | -if (! $user->rights->agenda->myactions->read) accessforbidden(); |
|
| 74 | -if (! $user->rights->agenda->allactions->read) $canedit=0; |
|
| 75 | -if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me |
|
| 83 | +if (! $user->rights->agenda->myactions->read) { |
|
| 84 | + accessforbidden(); |
|
| 85 | +} |
|
| 86 | +if (! $user->rights->agenda->allactions->read) { |
|
| 87 | + $canedit=0; |
|
| 88 | +} |
|
| 89 | +if (! $user->rights->agenda->allactions->read || $filter =='mine') { |
|
| 90 | + // If no permission to see all, we show only affected to me |
|
| 76 | 91 | { |
| 77 | 92 | $filtert=$user->id; |
| 78 | 93 | } |
| 94 | +} |
|
| 79 | 95 | |
| 80 | 96 | //$action=GETPOST('action','alpha'); |
| 81 | 97 | $action='show_pertype'; |
@@ -92,13 +108,16 @@ discard block |
||
| 92 | 108 | if (GETPOST('actioncode','array')) |
| 93 | 109 | { |
| 94 | 110 | $actioncode=GETPOST('actioncode','array',3); |
| 95 | - if (! count($actioncode)) $actioncode='0'; |
|
| 96 | -} |
|
| 97 | -else |
|
| 111 | + if (! count($actioncode)) { |
|
| 112 | + $actioncode='0'; |
|
| 113 | + } |
|
| 114 | + } else |
|
| 98 | 115 | { |
| 99 | 116 | $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
| 100 | 117 | } |
| 101 | -if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 118 | +if ($actioncode == '' && empty($actioncodearray)) { |
|
| 119 | + $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 120 | +} |
|
| 102 | 121 | |
| 103 | 122 | $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); |
| 104 | 123 | if ($dateselect > 0) |
@@ -112,17 +131,27 @@ discard block |
||
| 112 | 131 | $tmparray=explode('-',$tmp); |
| 113 | 132 | $begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); |
| 114 | 133 | $end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18); |
| 115 | -if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; |
|
| 116 | -if ($end_h < 1 || $end_h > 24) $end_h = 18; |
|
| 117 | -if ($end_h <= $begin_h) $end_h = $begin_h + 1; |
|
| 134 | +if ($begin_h < 0 || $begin_h > 23) { |
|
| 135 | + $begin_h = 9; |
|
| 136 | +} |
|
| 137 | +if ($end_h < 1 || $end_h > 24) { |
|
| 138 | + $end_h = 18; |
|
| 139 | +} |
|
| 140 | +if ($end_h <= $begin_h) { |
|
| 141 | + $end_h = $begin_h + 1; |
|
| 142 | +} |
|
| 118 | 143 | |
| 119 | 144 | $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS; |
| 120 | 145 | $tmparray=explode('-',$tmp); |
| 121 | 146 | $begin_d = 1; |
| 122 | 147 | $end_d = 53; |
| 123 | 148 | |
| 124 | -if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 125 | -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); |
|
| 149 | +if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) { |
|
| 150 | + $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 151 | +} |
|
| 152 | +if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) { |
|
| 153 | + $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); |
|
| 154 | +} |
|
| 126 | 155 | |
| 127 | 156 | if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { |
| 128 | 157 | $action='show_month'; $day=''; |
@@ -197,21 +226,47 @@ discard block |
||
| 197 | 226 | //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; |
| 198 | 227 | |
| 199 | 228 | $title=$langs->trans("DoneAndToDoActions"); |
| 200 | -if ($status == 'done') $title=$langs->trans("DoneActions"); |
|
| 201 | -if ($status == 'todo') $title=$langs->trans("ToDoActions"); |
|
| 229 | +if ($status == 'done') { |
|
| 230 | + $title=$langs->trans("DoneActions"); |
|
| 231 | +} |
|
| 232 | +if ($status == 'todo') { |
|
| 233 | + $title=$langs->trans("ToDoActions"); |
|
| 234 | +} |
|
| 202 | 235 | |
| 203 | 236 | $param=''; |
| 204 | -if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode; |
|
| 205 | -if ($resourceid > 0) $param.="&resourceid=".$resourceid; |
|
| 206 | -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status; |
|
| 207 | -if ($filter) $param.="&filter=".$filter; |
|
| 208 | -if ($filtert) $param.="&filtert=".$filtert; |
|
| 209 | -if ($usergroup) $param.="&usergroup=".$usergroup; |
|
| 210 | -if ($socid) $param.="&socid=".$socid; |
|
| 211 | -if ($showbirthday) $param.="&showbirthday=1"; |
|
| 212 | -if ($pid) $param.="&projectid=".$pid; |
|
| 213 | -if ($type) $param.="&type=".$type; |
|
| 214 | -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param.='&action='.$action; |
|
| 237 | +if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) { |
|
| 238 | + $param.="&actioncode=".$actioncode; |
|
| 239 | +} |
|
| 240 | +if ($resourceid > 0) { |
|
| 241 | + $param.="&resourceid=".$resourceid; |
|
| 242 | +} |
|
| 243 | +if ($status || isset($_GET['status']) || isset($_POST['status'])) { |
|
| 244 | + $param.="&status=".$status; |
|
| 245 | +} |
|
| 246 | +if ($filter) { |
|
| 247 | + $param.="&filter=".$filter; |
|
| 248 | +} |
|
| 249 | +if ($filtert) { |
|
| 250 | + $param.="&filtert=".$filtert; |
|
| 251 | +} |
|
| 252 | +if ($usergroup) { |
|
| 253 | + $param.="&usergroup=".$usergroup; |
|
| 254 | +} |
|
| 255 | +if ($socid) { |
|
| 256 | + $param.="&socid=".$socid; |
|
| 257 | +} |
|
| 258 | +if ($showbirthday) { |
|
| 259 | + $param.="&showbirthday=1"; |
|
| 260 | +} |
|
| 261 | +if ($pid) { |
|
| 262 | + $param.="&projectid=".$pid; |
|
| 263 | +} |
|
| 264 | +if ($type) { |
|
| 265 | + $param.="&type=".$type; |
|
| 266 | +} |
|
| 267 | +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') { |
|
| 268 | + $param.='&action='.$action; |
|
| 269 | +} |
|
| 215 | 270 | $param.="&maxprint=".$maxprint; |
| 216 | 271 | |
| 217 | 272 | $prev = dol_get_first_day($year, 1); |
@@ -329,8 +384,7 @@ discard block |
||
| 329 | 384 | if (empty($reshook)) |
| 330 | 385 | { |
| 331 | 386 | $s.= $hookmanager->resPrint; |
| 332 | - } |
|
| 333 | - elseif ($reshook > 1) |
|
| 387 | + } elseif ($reshook > 1) |
|
| 334 | 388 | { |
| 335 | 389 | $s = $hookmanager->resPrint; |
| 336 | 390 | } |
@@ -347,7 +401,9 @@ discard block |
||
| 347 | 401 | $eventarray=array(); |
| 348 | 402 | |
| 349 | 403 | $sql = 'SELECT'; |
| 350 | -if ($usergroup > 0) $sql.=" DISTINCT"; |
|
| 404 | +if ($usergroup > 0) { |
|
| 405 | + $sql.=" DISTINCT"; |
|
| 406 | +} |
|
| 351 | 407 | $sql.= ' a.id, a.label,'; |
| 352 | 408 | $sql.= ' a.datep,'; |
| 353 | 409 | $sql.= ' a.datep2,'; |
@@ -357,12 +413,20 @@ discard block |
||
| 357 | 413 | $sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; |
| 358 | 414 | $sql.= ' ca.code, ca.color'; |
| 359 | 415 | $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; |
| 360 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 416 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 417 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 418 | +} |
|
| 361 | 419 | // We must filter on resource table |
| 362 | -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 420 | +if ($resourceid > 0) { |
|
| 421 | + $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 422 | +} |
|
| 363 | 423 | // We must filter on assignement table |
| 364 | -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 365 | -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 424 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 425 | + $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 426 | +} |
|
| 427 | +if ($usergroup > 0) { |
|
| 428 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 429 | +} |
|
| 366 | 430 | $sql.= ' WHERE a.fk_action = ca.id'; |
| 367 | 431 | $sql.= ' AND a.entity IN ('.getEntity('agenda').')'; |
| 368 | 432 | // Condition on actioncode |
@@ -370,30 +434,47 @@ discard block |
||
| 370 | 434 | { |
| 371 | 435 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 372 | 436 | { |
| 373 | - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; |
|
| 374 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 375 | - else |
|
| 437 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 438 | + $sql.= " AND ca.type != 'systemauto'"; |
|
| 439 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 440 | + $sql.= " AND ca.type = 'systemauto'"; |
|
| 441 | + } else |
|
| 376 | 442 | { |
| 377 | - if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'"; |
|
| 378 | - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 443 | + if ($actioncode == 'AC_OTH') { |
|
| 444 | + $sql.= " AND ca.type != 'systemauto'"; |
|
| 445 | + } |
|
| 446 | + if ($actioncode == 'AC_OTH_AUTO') { |
|
| 447 | + $sql.= " AND ca.type = 'systemauto'"; |
|
| 448 | + } |
|
| 379 | 449 | } |
| 380 | - } |
|
| 381 | - else |
|
| 450 | + } else |
|
| 382 | 451 | { |
| 383 | - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; |
|
| 384 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 385 | - else |
|
| 452 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 453 | + $sql.= " AND ca.type != 'systemauto'"; |
|
| 454 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 455 | + $sql.= " AND ca.type = 'systemauto'"; |
|
| 456 | + } else |
|
| 386 | 457 | { |
| 387 | 458 | $sql.=" AND ca.code IN ('".implode("','", explode(',',$actioncode))."')"; |
| 388 | 459 | } |
| 389 | 460 | } |
| 390 | 461 | } |
| 391 | -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 392 | -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); |
|
| 393 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; |
|
| 394 | -if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; |
|
| 462 | +if ($resourceid > 0) { |
|
| 463 | + $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 464 | +} |
|
| 465 | +if ($pid) { |
|
| 466 | + $sql.=" AND a.fk_project=".$db->escape($pid); |
|
| 467 | +} |
|
| 468 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 469 | + $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; |
|
| 470 | +} |
|
| 471 | +if ($socid > 0) { |
|
| 472 | + $sql.= ' AND a.fk_soc = '.$socid; |
|
| 473 | +} |
|
| 395 | 474 | // We must filter on assignement table |
| 396 | -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 475 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 476 | + $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 477 | +} |
|
| 397 | 478 | if ($action == 'show_day') |
| 398 | 479 | { |
| 399 | 480 | $sql.= " AND ("; |
@@ -406,8 +487,7 @@ discard block |
||
| 406 | 487 | $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; |
| 407 | 488 | $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; |
| 408 | 489 | $sql.= ')'; |
| 409 | -} |
|
| 410 | -else |
|
| 490 | +} else |
|
| 411 | 491 | { |
| 412 | 492 | // To limit array |
| 413 | 493 | $sql.= " AND ("; |
@@ -421,7 +501,9 @@ discard block |
||
| 421 | 501 | $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,12,31,$year)+(60*60*24*7))."')"; |
| 422 | 502 | $sql.= ')'; |
| 423 | 503 | } |
| 424 | -if ($type) $sql.= " AND ca.id = ".$type; |
|
| 504 | +if ($type) { |
|
| 505 | + $sql.= " AND ca.id = ".$type; |
|
| 506 | +} |
|
| 425 | 507 | if ($status == '0') { $sql.= " AND a.percent = 0"; } |
| 426 | 508 | if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable |
| 427 | 509 | if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
@@ -431,8 +513,12 @@ discard block |
||
| 431 | 513 | if ($filtert > 0 || $usergroup > 0) |
| 432 | 514 | { |
| 433 | 515 | $sql.= " AND ("; |
| 434 | - if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; |
|
| 435 | - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; |
|
| 516 | + if ($filtert > 0) { |
|
| 517 | + $sql.= "ar.fk_element = ".$filtert; |
|
| 518 | + } |
|
| 519 | + if ($usergroup > 0) { |
|
| 520 | + $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; |
|
| 521 | + } |
|
| 436 | 522 | $sql.= ")"; |
| 437 | 523 | } |
| 438 | 524 | // Sort on date |
@@ -488,14 +574,19 @@ discard block |
||
| 488 | 574 | if ($event->percentage <= 0) |
| 489 | 575 | { |
| 490 | 576 | $event->date_start_in_calendar=$datep; |
| 491 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 492 | - else $event->date_end_in_calendar=$datep; |
|
| 493 | - } |
|
| 494 | - else |
|
| 577 | + if ($datep2 != '' && $datep2 >= $datep) { |
|
| 578 | + $event->date_end_in_calendar=$datep2; |
|
| 579 | + } else { |
|
| 580 | + $event->date_end_in_calendar=$datep; |
|
| 581 | + } |
|
| 582 | + } else |
|
| 495 | 583 | { |
| 496 | 584 | $event->date_start_in_calendar=$datep; |
| 497 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 498 | - else $event->date_end_in_calendar=$datep; |
|
| 585 | + if ($datep2 != '' && $datep2 >= $datep) { |
|
| 586 | + $event->date_end_in_calendar=$datep2; |
|
| 587 | + } else { |
|
| 588 | + $event->date_end_in_calendar=$datep; |
|
| 589 | + } |
|
| 499 | 590 | } |
| 500 | 591 | // Define ponctual property |
| 501 | 592 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) |
@@ -509,14 +600,17 @@ discard block |
||
| 509 | 600 | { |
| 510 | 601 | // This record is out of visible range |
| 511 | 602 | unset($event); |
| 512 | - } |
|
| 513 | - else |
|
| 603 | + } else |
|
| 514 | 604 | { |
| 515 | 605 | //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
| 516 | 606 | $event->fetch_userassigned(); // This load $event->userassigned |
| 517 | 607 | |
| 518 | - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; |
|
| 519 | - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); |
|
| 608 | + if ($event->date_start_in_calendar < $firstdaytoshow) { |
|
| 609 | + $event->date_start_in_calendar=$firstdaytoshow; |
|
| 610 | + } |
|
| 611 | + if ($event->date_end_in_calendar >= $lastdaytoshow) { |
|
| 612 | + $event->date_end_in_calendar=($lastdaytoshow - 1); |
|
| 613 | + } |
|
| 520 | 614 | |
| 521 | 615 | // Add an entry in actionarray for each day |
| 522 | 616 | $daycursor=$event->date_start_in_calendar; |
@@ -535,7 +629,9 @@ discard block |
||
| 535 | 629 | $j++; |
| 536 | 630 | |
| 537 | 631 | $daykey+=60*60*24; |
| 538 | - if ($daykey > $event->date_end_in_calendar) $loop=false; |
|
| 632 | + if ($daykey > $event->date_end_in_calendar) { |
|
| 633 | + $loop=false; |
|
| 634 | + } |
|
| 539 | 635 | } |
| 540 | 636 | while ($loop); |
| 541 | 637 | |
@@ -544,8 +640,7 @@ discard block |
||
| 544 | 640 | } |
| 545 | 641 | $i++; |
| 546 | 642 | } |
| 547 | -} |
|
| 548 | -else |
|
| 643 | +} else |
|
| 549 | 644 | { |
| 550 | 645 | dol_print_error($db); |
| 551 | 646 | } |
@@ -560,7 +655,9 @@ discard block |
||
| 560 | 655 | { |
| 561 | 656 | include_once $color_file; |
| 562 | 657 | } |
| 563 | -if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); |
|
| 658 | +if (! is_array($theme_datacolor)) { |
|
| 659 | + $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); |
|
| 660 | +} |
|
| 564 | 661 | |
| 565 | 662 | |
| 566 | 663 | $newparam=$param; // newparam is for birthday links |
@@ -654,10 +751,16 @@ discard block |
||
| 654 | 751 | $tmpyear = $tmparray['year']; |
| 655 | 752 | |
| 656 | 753 | $style='cal_current_month'; |
| 657 | - if ($iter_day == 6) $style.=' cal_other_month'; |
|
| 754 | + if ($iter_day == 6) { |
|
| 755 | + $style.=' cal_other_month'; |
|
| 756 | + } |
|
| 658 | 757 | $today=0; |
| 659 | - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; |
|
| 660 | - if ($today) $style='cal_today_peruser'; |
|
| 758 | + if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) { |
|
| 759 | + $today=1; |
|
| 760 | + } |
|
| 761 | + if ($today) { |
|
| 762 | + $style='cal_today_peruser'; |
|
| 763 | + } |
|
| 661 | 764 | |
| 662 | 765 | show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
| 663 | 766 | |
@@ -785,7 +888,8 @@ discard block |
||
| 785 | 888 | $jour = date('d',$daykey); |
| 786 | 889 | //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n"; |
| 787 | 890 | |
| 788 | - if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? |
|
| 891 | + if ($day==$jour && $month==$mois && $year==$annee) { |
|
| 892 | + // Is it the day we are looking for when calling function ? |
|
| 789 | 893 | { |
| 790 | 894 | // Scan all event for this date |
| 791 | 895 | foreach ($eventarray[$daykey] as $index => $event) |
@@ -793,12 +897,18 @@ discard block |
||
| 793 | 897 | //var_dump($event); |
| 794 | 898 | |
| 795 | 899 | $keysofuserassigned=array_keys($event->userassigned); |
| 796 | - if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 900 | + } |
|
| 901 | + if (! in_array($username->id,$keysofuserassigned)) { |
|
| 902 | + continue; |
|
| 903 | + } |
|
| 904 | + // We discard record if event is from another user than user we want to show |
|
| 797 | 905 | //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
| 798 | 906 | |
| 799 | 907 | $parameters=array(); |
| 800 | 908 | $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks |
| 801 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 909 | + if ($reshook < 0) { |
|
| 910 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 911 | + } |
|
| 802 | 912 | |
| 803 | 913 | $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); |
| 804 | 914 | |
@@ -807,9 +917,10 @@ discard block |
||
| 807 | 917 | if (in_array($user->id, $keysofuserassigned)) |
| 808 | 918 | { |
| 809 | 919 | $nummytasks++; $cssclass='family_mytasks'; |
| 810 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; |
|
| 811 | - } |
|
| 812 | - else if ($event->type_code == 'ICALEVENT') |
|
| 920 | + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
|
| 921 | + $color=$event->type_color; |
|
| 922 | + } |
|
| 923 | + } else if ($event->type_code == 'ICALEVENT') |
|
| 813 | 924 | { |
| 814 | 925 | $numical++; |
| 815 | 926 | if (! empty($event->icalname)) |
@@ -822,30 +933,34 @@ discard block |
||
| 822 | 933 | |
| 823 | 934 | $color=$event->icalcolor; |
| 824 | 935 | $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); |
| 825 | - } |
|
| 826 | - else if ($event->type_code == 'BIRTHDAY') |
|
| 936 | + } else if ($event->type_code == 'BIRTHDAY') |
|
| 827 | 937 | { |
| 828 | 938 | $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
| 829 | - } |
|
| 830 | - else |
|
| 939 | + } else |
|
| 831 | 940 | { |
| 832 | 941 | $numother++; $cssclass='family_other'; |
| 833 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; |
|
| 942 | + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
|
| 943 | + $color=$event->type_color; |
|
| 944 | + } |
|
| 834 | 945 | } |
| 835 | 946 | |
| 836 | - if ($color < 0) // Color was not forced. Set color according to color index. |
|
| 947 | + if ($color < 0) { |
|
| 948 | + // Color was not forced. Set color according to color index. |
|
| 837 | 949 | { |
| 838 | 950 | // Define color index if not yet defined |
| 839 | 951 | $idusertouse=($event->userownerid?$event->userownerid:0); |
| 952 | + } |
|
| 840 | 953 | if (isset($colorindexused[$idusertouse])) |
| 841 | 954 | { |
| 842 | 955 | $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user |
| 843 | - } |
|
| 844 | - else |
|
| 956 | + } else |
|
| 845 | 957 | { |
| 846 | 958 | $colorindex=$nextindextouse; |
| 847 | 959 | $colorindexused[$idusertouse]=$colorindex; |
| 848 | - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color |
|
| 960 | + if (! empty($theme_datacolor[$nextindextouse+1])) { |
|
| 961 | + $nextindextouse++; |
|
| 962 | + } |
|
| 963 | + // Prepare to use next color |
|
| 849 | 964 | } |
| 850 | 965 | // Define color |
| 851 | 966 | $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
@@ -864,7 +979,9 @@ discard block |
||
| 864 | 979 | $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); |
| 865 | 980 | |
| 866 | 981 | $dateendtouse=$event->date_end_in_calendar; |
| 867 | - if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; |
|
| 982 | + if ($dateendtouse==$event->date_start_in_calendar) { |
|
| 983 | + $dateendtouse++; |
|
| 984 | + } |
|
| 868 | 985 | |
| 869 | 986 | //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
| 870 | 987 | |
@@ -877,8 +994,11 @@ discard block |
||
| 877 | 994 | { |
| 878 | 995 | $tmpa=dol_getdate($event->date_start_in_calendar,true); |
| 879 | 996 | $tmpb=dol_getdate($event->date_end_in_calendar,true); |
| 880 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 881 | - else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 997 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
|
| 998 | + $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 999 | + } else { |
|
| 1000 | + $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1001 | + } |
|
| 882 | 1002 | } |
| 883 | 1003 | $cases1[$h][$event->id]['string'].=' - '.$event->label; |
| 884 | 1004 | $cases1[$h][$event->id]['typecode']=$event->type_code; |
@@ -923,8 +1043,11 @@ discard block |
||
| 923 | 1043 | { |
| 924 | 1044 | $tmpa=dol_getdate($event->date_start_in_calendar,true); |
| 925 | 1045 | $tmpb=dol_getdate($event->date_end_in_calendar,true); |
| 926 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 927 | - else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1046 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
|
| 1047 | + $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1048 | + } else { |
|
| 1049 | + $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1050 | + } |
|
| 928 | 1051 | } |
| 929 | 1052 | $cases2[$h][$event->id]['string'].=' - '.$event->label; |
| 930 | 1053 | $cases2[$h][$event->id]['typecode']=$event->type_code; |
@@ -960,8 +1083,7 @@ discard block |
||
| 960 | 1083 | $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
| 961 | 1084 | } |
| 962 | 1085 | } |
| 963 | - } |
|
| 964 | - else |
|
| 1086 | + } else |
|
| 965 | 1087 | { |
| 966 | 1088 | $busy=$event->transparency; |
| 967 | 1089 | $cases1[$h][$event->id]['busy']=$busy; |
@@ -991,55 +1113,86 @@ discard block |
||
| 991 | 1113 | if (isset($cases1[$h]) && $cases1[$h] != '') |
| 992 | 1114 | { |
| 993 | 1115 | //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 994 | - if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1116 | + if (count($cases1[$h]) > 1) { |
|
| 1117 | + $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1118 | + } |
|
| 995 | 1119 | $string1=' '; |
| 996 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; |
|
| 997 | - else $style1='peruser_busy'; |
|
| 1120 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { |
|
| 1121 | + $style1='peruser_notbusy'; |
|
| 1122 | + } else { |
|
| 1123 | + $style1='peruser_busy'; |
|
| 1124 | + } |
|
| 998 | 1125 | foreach($cases1[$h] as $id => $ev) |
| 999 | 1126 | { |
| 1000 | - if ($ev['busy']) $style1='peruser_busy'; |
|
| 1127 | + if ($ev['busy']) { |
|
| 1128 | + $style1='peruser_busy'; |
|
| 1129 | + } |
|
| 1001 | 1130 | } |
| 1002 | 1131 | } |
| 1003 | 1132 | if (isset($cases2[$h]) && $cases2[$h] != '') |
| 1004 | 1133 | { |
| 1005 | 1134 | //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1006 | - if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1135 | + if (count($cases2[$h]) > 1) { |
|
| 1136 | + $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1137 | + } |
|
| 1007 | 1138 | $string2=' '; |
| 1008 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; |
|
| 1009 | - else $style2='peruser_busy'; |
|
| 1139 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { |
|
| 1140 | + $style2='peruser_notbusy'; |
|
| 1141 | + } else { |
|
| 1142 | + $style2='peruser_busy'; |
|
| 1143 | + } |
|
| 1010 | 1144 | foreach($cases2[$h] as $id => $ev) |
| 1011 | 1145 | { |
| 1012 | - if ($ev['busy']) $style2='peruser_busy'; |
|
| 1146 | + if ($ev['busy']) { |
|
| 1147 | + $style2='peruser_busy'; |
|
| 1148 | + } |
|
| 1013 | 1149 | } |
| 1014 | 1150 | } |
| 1015 | 1151 | |
| 1016 | 1152 | $ids1='';$ids2=''; |
| 1017 | - if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h])); |
|
| 1018 | - if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h])); |
|
| 1153 | + if (count($cases1[$h]) && array_keys($cases1[$h])) { |
|
| 1154 | + $ids1=join(',',array_keys($cases1[$h])); |
|
| 1155 | + } |
|
| 1156 | + if (count($cases2[$h]) && array_keys($cases2[$h])) { |
|
| 1157 | + $ids2=join(',',array_keys($cases2[$h])); |
|
| 1158 | + } |
|
| 1019 | 1159 | |
| 1020 | - if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1021 | - else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1022 | - if (count($cases1[$h]) == 1) // only 1 event |
|
| 1160 | + if ($h == $begin_h) { |
|
| 1161 | + echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1162 | + } else { |
|
| 1163 | + echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1164 | + } |
|
| 1165 | + if (count($cases1[$h]) == 1) { |
|
| 1166 | + // only 1 event |
|
| 1023 | 1167 | { |
| 1024 | 1168 | $output = array_slice($cases1[$h], 0, 1); |
| 1025 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1026 | - if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1027 | - if ($output[0]['color']) $color1 = $output[0]['color']; |
|
| 1028 | 1169 | } |
| 1029 | - else if (count($cases1[$h]) > 1) |
|
| 1170 | + $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1171 | + if ($output[0]['string']) { |
|
| 1172 | + $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1173 | + } |
|
| 1174 | + if ($output[0]['color']) { |
|
| 1175 | + $color1 = $output[0]['color']; |
|
| 1176 | + } |
|
| 1177 | + } else if (count($cases1[$h]) > 1) |
|
| 1030 | 1178 | { |
| 1031 | 1179 | $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
| 1032 | 1180 | $color1='222222'; |
| 1033 | 1181 | } |
| 1034 | 1182 | |
| 1035 | - if (count($cases2[$h]) == 1) // only 1 event |
|
| 1183 | + if (count($cases2[$h]) == 1) { |
|
| 1184 | + // only 1 event |
|
| 1036 | 1185 | { |
| 1037 | 1186 | $output = array_slice($cases2[$h], 0, 1); |
| 1038 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1039 | - if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1040 | - if ($output[0]['color']) $color2 = $output[0]['color']; |
|
| 1041 | 1187 | } |
| 1042 | - else if (count($cases2[$h]) > 1) |
|
| 1188 | + $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1189 | + if ($output[0]['string']) { |
|
| 1190 | + $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1191 | + } |
|
| 1192 | + if ($output[0]['color']) { |
|
| 1193 | + $color2 = $output[0]['color']; |
|
| 1194 | + } |
|
| 1195 | + } else if (count($cases2[$h]) > 1) |
|
| 1043 | 1196 | { |
| 1044 | 1197 | $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
| 1045 | 1198 | $color2='222222'; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 33 | 33 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 34 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 34 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 35 | 35 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
| 36 | 36 | require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 37 | 37 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 43 | 43 | |
| 44 | 44 | |
| 45 | -if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; |
|
| 45 | +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; |
|
| 46 | 46 | |
| 47 | -$filter = GETPOST("filter",'alpha',3); |
|
| 48 | -$filtert = GETPOST("filtert","int",3); |
|
| 49 | -$usergroup = GETPOST("usergroup","int",3); |
|
| 47 | +$filter = GETPOST("filter", 'alpha', 3); |
|
| 48 | +$filtert = GETPOST("filtert", "int", 3); |
|
| 49 | +$usergroup = GETPOST("usergroup", "int", 3); |
|
| 50 | 50 | //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; |
| 51 | 51 | //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; |
| 52 | 52 | $showbirthday = 0; |
@@ -54,90 +54,90 @@ discard block |
||
| 54 | 54 | // If not choice done on calendar owner, we filter on user. |
| 55 | 55 | if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) |
| 56 | 56 | { |
| 57 | - $filtert=$user->id; |
|
| 57 | + $filtert = $user->id; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
| 61 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
| 62 | -$page = GETPOST("page","int"); |
|
| 60 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
| 61 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
| 62 | +$page = GETPOST("page", "int"); |
|
| 63 | 63 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 64 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 64 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 65 | 65 | $offset = $limit * $page; |
| 66 | -if (! $sortorder) $sortorder="ASC"; |
|
| 67 | -if (! $sortfield) $sortfield="a.datec"; |
|
| 66 | +if (!$sortorder) $sortorder = "ASC"; |
|
| 67 | +if (!$sortfield) $sortfield = "a.datec"; |
|
| 68 | 68 | |
| 69 | 69 | // Security check |
| 70 | -$socid = GETPOST("socid","int"); |
|
| 71 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 70 | +$socid = GETPOST("socid", "int"); |
|
| 71 | +if ($user->societe_id) $socid = $user->societe_id; |
|
| 72 | 72 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
| 73 | -if ($socid < 0) $socid=''; |
|
| 73 | +if ($socid < 0) $socid = ''; |
|
| 74 | 74 | |
| 75 | -$canedit=1; |
|
| 76 | -if (! $user->rights->agenda->myactions->read) accessforbidden(); |
|
| 77 | -if (! $user->rights->agenda->allactions->read) $canedit=0; |
|
| 78 | -if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me |
|
| 75 | +$canedit = 1; |
|
| 76 | +if (!$user->rights->agenda->myactions->read) accessforbidden(); |
|
| 77 | +if (!$user->rights->agenda->allactions->read) $canedit = 0; |
|
| 78 | +if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me |
|
| 79 | 79 | { |
| 80 | - $filtert=$user->id; |
|
| 80 | + $filtert = $user->id; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | //$action=GETPOST('action','alpha'); |
| 84 | -$action='show_pertype'; |
|
| 85 | -$resourceid=GETPOST("resourceid","int"); |
|
| 86 | -$year=GETPOST("year","int")?GETPOST("year","int"):date("Y"); |
|
| 87 | -$month=GETPOST("month","int")?GETPOST("month","int"):date("m"); |
|
| 88 | -$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); |
|
| 89 | -$day=GETPOST("day","int")?GETPOST("day","int"):date("d"); |
|
| 90 | -$pid=GETPOST("projectid","int",3); |
|
| 91 | -$status=GETPOST("status",'alpha'); |
|
| 92 | -$type=GETPOST("type",'alpha'); |
|
| 93 | -$maxprint=((GETPOST("maxprint",'int')!='')?GETPOST("maxprint",'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); |
|
| 84 | +$action = 'show_pertype'; |
|
| 85 | +$resourceid = GETPOST("resourceid", "int"); |
|
| 86 | +$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); |
|
| 87 | +$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); |
|
| 88 | +$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); |
|
| 89 | +$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); |
|
| 90 | +$pid = GETPOST("projectid", "int", 3); |
|
| 91 | +$status = GETPOST("status", 'alpha'); |
|
| 92 | +$type = GETPOST("type", 'alpha'); |
|
| 93 | +$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); |
|
| 94 | 94 | // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) |
| 95 | -if (GETPOST('actioncode','array')) |
|
| 95 | +if (GETPOST('actioncode', 'array')) |
|
| 96 | 96 | { |
| 97 | - $actioncode=GETPOST('actioncode','array',3); |
|
| 98 | - if (! count($actioncode)) $actioncode='0'; |
|
| 97 | + $actioncode = GETPOST('actioncode', 'array', 3); |
|
| 98 | + if (!count($actioncode)) $actioncode = '0'; |
|
| 99 | 99 | } |
| 100 | 100 | else |
| 101 | 101 | { |
| 102 | - $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
|
| 102 | + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
|
| 103 | 103 | } |
| 104 | -if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 104 | +if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 105 | 105 | |
| 106 | -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); |
|
| 106 | +$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); |
|
| 107 | 107 | if ($dateselect > 0) |
| 108 | 108 | { |
| 109 | - $day=GETPOST('dateselectday','int'); |
|
| 110 | - $month=GETPOST('dateselectmonth','int'); |
|
| 111 | - $year=GETPOST('dateselectyear','int'); |
|
| 109 | + $day = GETPOST('dateselectday', 'int'); |
|
| 110 | + $month = GETPOST('dateselectmonth', 'int'); |
|
| 111 | + $year = GETPOST('dateselectyear', 'int'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; |
|
| 115 | -$tmparray=explode('-',$tmp); |
|
| 116 | -$begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); |
|
| 117 | -$end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18); |
|
| 114 | +$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; |
|
| 115 | +$tmparray = explode('-', $tmp); |
|
| 116 | +$begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); |
|
| 117 | +$end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); |
|
| 118 | 118 | if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; |
| 119 | 119 | if ($end_h < 1 || $end_h > 24) $end_h = 18; |
| 120 | 120 | if ($end_h <= $begin_h) $end_h = $begin_h + 1; |
| 121 | 121 | |
| 122 | -$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS; |
|
| 123 | -$tmparray=explode('-',$tmp); |
|
| 122 | +$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; |
|
| 123 | +$tmparray = explode('-', $tmp); |
|
| 124 | 124 | $begin_d = 1; |
| 125 | 125 | $end_d = 53; |
| 126 | 126 | |
| 127 | -if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 128 | -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); |
|
| 127 | +if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 128 | +if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
|
| 129 | 129 | |
| 130 | -if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { |
|
| 131 | - $action='show_month'; $day=''; |
|
| 130 | +if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { |
|
| 131 | + $action = 'show_month'; $day = ''; |
|
| 132 | 132 | } // View by month |
| 133 | -if (GETPOST('viewweek','alpha') || $action == 'show_week') { |
|
| 134 | - $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d")); |
|
| 133 | +if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { |
|
| 134 | + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); |
|
| 135 | 135 | } // View by week |
| 136 | -if (GETPOST('viewday','alpha') || $action == 'show_day') { |
|
| 137 | - $action='show_day'; $day=($day?$day:date("d")); |
|
| 136 | +if (GETPOST('viewday', 'alpha') || $action == 'show_day') { |
|
| 137 | + $action = 'show_day'; $day = ($day ? $day : date("d")); |
|
| 138 | 138 | } // View by day |
| 139 | -if (GETPOST('viewyear','alpha') || $action == 'show_year') { |
|
| 140 | - $action='show_year'; |
|
| 139 | +if (GETPOST('viewyear', 'alpha') || $action == 'show_year') { |
|
| 140 | + $action = 'show_year'; |
|
| 141 | 141 | } // View by year |
| 142 | 142 | |
| 143 | 143 | // Load translation files required by the page |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | * Actions |
| 152 | 152 | */ |
| 153 | 153 | |
| 154 | -if ($action =='delete_action') |
|
| 154 | +if ($action == 'delete_action') |
|
| 155 | 155 | { |
| 156 | 156 | $event = new ActionComm($db); |
| 157 | 157 | $event->fetch($actionid); |
| 158 | - $result=$event->delete(); |
|
| 158 | + $result = $event->delete(); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -164,21 +164,21 @@ discard block |
||
| 164 | 164 | * View |
| 165 | 165 | */ |
| 166 | 166 | |
| 167 | -$form=new Form($db); |
|
| 168 | -$companystatic=new Societe($db); |
|
| 167 | +$form = new Form($db); |
|
| 168 | +$companystatic = new Societe($db); |
|
| 169 | 169 | |
| 170 | -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; |
|
| 171 | -llxHeader('',$langs->trans("Agenda"),$help_url); |
|
| 170 | +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; |
|
| 171 | +llxHeader('', $langs->trans("Agenda"), $help_url); |
|
| 172 | 172 | |
| 173 | -$now=dol_now(); |
|
| 174 | -$nowarray=dol_getdate($now); |
|
| 175 | -$nowyear=$nowarray['year']; |
|
| 176 | -$nowmonth=$nowarray['mon']; |
|
| 177 | -$nowday=$nowarray['mday']; |
|
| 173 | +$now = dol_now(); |
|
| 174 | +$nowarray = dol_getdate($now); |
|
| 175 | +$nowyear = $nowarray['year']; |
|
| 176 | +$nowmonth = $nowarray['mon']; |
|
| 177 | +$nowday = $nowarray['mday']; |
|
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | // Define list of all external calendars (global setup) |
| 181 | -$listofextcals=array(); |
|
| 181 | +$listofextcals = array(); |
|
| 182 | 182 | |
| 183 | 183 | $prev = dol_get_first_day($year, $month); |
| 184 | 184 | $first_day = 1; |
@@ -193,36 +193,36 @@ discard block |
||
| 193 | 193 | $next_month = $month; |
| 194 | 194 | $next_day = $day; |
| 195 | 195 | |
| 196 | -$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); |
|
| 196 | +$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); |
|
| 197 | 197 | |
| 198 | 198 | $tmpday = $first_day; |
| 199 | 199 | //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; |
| 200 | 200 | //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; |
| 201 | 201 | |
| 202 | -$title=$langs->trans("DoneAndToDoActions"); |
|
| 203 | -if ($status == 'done') $title=$langs->trans("DoneActions"); |
|
| 204 | -if ($status == 'todo') $title=$langs->trans("ToDoActions"); |
|
| 205 | - |
|
| 206 | -$param=''; |
|
| 207 | -if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode; |
|
| 208 | -if ($resourceid > 0) $param.="&resourceid=".$resourceid; |
|
| 209 | -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status; |
|
| 210 | -if ($filter) $param.="&filter=".$filter; |
|
| 211 | -if ($filtert) $param.="&filtert=".$filtert; |
|
| 212 | -if ($usergroup) $param.="&usergroup=".$usergroup; |
|
| 213 | -if ($socid) $param.="&socid=".$socid; |
|
| 214 | -if ($showbirthday) $param.="&showbirthday=1"; |
|
| 215 | -if ($pid) $param.="&projectid=".$pid; |
|
| 216 | -if ($type) $param.="&type=".$type; |
|
| 217 | -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param.='&action='.$action; |
|
| 218 | -$param.="&maxprint=".$maxprint; |
|
| 202 | +$title = $langs->trans("DoneAndToDoActions"); |
|
| 203 | +if ($status == 'done') $title = $langs->trans("DoneActions"); |
|
| 204 | +if ($status == 'todo') $title = $langs->trans("ToDoActions"); |
|
| 205 | + |
|
| 206 | +$param = ''; |
|
| 207 | +if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param .= "&actioncode=".$actioncode; |
|
| 208 | +if ($resourceid > 0) $param .= "&resourceid=".$resourceid; |
|
| 209 | +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&status=".$status; |
|
| 210 | +if ($filter) $param .= "&filter=".$filter; |
|
| 211 | +if ($filtert) $param .= "&filtert=".$filtert; |
|
| 212 | +if ($usergroup) $param .= "&usergroup=".$usergroup; |
|
| 213 | +if ($socid) $param .= "&socid=".$socid; |
|
| 214 | +if ($showbirthday) $param .= "&showbirthday=1"; |
|
| 215 | +if ($pid) $param .= "&projectid=".$pid; |
|
| 216 | +if ($type) $param .= "&type=".$type; |
|
| 217 | +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param .= '&action='.$action; |
|
| 218 | +$param .= "&maxprint=".$maxprint; |
|
| 219 | 219 | |
| 220 | 220 | $prev = dol_get_first_day($year, 1); |
| 221 | 221 | $prev_year = $year - 1; |
| 222 | 222 | $prev_month = $month; |
| 223 | 223 | $prev_day = $day; |
| 224 | 224 | $first_day = 1; |
| 225 | -$first_month= 1; |
|
| 225 | +$first_month = 1; |
|
| 226 | 226 | $first_year = $year; |
| 227 | 227 | |
| 228 | 228 | $week = $prev['week']; |
@@ -234,52 +234,52 @@ discard block |
||
| 234 | 234 | $next_day = $day; |
| 235 | 235 | |
| 236 | 236 | // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) |
| 237 | -$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); |
|
| 238 | -$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); |
|
| 237 | +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); |
|
| 238 | +$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); |
|
| 239 | 239 | //print $firstday.'-'.$first_month.'-'.$first_year; |
| 240 | 240 | //print dol_print_date($firstdaytoshow,'dayhour'); |
| 241 | 241 | //print dol_print_date($lastdaytoshow,'dayhour'); |
| 242 | 242 | |
| 243 | -$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); |
|
| 243 | +$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); |
|
| 244 | 244 | |
| 245 | 245 | $tmpday = $first_day; |
| 246 | 246 | |
| 247 | -$nav ="<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n"; |
|
| 248 | -$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y")."</span> \n"; |
|
| 249 | -$nav.="<a href=\"?year=".$next_year."&month=".$next_month."&day=".$next_day.$param."\">".img_next($langs->trans("Next"))."</a>\n"; |
|
| 250 | -$nav.=" (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)"; |
|
| 251 | -$picto='calendarweek'; |
|
| 252 | - |
|
| 253 | -$nav.=' <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">'; |
|
| 254 | -$nav.='<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
| 255 | -$nav.='<input type="hidden" name="action" value="' . $action . '">'; |
|
| 256 | -$nav.='<input type="hidden" name="filtert" value="' . $filtert . '">'; |
|
| 257 | -$nav.='<input type="hidden" name="usergroup" value="' . $usergroup . '">'; |
|
| 258 | -$nav.='<input type="hidden" name="actioncode" value="' . $actioncode . '">'; |
|
| 259 | -$nav.='<input type="hidden" name="resourceid" value="' . $resourceid . '">'; |
|
| 260 | -$nav.='<input type="hidden" name="status" value="' . $status . '">'; |
|
| 261 | -$nav.='<input type="hidden" name="socid" value="' . $socid . '">'; |
|
| 262 | -$nav.='<input type="hidden" name="projectid" value="' . $projectid . '">'; |
|
| 263 | -$nav.='<input type="hidden" name="begin_h" value="' . $begin_h . '">'; |
|
| 264 | -$nav.='<input type="hidden" name="end_h" value="' . $end_h . '">'; |
|
| 265 | -$nav.='<input type="hidden" name="begin_d" value="' . $begin_d . '">'; |
|
| 266 | -$nav.='<input type="hidden" name="end_d" value="' . $end_d . '">'; |
|
| 267 | -$nav.='<input type="hidden" name="showbirthday" value="' . $showbirthday . '">'; |
|
| 268 | - |
|
| 269 | -$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); |
|
| 270 | -$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">'; |
|
| 271 | -$nav.='</form>'; |
|
| 247 | +$nav = "<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n"; |
|
| 248 | +$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y")."</span> \n"; |
|
| 249 | +$nav .= "<a href=\"?year=".$next_year."&month=".$next_month."&day=".$next_day.$param."\">".img_next($langs->trans("Next"))."</a>\n"; |
|
| 250 | +$nav .= " (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)"; |
|
| 251 | +$picto = 'calendarweek'; |
|
| 252 | + |
|
| 253 | +$nav .= ' <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">'; |
|
| 254 | +$nav .= '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; |
|
| 255 | +$nav .= '<input type="hidden" name="action" value="'.$action.'">'; |
|
| 256 | +$nav .= '<input type="hidden" name="filtert" value="'.$filtert.'">'; |
|
| 257 | +$nav .= '<input type="hidden" name="usergroup" value="'.$usergroup.'">'; |
|
| 258 | +$nav .= '<input type="hidden" name="actioncode" value="'.$actioncode.'">'; |
|
| 259 | +$nav .= '<input type="hidden" name="resourceid" value="'.$resourceid.'">'; |
|
| 260 | +$nav .= '<input type="hidden" name="status" value="'.$status.'">'; |
|
| 261 | +$nav .= '<input type="hidden" name="socid" value="'.$socid.'">'; |
|
| 262 | +$nav .= '<input type="hidden" name="projectid" value="'.$projectid.'">'; |
|
| 263 | +$nav .= '<input type="hidden" name="begin_h" value="'.$begin_h.'">'; |
|
| 264 | +$nav .= '<input type="hidden" name="end_h" value="'.$end_h.'">'; |
|
| 265 | +$nav .= '<input type="hidden" name="begin_d" value="'.$begin_d.'">'; |
|
| 266 | +$nav .= '<input type="hidden" name="end_d" value="'.$end_d.'">'; |
|
| 267 | +$nav .= '<input type="hidden" name="showbirthday" value="'.$showbirthday.'">'; |
|
| 268 | + |
|
| 269 | +$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); |
|
| 270 | +$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">'; |
|
| 271 | +$nav .= '</form>'; |
|
| 272 | 272 | |
| 273 | 273 | // Must be after the nav definition |
| 274 | -$param.='&year='.$year.'&month='.$month.($day?'&day='.$day:''); |
|
| 274 | +$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); |
|
| 275 | 275 | //print 'x'.$param; |
| 276 | 276 | |
| 277 | 277 | |
| 278 | 278 | |
| 279 | 279 | |
| 280 | -$tabactive='cardpertype'; |
|
| 280 | +$tabactive = 'cardpertype'; |
|
| 281 | 281 | |
| 282 | -$paramnoaction=preg_replace('/action=[a-z_]+/','',$param); |
|
| 282 | +$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); |
|
| 283 | 283 | |
| 284 | 284 | $head = calendars_prepare_head($paramnoaction); |
| 285 | 285 | |
@@ -287,51 +287,51 @@ discard block |
||
| 287 | 287 | print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); |
| 288 | 288 | dol_fiche_end(); |
| 289 | 289 | |
| 290 | -$showextcals=$listofextcals; |
|
| 290 | +$showextcals = $listofextcals; |
|
| 291 | 291 | // Legend |
| 292 | 292 | if ($conf->use_javascript_ajax) |
| 293 | 293 | { |
| 294 | - $s=''; |
|
| 295 | - $s.='<script type="text/javascript">' . "\n"; |
|
| 296 | - $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 297 | - $s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n"; |
|
| 298 | - $s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n"; |
|
| 299 | - $s.='jQuery(".family_birthday").toggle();' . "\n"; |
|
| 300 | - if ($action=="show_week" || $action=="show_month" || empty($action)) |
|
| 294 | + $s = ''; |
|
| 295 | + $s .= '<script type="text/javascript">'."\n"; |
|
| 296 | + $s .= 'jQuery(document).ready(function () {'."\n"; |
|
| 297 | + $s .= 'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'."\n"; |
|
| 298 | + $s .= 'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'."\n"; |
|
| 299 | + $s .= 'jQuery(".family_birthday").toggle();'."\n"; |
|
| 300 | + if ($action == "show_week" || $action == "show_month" || empty($action)) |
|
| 301 | 301 | { |
| 302 | - $s.='jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; |
|
| 303 | - $s.='var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; |
|
| 302 | + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; |
|
| 303 | + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; |
|
| 304 | 304 | } |
| 305 | - $s.='});' . "\n"; |
|
| 306 | - $s.='</script>' . "\n"; |
|
| 307 | - if (! empty($conf->use_javascript_ajax)) |
|
| 305 | + $s .= '});'."\n"; |
|
| 306 | + $s .= '</script>'."\n"; |
|
| 307 | + if (!empty($conf->use_javascript_ajax)) |
|
| 308 | 308 | { |
| 309 | - $s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>'; |
|
| 309 | + $s .= '<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' </div>'; |
|
| 310 | 310 | if (is_array($showextcals) && count($showextcals) > 0) |
| 311 | 311 | { |
| 312 | 312 | foreach ($showextcals as $val) |
| 313 | 313 | { |
| 314 | 314 | $htmlname = md5($val['name']); |
| 315 | - $s.='<script type="text/javascript">' . "\n"; |
|
| 316 | - $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 317 | - $s.=' jQuery("#check_ext' . $htmlname . '").click(function() {'; |
|
| 318 | - $s.=' /* alert("'.$htmlname.'"); */'; |
|
| 319 | - $s.=' jQuery(".family_ext' . $htmlname . '").toggle();'; |
|
| 320 | - $s.=' });' . "\n"; |
|
| 321 | - $s.='});' . "\n"; |
|
| 322 | - $s.='</script>' . "\n"; |
|
| 323 | - $s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val ['name'] . ' </div>'; |
|
| 315 | + $s .= '<script type="text/javascript">'."\n"; |
|
| 316 | + $s .= 'jQuery(document).ready(function () {'."\n"; |
|
| 317 | + $s .= ' jQuery("#check_ext'.$htmlname.'").click(function() {'; |
|
| 318 | + $s .= ' /* alert("'.$htmlname.'"); */'; |
|
| 319 | + $s .= ' jQuery(".family_ext'.$htmlname.'").toggle();'; |
|
| 320 | + $s .= ' });'."\n"; |
|
| 321 | + $s .= '});'."\n"; |
|
| 322 | + $s .= '</script>'."\n"; |
|
| 323 | + $s .= '<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.'" name="check_ext'.$htmlname.'" checked> '.$val ['name'].' </div>'; |
|
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>'; |
| 328 | 328 | |
| 329 | 329 | // Calendars from hooks |
| 330 | - $parameters=array(); $object=null; |
|
| 331 | - $reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action); |
|
| 330 | + $parameters = array(); $object = null; |
|
| 331 | + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); |
|
| 332 | 332 | if (empty($reshook)) |
| 333 | 333 | { |
| 334 | - $s.= $hookmanager->resPrint; |
|
| 334 | + $s .= $hookmanager->resPrint; |
|
| 335 | 335 | } |
| 336 | 336 | elseif ($reshook > 1) |
| 337 | 337 | { |
@@ -342,168 +342,168 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | |
| 344 | 344 | |
| 345 | -$link=''; |
|
| 345 | +$link = ''; |
|
| 346 | 346 | print load_fiche_titre($s, $link.' '.$nav, ''); |
| 347 | 347 | |
| 348 | 348 | |
| 349 | 349 | // Get event in an array |
| 350 | -$eventarray=array(); |
|
| 350 | +$eventarray = array(); |
|
| 351 | 351 | |
| 352 | 352 | $sql = 'SELECT'; |
| 353 | -if ($usergroup > 0) $sql.=" DISTINCT"; |
|
| 354 | -$sql.= ' a.id, a.label,'; |
|
| 355 | -$sql.= ' a.datep,'; |
|
| 356 | -$sql.= ' a.datep2,'; |
|
| 357 | -$sql.= ' a.percent,'; |
|
| 358 | -$sql.= ' a.fk_user_author,a.fk_user_action,'; |
|
| 359 | -$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; |
|
| 360 | -$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; |
|
| 361 | -$sql.= ' ca.code, ca.color'; |
|
| 362 | -$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; |
|
| 363 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 353 | +if ($usergroup > 0) $sql .= " DISTINCT"; |
|
| 354 | +$sql .= ' a.id, a.label,'; |
|
| 355 | +$sql .= ' a.datep,'; |
|
| 356 | +$sql .= ' a.datep2,'; |
|
| 357 | +$sql .= ' a.percent,'; |
|
| 358 | +$sql .= ' a.fk_user_author,a.fk_user_action,'; |
|
| 359 | +$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,'; |
|
| 360 | +$sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; |
|
| 361 | +$sql .= ' ca.code, ca.color'; |
|
| 362 | +$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; |
|
| 363 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 364 | 364 | // We must filter on resource table |
| 365 | -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 365 | +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 366 | 366 | // We must filter on assignement table |
| 367 | -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 368 | -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 369 | -$sql.= ' WHERE a.fk_action = ca.id'; |
|
| 370 | -$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; |
|
| 367 | +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 368 | +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 369 | +$sql .= ' WHERE a.fk_action = ca.id'; |
|
| 370 | +$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; |
|
| 371 | 371 | // Condition on actioncode |
| 372 | -if (! empty($actioncode)) |
|
| 372 | +if (!empty($actioncode)) |
|
| 373 | 373 | { |
| 374 | 374 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 375 | 375 | { |
| 376 | - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; |
|
| 377 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 376 | + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; |
|
| 377 | + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 378 | 378 | else |
| 379 | 379 | { |
| 380 | - if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'"; |
|
| 381 | - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 380 | + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; |
|
| 381 | + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | else |
| 385 | 385 | { |
| 386 | - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; |
|
| 387 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 386 | + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; |
|
| 387 | + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 388 | 388 | else |
| 389 | 389 | { |
| 390 | - $sql.=" AND ca.code IN ('".implode("','", explode(',',$actioncode))."')"; |
|
| 390 | + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 395 | -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); |
|
| 396 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; |
|
| 397 | -if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; |
|
| 394 | +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 395 | +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); |
|
| 396 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 397 | +if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; |
|
| 398 | 398 | // We must filter on assignement table |
| 399 | -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 399 | +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 400 | 400 | if ($action == 'show_day') |
| 401 | 401 | { |
| 402 | - $sql.= " AND ("; |
|
| 403 | - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; |
|
| 404 | - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; |
|
| 405 | - $sql.= " OR "; |
|
| 406 | - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; |
|
| 407 | - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; |
|
| 408 | - $sql.= " OR "; |
|
| 409 | - $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; |
|
| 410 | - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; |
|
| 411 | - $sql.= ')'; |
|
| 402 | + $sql .= " AND ("; |
|
| 403 | + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; |
|
| 404 | + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; |
|
| 405 | + $sql .= " OR "; |
|
| 406 | + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; |
|
| 407 | + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; |
|
| 408 | + $sql .= " OR "; |
|
| 409 | + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; |
|
| 410 | + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; |
|
| 411 | + $sql .= ')'; |
|
| 412 | 412 | } |
| 413 | 413 | else |
| 414 | 414 | { |
| 415 | 415 | // To limit array |
| 416 | - $sql.= " AND ("; |
|
| 417 | - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,1,1,$year)-(60*60*24*7))."'"; // Start 7 days before |
|
| 418 | - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,12,31,$year)+(60*60*24*7))."')"; // End 7 days after |
|
| 419 | - $sql.= " OR "; |
|
| 420 | - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,1,1,$year)-(60*60*24*7))."'"; |
|
| 421 | - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,12,31,$year)+(60*60*24*7))."')"; |
|
| 422 | - $sql.= " OR "; |
|
| 423 | - $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,12,1,$year)-(60*60*24*7))."'"; |
|
| 424 | - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,12,31,$year)+(60*60*24*7))."')"; |
|
| 425 | - $sql.= ')'; |
|
| 416 | + $sql .= " AND ("; |
|
| 417 | + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before |
|
| 418 | + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after |
|
| 419 | + $sql .= " OR "; |
|
| 420 | + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; |
|
| 421 | + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; |
|
| 422 | + $sql .= " OR "; |
|
| 423 | + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; |
|
| 424 | + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; |
|
| 425 | + $sql .= ')'; |
|
| 426 | 426 | } |
| 427 | -if ($type) $sql.= " AND ca.id = ".$type; |
|
| 428 | -if ($status == '0') { $sql.= " AND a.percent = 0"; } |
|
| 429 | -if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable |
|
| 430 | -if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
|
| 431 | -if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100)"; } |
|
| 432 | -if ($status == 'todo') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } |
|
| 427 | +if ($type) $sql .= " AND ca.id = ".$type; |
|
| 428 | +if ($status == '0') { $sql .= " AND a.percent = 0"; } |
|
| 429 | +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable |
|
| 430 | +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
|
| 431 | +if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } |
|
| 432 | +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } |
|
| 433 | 433 | // We must filter on assignement table |
| 434 | 434 | if ($filtert > 0 || $usergroup > 0) |
| 435 | 435 | { |
| 436 | - $sql.= " AND ("; |
|
| 437 | - if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; |
|
| 438 | - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; |
|
| 439 | - $sql.= ")"; |
|
| 436 | + $sql .= " AND ("; |
|
| 437 | + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; |
|
| 438 | + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; |
|
| 439 | + $sql .= ")"; |
|
| 440 | 440 | } |
| 441 | 441 | // Sort on date |
| 442 | -$sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action |
|
| 442 | +$sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action |
|
| 443 | 443 | //print $sql; |
| 444 | 444 | |
| 445 | 445 | dol_syslog("comm/action/index.php", LOG_DEBUG); |
| 446 | -$resql=$db->query($sql); |
|
| 446 | +$resql = $db->query($sql); |
|
| 447 | 447 | if ($resql) |
| 448 | 448 | { |
| 449 | 449 | $num = $db->num_rows($resql); |
| 450 | - $i=0; |
|
| 450 | + $i = 0; |
|
| 451 | 451 | while ($i < $num) |
| 452 | 452 | { |
| 453 | 453 | $obj = $db->fetch_object($resql); |
| 454 | 454 | |
| 455 | 455 | // Discard auto action if option is on |
| 456 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') |
|
| 456 | + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') |
|
| 457 | 457 | { |
| 458 | 458 | $i++; |
| 459 | 459 | continue; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - $datep=$db->jdate($obj->datep); |
|
| 463 | - $datep2=$db->jdate($obj->datep2); |
|
| 462 | + $datep = $db->jdate($obj->datep); |
|
| 463 | + $datep2 = $db->jdate($obj->datep2); |
|
| 464 | 464 | |
| 465 | 465 | // Create a new object action |
| 466 | - $event=new ActionComm($db); |
|
| 467 | - $event->id=$obj->id; |
|
| 468 | - $event->datep=$datep; // datep and datef are GMT date |
|
| 469 | - $event->datef=$datep2; |
|
| 470 | - $event->type_code=$obj->code; |
|
| 471 | - $event->type_color=$obj->color; |
|
| 472 | - $event->label=$obj->label; |
|
| 473 | - $event->percentage=$obj->percent; |
|
| 474 | - $event->authorid=$obj->fk_user_author; // user id of creator |
|
| 475 | - $event->userownerid=$obj->fk_user_action; // user id of owner |
|
| 476 | - $event->priority=$obj->priority; |
|
| 477 | - $event->fulldayevent=$obj->fulldayevent; |
|
| 478 | - $event->location=$obj->location; |
|
| 479 | - $event->transparency=$obj->transparency; |
|
| 480 | - |
|
| 481 | - $event->fk_project=$obj->fk_project; |
|
| 482 | - |
|
| 483 | - $event->socid=$obj->fk_soc; |
|
| 484 | - $event->contactid=$obj->fk_contact; |
|
| 485 | - |
|
| 486 | - $event->fk_element=$obj->fk_element; |
|
| 487 | - $event->elementtype=$obj->elementtype; |
|
| 466 | + $event = new ActionComm($db); |
|
| 467 | + $event->id = $obj->id; |
|
| 468 | + $event->datep = $datep; // datep and datef are GMT date |
|
| 469 | + $event->datef = $datep2; |
|
| 470 | + $event->type_code = $obj->code; |
|
| 471 | + $event->type_color = $obj->color; |
|
| 472 | + $event->label = $obj->label; |
|
| 473 | + $event->percentage = $obj->percent; |
|
| 474 | + $event->authorid = $obj->fk_user_author; // user id of creator |
|
| 475 | + $event->userownerid = $obj->fk_user_action; // user id of owner |
|
| 476 | + $event->priority = $obj->priority; |
|
| 477 | + $event->fulldayevent = $obj->fulldayevent; |
|
| 478 | + $event->location = $obj->location; |
|
| 479 | + $event->transparency = $obj->transparency; |
|
| 480 | + |
|
| 481 | + $event->fk_project = $obj->fk_project; |
|
| 482 | + |
|
| 483 | + $event->socid = $obj->fk_soc; |
|
| 484 | + $event->contactid = $obj->fk_contact; |
|
| 485 | + |
|
| 486 | + $event->fk_element = $obj->fk_element; |
|
| 487 | + $event->elementtype = $obj->elementtype; |
|
| 488 | 488 | |
| 489 | 489 | // Defined date_start_in_calendar and date_end_in_calendar property |
| 490 | 490 | // They are date start and end of action but modified to not be outside calendar view. |
| 491 | 491 | if ($event->percentage <= 0) |
| 492 | 492 | { |
| 493 | - $event->date_start_in_calendar=$datep; |
|
| 494 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 495 | - else $event->date_end_in_calendar=$datep; |
|
| 493 | + $event->date_start_in_calendar = $datep; |
|
| 494 | + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; |
|
| 495 | + else $event->date_end_in_calendar = $datep; |
|
| 496 | 496 | } |
| 497 | 497 | else |
| 498 | 498 | { |
| 499 | - $event->date_start_in_calendar=$datep; |
|
| 500 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 501 | - else $event->date_end_in_calendar=$datep; |
|
| 499 | + $event->date_start_in_calendar = $datep; |
|
| 500 | + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; |
|
| 501 | + else $event->date_end_in_calendar = $datep; |
|
| 502 | 502 | } |
| 503 | 503 | // Define ponctual property |
| 504 | 504 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) |
| 505 | 505 | { |
| 506 | - $event->ponctuel=1; |
|
| 506 | + $event->ponctuel = 1; |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | // Check values |
@@ -516,29 +516,29 @@ discard block |
||
| 516 | 516 | else |
| 517 | 517 | { |
| 518 | 518 | //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
| 519 | - $event->fetch_userassigned(); // This load $event->userassigned |
|
| 519 | + $event->fetch_userassigned(); // This load $event->userassigned |
|
| 520 | 520 | |
| 521 | - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; |
|
| 522 | - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); |
|
| 521 | + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; |
|
| 522 | + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
| 523 | 523 | |
| 524 | 524 | // Add an entry in actionarray for each day |
| 525 | - $daycursor=$event->date_start_in_calendar; |
|
| 526 | - $annee = date('Y',$daycursor); |
|
| 527 | - $mois = date('m',$daycursor); |
|
| 528 | - $jour = date('d',$daycursor); |
|
| 525 | + $daycursor = $event->date_start_in_calendar; |
|
| 526 | + $annee = date('Y', $daycursor); |
|
| 527 | + $mois = date('m', $daycursor); |
|
| 528 | + $jour = date('d', $daycursor); |
|
| 529 | 529 | |
| 530 | 530 | // Loop on each day covered by action to prepare an index to show on calendar |
| 531 | - $loop=true; $j=0; |
|
| 532 | - $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); |
|
| 531 | + $loop = true; $j = 0; |
|
| 532 | + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); |
|
| 533 | 533 | do |
| 534 | 534 | { |
| 535 | 535 | //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>'; |
| 536 | 536 | |
| 537 | - $eventarray[$daykey][]=$event; |
|
| 537 | + $eventarray[$daykey][] = $event; |
|
| 538 | 538 | $j++; |
| 539 | 539 | |
| 540 | - $daykey+=60*60*24; |
|
| 541 | - if ($daykey > $event->date_end_in_calendar) $loop=false; |
|
| 540 | + $daykey += 60 * 60 * 24; |
|
| 541 | + if ($daykey > $event->date_end_in_calendar) $loop = false; |
|
| 542 | 542 | } |
| 543 | 543 | while ($loop); |
| 544 | 544 | |
@@ -553,9 +553,9 @@ discard block |
||
| 553 | 553 | dol_print_error($db); |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | -$maxnbofchar=18; |
|
| 557 | -$cachethirdparties=array(); |
|
| 558 | -$cachecontacts=array(); |
|
| 556 | +$maxnbofchar = 18; |
|
| 557 | +$cachethirdparties = array(); |
|
| 558 | +$cachecontacts = array(); |
|
| 559 | 559 | |
| 560 | 560 | // Define theme_datacolor array |
| 561 | 561 | $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php"; |
@@ -563,24 +563,24 @@ discard block |
||
| 563 | 563 | { |
| 564 | 564 | include_once $color_file; |
| 565 | 565 | } |
| 566 | -if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); |
|
| 566 | +if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); |
|
| 567 | 567 | |
| 568 | 568 | |
| 569 | -$newparam=$param; // newparam is for birthday links |
|
| 570 | -$newparam=preg_replace('/showbirthday=/i','showbirthday_=',$newparam); // To avoid replacement when replace day= is done |
|
| 571 | -$newparam=preg_replace('/action=show_month&?/i','',$newparam); |
|
| 572 | -$newparam=preg_replace('/action=show_week&?/i','',$newparam); |
|
| 573 | -$newparam=preg_replace('/day=[0-9]+&?/i','',$newparam); |
|
| 574 | -$newparam=preg_replace('/month=[0-9]+&?/i','',$newparam); |
|
| 575 | -$newparam=preg_replace('/year=[0-9]+&?/i','',$newparam); |
|
| 576 | -$newparam=preg_replace('/viewweek=[0-9]+&?/i','',$newparam); |
|
| 577 | -$newparam=preg_replace('/showbirthday_=/i','showbirthday=',$newparam); // Restore correct parameter |
|
| 578 | -$newparam.='&viewweek=1'; |
|
| 569 | +$newparam = $param; // newparam is for birthday links |
|
| 570 | +$newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done |
|
| 571 | +$newparam = preg_replace('/action=show_month&?/i', '', $newparam); |
|
| 572 | +$newparam = preg_replace('/action=show_week&?/i', '', $newparam); |
|
| 573 | +$newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); |
|
| 574 | +$newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); |
|
| 575 | +$newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); |
|
| 576 | +$newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); |
|
| 577 | +$newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter |
|
| 578 | +$newparam .= '&viewweek=1'; |
|
| 579 | 579 | |
| 580 | 580 | echo '<form id="move_event" action="" method="POST"><input type="hidden" name="action" value="mupdate">'; |
| 581 | 581 | echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">'; |
| 582 | 582 | echo '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 583 | -echo '<input type="hidden" name="newdate" id="newdate">' ; |
|
| 583 | +echo '<input type="hidden" name="newdate" id="newdate">'; |
|
| 584 | 584 | echo '</form>'; |
| 585 | 585 | |
| 586 | 586 | |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | echo '<tr class="liste_titre">'; |
| 595 | 595 | echo '<td></td>'; |
| 596 | -$i=0; // 0 = sunday, |
|
| 596 | +$i = 0; // 0 = sunday, |
|
| 597 | 597 | echo '<td align="center" colspan="'.($end_d - $begin_d).'">'; |
| 598 | 598 | echo $langs->trans("Year"); |
| 599 | 599 | print "<br>"; |
@@ -603,40 +603,40 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | echo '<tr class="liste_titre">'; |
| 605 | 605 | echo '<td></td>'; |
| 606 | -$i=0; |
|
| 606 | +$i = 0; |
|
| 607 | 607 | for ($h = $begin_d; $h < $end_d; $h++) |
| 608 | 608 | { |
| 609 | 609 | echo '<td align="center">'; |
| 610 | - print '<small style="font-family: courier">'.sprintf("%02d",$h).'</small>'; |
|
| 610 | + print '<small style="font-family: courier">'.sprintf("%02d", $h).'</small>'; |
|
| 611 | 611 | print "</td>"; |
| 612 | 612 | } |
| 613 | 613 | echo "</td>\n"; |
| 614 | 614 | echo "</tr>\n"; |
| 615 | 615 | |
| 616 | 616 | |
| 617 | -$typeofevents=array(); |
|
| 617 | +$typeofevents = array(); |
|
| 618 | 618 | |
| 619 | 619 | // Load array of colors by type |
| 620 | -$colorsbytype=array(); |
|
| 621 | -$labelbytype=array(); |
|
| 622 | -$sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
|
| 623 | -$resql=$db->query($sql); |
|
| 620 | +$colorsbytype = array(); |
|
| 621 | +$labelbytype = array(); |
|
| 622 | +$sql = "SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
|
| 623 | +$resql = $db->query($sql); |
|
| 624 | 624 | while ($obj = $db->fetch_object($resql)) |
| 625 | 625 | { |
| 626 | - $colorsbytype[$obj->code]=$obj->color; |
|
| 627 | - $labelbytype[$obj->code]=$obj->libelle; |
|
| 626 | + $colorsbytype[$obj->code] = $obj->color; |
|
| 627 | + $labelbytype[$obj->code] = $obj->libelle; |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | // Loop on each user to show calendar |
| 631 | -$todayarray=dol_getdate($now,'fast'); |
|
| 631 | +$todayarray = dol_getdate($now, 'fast'); |
|
| 632 | 632 | $sav = $tmpday; |
| 633 | 633 | $showheader = true; |
| 634 | 634 | $var = false; |
| 635 | 635 | foreach ($typeofevents as $typeofevent) |
| 636 | 636 | { |
| 637 | - $var = ! $var; |
|
| 637 | + $var = !$var; |
|
| 638 | 638 | echo "<tr>"; |
| 639 | - echo '<td class="cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">' . $username->getNomUrl(1). '</td>'; |
|
| 639 | + echo '<td class="cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">'.$username->getNomUrl(1).'</td>'; |
|
| 640 | 640 | $tmpday = $sav; |
| 641 | 641 | |
| 642 | 642 | // Lopp on each day of week |
@@ -651,16 +651,16 @@ discard block |
||
| 651 | 651 | |
| 652 | 652 | // Show days of the current week |
| 653 | 653 | $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); |
| 654 | - $tmparray = dol_getdate($curtime,'fast'); |
|
| 654 | + $tmparray = dol_getdate($curtime, 'fast'); |
|
| 655 | 655 | $tmpday = $tmparray['mday']; |
| 656 | 656 | $tmpmonth = $tmparray['mon']; |
| 657 | 657 | $tmpyear = $tmparray['year']; |
| 658 | 658 | |
| 659 | - $style='cal_current_month'; |
|
| 660 | - if ($iter_day == 6) $style.=' cal_other_month'; |
|
| 661 | - $today=0; |
|
| 662 | - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; |
|
| 663 | - if ($today) $style='cal_today_peruser'; |
|
| 659 | + $style = 'cal_current_month'; |
|
| 660 | + if ($iter_day == 6) $style .= ' cal_other_month'; |
|
| 661 | + $today = 0; |
|
| 662 | + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; |
|
| 663 | + if ($today) $style = 'cal_today_peruser'; |
|
| 664 | 664 | |
| 665 | 665 | show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
| 666 | 666 | |
@@ -673,16 +673,16 @@ discard block |
||
| 673 | 673 | echo "</table>\n"; |
| 674 | 674 | |
| 675 | 675 | |
| 676 | -if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 676 | +if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
| 677 | 677 | { |
| 678 | 678 | $langs->load("commercial"); |
| 679 | 679 | print '<br>'.$langs->trans("Legend").': <br>'; |
| 680 | - foreach($colorsbytype as $code => $color) |
|
| 680 | + foreach ($colorsbytype as $code => $color) |
|
| 681 | 681 | { |
| 682 | 682 | if ($color) |
| 683 | 683 | { |
| 684 | - print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color?'background: #'.$color.';':'').'width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 685 | - print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code]; |
|
| 684 | + print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ? 'background: #'.$color.';' : '').'width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 685 | + print $langs->trans("Action".$code) != "Action".$code ? $langs->trans("Action".$code) : $labelbytype[$code]; |
|
| 686 | 686 | //print $code; |
| 687 | 687 | print '</div>'; |
| 688 | 688 | } |
@@ -760,98 +760,98 @@ discard block |
||
| 760 | 760 | * @param bool $var true or false for alternat style on tr/td |
| 761 | 761 | * @return void |
| 762 | 762 | */ |
| 763 | -function show_day_events_pertype($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false) |
|
| 763 | +function show_day_events_pertype($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $showheader = false, $colorsbytype = array(), $var = false) |
|
| 764 | 764 | { |
| 765 | 765 | global $db; |
| 766 | 766 | global $user, $conf, $langs, $hookmanager, $action; |
| 767 | - global $filter, $filtert, $status, $actioncode; // Filters used into search form |
|
| 768 | - global $theme_datacolor; // Array with a list of different we can use (come from theme) |
|
| 767 | + global $filter, $filtert, $status, $actioncode; // Filters used into search form |
|
| 768 | + global $theme_datacolor; // Array with a list of different we can use (come from theme) |
|
| 769 | 769 | global $cachethirdparties, $cachecontacts, $cacheprojects, $colorindexused; |
| 770 | 770 | global $begin_h, $end_h; |
| 771 | 771 | |
| 772 | - $cases1 = array(); // Color first half hour |
|
| 772 | + $cases1 = array(); // Color first half hour |
|
| 773 | 773 | $cases2 = array(); // Color second half hour |
| 774 | 774 | |
| 775 | 775 | $curtime = dol_mktime(0, 0, 0, $month, $day, $year); |
| 776 | 776 | |
| 777 | - $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); |
|
| 778 | - $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); |
|
| 777 | + $i = 0; $nummytasks = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); |
|
| 778 | + $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); |
|
| 779 | 779 | |
| 780 | - $nextindextouse=count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ... |
|
| 780 | + $nextindextouse = count($colorindexused); // At first run, this is 0, so fist user has 0, next 1, ... |
|
| 781 | 781 | //if ($username->id && $day==1) var_dump($eventarray); |
| 782 | 782 | |
| 783 | 783 | // We are in a particular day for $username, now we scan all events |
| 784 | 784 | foreach ($eventarray as $daykey => $notused) |
| 785 | 785 | { |
| 786 | - $annee = date('Y',$daykey); |
|
| 787 | - $mois = date('m',$daykey); |
|
| 788 | - $jour = date('d',$daykey); |
|
| 786 | + $annee = date('Y', $daykey); |
|
| 787 | + $mois = date('m', $daykey); |
|
| 788 | + $jour = date('d', $daykey); |
|
| 789 | 789 | //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n"; |
| 790 | 790 | |
| 791 | - if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? |
|
| 791 | + if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ? |
|
| 792 | 792 | { |
| 793 | 793 | // Scan all event for this date |
| 794 | 794 | foreach ($eventarray[$daykey] as $index => $event) |
| 795 | 795 | { |
| 796 | 796 | //var_dump($event); |
| 797 | 797 | |
| 798 | - $keysofuserassigned=array_keys($event->userassigned); |
|
| 799 | - if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 798 | + $keysofuserassigned = array_keys($event->userassigned); |
|
| 799 | + if (!in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 800 | 800 | //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
| 801 | 801 | |
| 802 | - $parameters=array(); |
|
| 803 | - $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks |
|
| 802 | + $parameters = array(); |
|
| 803 | + $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks |
|
| 804 | 804 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 805 | 805 | |
| 806 | - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); |
|
| 806 | + $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); |
|
| 807 | 807 | |
| 808 | 808 | // Define $color (Hex string like '0088FF') and $cssclass of event |
| 809 | - $color=-1; $cssclass=''; $colorindex=-1; |
|
| 809 | + $color = -1; $cssclass = ''; $colorindex = -1; |
|
| 810 | 810 | if (in_array($user->id, $keysofuserassigned)) |
| 811 | 811 | { |
| 812 | - $nummytasks++; $cssclass='family_mytasks'; |
|
| 813 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; |
|
| 812 | + $nummytasks++; $cssclass = 'family_mytasks'; |
|
| 813 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; |
|
| 814 | 814 | } |
| 815 | 815 | else if ($event->type_code == 'ICALEVENT') |
| 816 | 816 | { |
| 817 | 817 | $numical++; |
| 818 | - if (! empty($event->icalname)) |
|
| 818 | + if (!empty($event->icalname)) |
|
| 819 | 819 | { |
| 820 | - if (! isset($numicals[dol_string_nospecial($event->icalname)])) { |
|
| 820 | + if (!isset($numicals[dol_string_nospecial($event->icalname)])) { |
|
| 821 | 821 | $numicals[dol_string_nospecial($event->icalname)] = 0; |
| 822 | 822 | } |
| 823 | 823 | $numicals[dol_string_nospecial($event->icalname)]++; |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - $color=$event->icalcolor; |
|
| 827 | - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); |
|
| 826 | + $color = $event->icalcolor; |
|
| 827 | + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable'); |
|
| 828 | 828 | } |
| 829 | 829 | else if ($event->type_code == 'BIRTHDAY') |
| 830 | 830 | { |
| 831 | - $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 831 | + $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); |
|
| 832 | 832 | } |
| 833 | 833 | else |
| 834 | 834 | { |
| 835 | - $numother++; $cssclass='family_other'; |
|
| 836 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color=$event->type_color; |
|
| 835 | + $numother++; $cssclass = 'family_other'; |
|
| 836 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | if ($color < 0) // Color was not forced. Set color according to color index. |
| 840 | 840 | { |
| 841 | 841 | // Define color index if not yet defined |
| 842 | - $idusertouse=($event->userownerid?$event->userownerid:0); |
|
| 842 | + $idusertouse = ($event->userownerid ? $event->userownerid : 0); |
|
| 843 | 843 | if (isset($colorindexused[$idusertouse])) |
| 844 | 844 | { |
| 845 | - $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user |
|
| 845 | + $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user |
|
| 846 | 846 | } |
| 847 | 847 | else |
| 848 | 848 | { |
| 849 | - $colorindex=$nextindextouse; |
|
| 850 | - $colorindexused[$idusertouse]=$colorindex; |
|
| 851 | - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color |
|
| 849 | + $colorindex = $nextindextouse; |
|
| 850 | + $colorindexused[$idusertouse] = $colorindex; |
|
| 851 | + if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color |
|
| 852 | 852 | } |
| 853 | 853 | // Define color |
| 854 | - $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 854 | + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); |
|
| 855 | 855 | } |
| 856 | 856 | //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; |
| 857 | 857 | |
@@ -862,195 +862,195 @@ discard block |
||
| 862 | 862 | $newcolor = ''; //init |
| 863 | 863 | if (empty($event->fulldayevent)) |
| 864 | 864 | { |
| 865 | - $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0); |
|
| 866 | - $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0); |
|
| 867 | - $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); |
|
| 865 | + $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, false, 0); |
|
| 866 | + $b = dol_mktime((int) $h, 30, 0, $month, $day, $year, false, 0); |
|
| 867 | + $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, false, 0); |
|
| 868 | 868 | |
| 869 | - $dateendtouse=$event->date_end_in_calendar; |
|
| 870 | - if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; |
|
| 869 | + $dateendtouse = $event->date_end_in_calendar; |
|
| 870 | + if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++; |
|
| 871 | 871 | |
| 872 | 872 | //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
| 873 | 873 | |
| 874 | 874 | if ($event->date_start_in_calendar < $b && $dateendtouse > $a) |
| 875 | 875 | { |
| 876 | - $busy=$event->transparency; |
|
| 877 | - $cases1[$h][$event->id]['busy']=$busy; |
|
| 878 | - $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 876 | + $busy = $event->transparency; |
|
| 877 | + $cases1[$h][$event->id]['busy'] = $busy; |
|
| 878 | + $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); |
|
| 879 | 879 | if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
| 880 | 880 | { |
| 881 | - $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 882 | - $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 883 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 884 | - else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 881 | + $tmpa = dol_getdate($event->date_start_in_calendar, true); |
|
| 882 | + $tmpb = dol_getdate($event->date_end_in_calendar, true); |
|
| 883 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); |
|
| 884 | + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); |
|
| 885 | 885 | } |
| 886 | - $cases1[$h][$event->id]['string'].=' - '.$event->label; |
|
| 887 | - $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 888 | - $cases1[$h][$event->id]['color']=$color; |
|
| 886 | + $cases1[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 887 | + $cases1[$h][$event->id]['typecode'] = $event->type_code; |
|
| 888 | + $cases1[$h][$event->id]['color'] = $color; |
|
| 889 | 889 | if ($event->fk_project > 0) |
| 890 | 890 | { |
| 891 | 891 | if (empty($cacheprojects[$event->fk_project])) |
| 892 | 892 | { |
| 893 | - $tmpproj=new Project($db); |
|
| 893 | + $tmpproj = new Project($db); |
|
| 894 | 894 | $tmpproj->fetch($event->fk_project); |
| 895 | - $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 895 | + $cacheprojects[$event->fk_project] = $tmpproj; |
|
| 896 | 896 | } |
| 897 | - $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 897 | + $cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 898 | 898 | } |
| 899 | 899 | if ($event->socid > 0) |
| 900 | 900 | { |
| 901 | 901 | if (empty($cachethirdparties[$event->socid])) |
| 902 | 902 | { |
| 903 | - $tmpthirdparty=new Societe($db); |
|
| 903 | + $tmpthirdparty = new Societe($db); |
|
| 904 | 904 | $tmpthirdparty->fetch($event->socid); |
| 905 | - $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 905 | + $cachethirdparties[$event->socid] = $tmpthirdparty; |
|
| 906 | 906 | } |
| 907 | - $cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 907 | + $cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name; |
|
| 908 | 908 | } |
| 909 | 909 | if ($event->contactid > 0) |
| 910 | 910 | { |
| 911 | 911 | if (empty($cachecontacts[$event->contactid])) |
| 912 | 912 | { |
| 913 | - $tmpcontact=new Contact($db); |
|
| 913 | + $tmpcontact = new Contact($db); |
|
| 914 | 914 | $tmpcontact->fetch($event->contactid); |
| 915 | - $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 915 | + $cachecontacts[$event->contactid] = $tmpcontact; |
|
| 916 | 916 | } |
| 917 | - $cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 917 | + $cases1[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | 920 | if ($event->date_start_in_calendar < $c && $dateendtouse > $b) |
| 921 | 921 | { |
| 922 | - $busy=$event->transparency; |
|
| 923 | - $cases2[$h][$event->id]['busy']=$busy; |
|
| 924 | - $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 922 | + $busy = $event->transparency; |
|
| 923 | + $cases2[$h][$event->id]['busy'] = $busy; |
|
| 924 | + $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); |
|
| 925 | 925 | if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
| 926 | 926 | { |
| 927 | - $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 928 | - $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 929 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 930 | - else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 927 | + $tmpa = dol_getdate($event->date_start_in_calendar, true); |
|
| 928 | + $tmpb = dol_getdate($event->date_end_in_calendar, true); |
|
| 929 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); |
|
| 930 | + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); |
|
| 931 | 931 | } |
| 932 | - $cases2[$h][$event->id]['string'].=' - '.$event->label; |
|
| 933 | - $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 934 | - $cases2[$h][$event->id]['color']=$color; |
|
| 932 | + $cases2[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 933 | + $cases2[$h][$event->id]['typecode'] = $event->type_code; |
|
| 934 | + $cases2[$h][$event->id]['color'] = $color; |
|
| 935 | 935 | if ($event->fk_project > 0) |
| 936 | 936 | { |
| 937 | 937 | if (empty($cacheprojects[$event->fk_project])) |
| 938 | 938 | { |
| 939 | - $tmpproj=new Project($db); |
|
| 939 | + $tmpproj = new Project($db); |
|
| 940 | 940 | $tmpproj->fetch($event->fk_project); |
| 941 | - $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 941 | + $cacheprojects[$event->fk_project] = $tmpproj; |
|
| 942 | 942 | } |
| 943 | - $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 943 | + $cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 944 | 944 | } |
| 945 | 945 | if ($event->socid > 0) |
| 946 | 946 | { |
| 947 | 947 | if (empty($cachethirdparties[$event->socid])) |
| 948 | 948 | { |
| 949 | - $tmpthirdparty=new Societe($db); |
|
| 949 | + $tmpthirdparty = new Societe($db); |
|
| 950 | 950 | $tmpthirdparty->fetch($event->socid); |
| 951 | - $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 951 | + $cachethirdparties[$event->socid] = $tmpthirdparty; |
|
| 952 | 952 | } |
| 953 | - $cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 953 | + $cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name; |
|
| 954 | 954 | } |
| 955 | 955 | if ($event->contactid > 0) |
| 956 | 956 | { |
| 957 | 957 | if (empty($cachecontacts[$event->contactid])) |
| 958 | 958 | { |
| 959 | - $tmpcontact=new Contact($db); |
|
| 959 | + $tmpcontact = new Contact($db); |
|
| 960 | 960 | $tmpcontact->fetch($event->contactid); |
| 961 | - $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 961 | + $cachecontacts[$event->contactid] = $tmpcontact; |
|
| 962 | 962 | } |
| 963 | - $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 963 | + $cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 964 | 964 | } |
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | 967 | else |
| 968 | 968 | { |
| 969 | - $busy=$event->transparency; |
|
| 970 | - $cases1[$h][$event->id]['busy']=$busy; |
|
| 971 | - $cases2[$h][$event->id]['busy']=$busy; |
|
| 972 | - $cases1[$h][$event->id]['string']=$event->label; |
|
| 973 | - $cases2[$h][$event->id]['string']=$event->label; |
|
| 974 | - $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 975 | - $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 976 | - $cases1[$h][$event->id]['color']=$color; |
|
| 977 | - $cases2[$h][$event->id]['color']=$color; |
|
| 969 | + $busy = $event->transparency; |
|
| 970 | + $cases1[$h][$event->id]['busy'] = $busy; |
|
| 971 | + $cases2[$h][$event->id]['busy'] = $busy; |
|
| 972 | + $cases1[$h][$event->id]['string'] = $event->label; |
|
| 973 | + $cases2[$h][$event->id]['string'] = $event->label; |
|
| 974 | + $cases1[$h][$event->id]['typecode'] = $event->type_code; |
|
| 975 | + $cases2[$h][$event->id]['typecode'] = $event->type_code; |
|
| 976 | + $cases1[$h][$event->id]['color'] = $color; |
|
| 977 | + $cases2[$h][$event->id]['color'] = $color; |
|
| 978 | 978 | } |
| 979 | 979 | } |
| 980 | 980 | $i++; |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | - break; // We found the date we were looking for. No need to search anymore. |
|
| 983 | + break; // We found the date we were looking for. No need to search anymore. |
|
| 984 | 984 | } |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | // Now output $casesX |
| 988 | 988 | for ($h = $begin_h; $h < $end_h; $h++) |
| 989 | 989 | { |
| 990 | - $color1='';$color2=''; |
|
| 991 | - $style1='';$style2=''; |
|
| 992 | - $string1=' ';$string2=' '; |
|
| 993 | - $title1='';$title2=''; |
|
| 990 | + $color1 = ''; $color2 = ''; |
|
| 991 | + $style1 = ''; $style2 = ''; |
|
| 992 | + $string1 = ' '; $string2 = ' '; |
|
| 993 | + $title1 = ''; $title2 = ''; |
|
| 994 | 994 | if (isset($cases1[$h]) && $cases1[$h] != '') |
| 995 | 995 | { |
| 996 | 996 | //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 997 | - if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 998 | - $string1=' '; |
|
| 999 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; |
|
| 1000 | - else $style1='peruser_busy'; |
|
| 1001 | - foreach($cases1[$h] as $id => $ev) |
|
| 997 | + if (count($cases1[$h]) > 1) $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 998 | + $string1 = ' '; |
|
| 999 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 = 'peruser_notbusy'; |
|
| 1000 | + else $style1 = 'peruser_busy'; |
|
| 1001 | + foreach ($cases1[$h] as $id => $ev) |
|
| 1002 | 1002 | { |
| 1003 | - if ($ev['busy']) $style1='peruser_busy'; |
|
| 1003 | + if ($ev['busy']) $style1 = 'peruser_busy'; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | } |
| 1006 | 1006 | if (isset($cases2[$h]) && $cases2[$h] != '') |
| 1007 | 1007 | { |
| 1008 | 1008 | //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1009 | - if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1010 | - $string2=' '; |
|
| 1011 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; |
|
| 1012 | - else $style2='peruser_busy'; |
|
| 1013 | - foreach($cases2[$h] as $id => $ev) |
|
| 1009 | + if (count($cases2[$h]) > 1) $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1010 | + $string2 = ' '; |
|
| 1011 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 = 'peruser_notbusy'; |
|
| 1012 | + else $style2 = 'peruser_busy'; |
|
| 1013 | + foreach ($cases2[$h] as $id => $ev) |
|
| 1014 | 1014 | { |
| 1015 | - if ($ev['busy']) $style2='peruser_busy'; |
|
| 1015 | + if ($ev['busy']) $style2 = 'peruser_busy'; |
|
| 1016 | 1016 | } |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | - $ids1='';$ids2=''; |
|
| 1020 | - if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h])); |
|
| 1021 | - if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h])); |
|
| 1019 | + $ids1 = ''; $ids2 = ''; |
|
| 1020 | + if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); |
|
| 1021 | + if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h])); |
|
| 1022 | 1022 | |
| 1023 | - if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1024 | - else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1023 | + if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1024 | + else echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1025 | 1025 | if (count($cases1[$h]) == 1) // only 1 event |
| 1026 | 1026 | { |
| 1027 | 1027 | $output = array_slice($cases1[$h], 0, 1); |
| 1028 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1029 | - if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1028 | + $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); |
|
| 1029 | + if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; |
|
| 1030 | 1030 | if ($output[0]['color']) $color1 = $output[0]['color']; |
| 1031 | 1031 | } |
| 1032 | 1032 | else if (count($cases1[$h]) > 1) |
| 1033 | 1033 | { |
| 1034 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1035 | - $color1='222222'; |
|
| 1034 | + $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); |
|
| 1035 | + $color1 = '222222'; |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | if (count($cases2[$h]) == 1) // only 1 event |
| 1039 | 1039 | { |
| 1040 | 1040 | $output = array_slice($cases2[$h], 0, 1); |
| 1041 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1042 | - if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1041 | + $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); |
|
| 1042 | + if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; |
|
| 1043 | 1043 | if ($output[0]['color']) $color2 = $output[0]['color']; |
| 1044 | 1044 | } |
| 1045 | 1045 | else if (count($cases2[$h]) > 1) |
| 1046 | 1046 | { |
| 1047 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1048 | - $color2='222222'; |
|
| 1047 | + $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); |
|
| 1048 | + $color2 = '222222'; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | print '<table class="nobordernopadding" width="100%">'; |
| 1051 | - print '<tr><td '.($color1?'style="background: #'.$color1.';"':'').'class="'.($style1?$style1.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>'; |
|
| 1051 | + print '<tr><td '.($color1 ? 'style="background: #'.$color1.';"' : '').'class="'.($style1 ? $style1.' ' : '').'onclickopenref'.($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>'; |
|
| 1052 | 1052 | print $string1; |
| 1053 | - print '</td><td '.($color2?'style="background: #'.$color2.';"':'').'class="'.($style2?$style2.' ':'').'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>'; |
|
| 1053 | + print '</td><td '.($color2 ? 'style="background: #'.$color2.';"' : '').'class="'.($style2 ? $style2.' ' : '').'onclickopenref'.($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids2 ? $ids2 : 'none').'"'.($title2 ? ' title="'.$title2.'"' : '').'>'; |
|
| 1054 | 1054 | print $string2; |
| 1055 | 1055 | print '</td></tr>'; |
| 1056 | 1056 | print '</table>'; |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | if ($action == 'builddoc') |
| 61 | 61 | { |
| 62 | - $cat = new CommActionRapport($db, $month, $year); |
|
| 63 | - $result=$cat->write_file(GETPOST('id','int')); |
|
| 64 | - if ($result < 0) |
|
| 65 | - { |
|
| 66 | - setEventMessages($cat->error, $cat->errors, 'errors'); |
|
| 67 | - } |
|
| 62 | + $cat = new CommActionRapport($db, $month, $year); |
|
| 63 | + $result=$cat->write_file(GETPOST('id','int')); |
|
| 64 | + if ($result < 0) |
|
| 65 | + { |
|
| 66 | + setEventMessages($cat->error, $cat->errors, 'errors'); |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | $nbtotalofrecords = $db->num_rows($result); |
| 96 | 96 | if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
| 97 | 97 | { |
| 98 | - $page = 0; |
|
| 99 | - $offset = 0; |
|
| 98 | + $page = 0; |
|
| 99 | + $offset = 0; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -107,106 +107,106 @@ discard block |
||
| 107 | 107 | $resql=$db->query($sql); |
| 108 | 108 | if ($resql) |
| 109 | 109 | { |
| 110 | - $num = $db->num_rows($resql); |
|
| 110 | + $num = $db->num_rows($resql); |
|
| 111 | 111 | |
| 112 | - $param=''; |
|
| 113 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 112 | + $param=''; |
|
| 113 | + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 114 | 114 | |
| 115 | - print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
|
| 115 | + print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
|
| 116 | 116 | if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
| 117 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 118 | - print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
|
| 119 | - print '<input type="hidden" name="action" value="list">'; |
|
| 120 | - print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
| 121 | - print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
| 122 | - print '<input type="hidden" name="page" value="'.$page.'">'; |
|
| 117 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
| 118 | + print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
|
| 119 | + print '<input type="hidden" name="action" value="list">'; |
|
| 120 | + print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
| 121 | + print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
| 122 | + print '<input type="hidden" name="page" value="'.$page.'">'; |
|
| 123 | 123 | |
| 124 | - print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit); |
|
| 124 | + print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit); |
|
| 125 | 125 | |
| 126 | - $moreforfilter=''; |
|
| 126 | + $moreforfilter=''; |
|
| 127 | 127 | |
| 128 | - $i = 0; |
|
| 128 | + $i = 0; |
|
| 129 | 129 | print '<div class="div-table-responsive">'; |
| 130 | 130 | print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
| 131 | 131 | |
| 132 | 132 | print '<tr class="liste_titre">'; |
| 133 | - print '<td>'.$langs->trans("Period").'</td>'; |
|
| 134 | - print '<td align="center">'.$langs->trans("EventsNb").'</td>'; |
|
| 135 | - print '<td align="center">'.$langs->trans("Action").'</td>'; |
|
| 136 | - print '<td>'.$langs->trans("PDF").'</td>'; |
|
| 137 | - print '<td align="center">'.$langs->trans("Date").'</td>'; |
|
| 138 | - print '<td align="center">'.$langs->trans("Size").'</td>'; |
|
| 139 | - print "</tr>\n"; |
|
| 140 | - |
|
| 141 | - while ($i < min($num,$limit)) |
|
| 142 | - { |
|
| 143 | - $obj=$db->fetch_object($resql); |
|
| 144 | - |
|
| 145 | - if ($obj) |
|
| 146 | - { |
|
| 147 | - |
|
| 148 | - print '<tr class="oddeven">'; |
|
| 149 | - |
|
| 150 | - // Date |
|
| 151 | - print "<td>".$obj->df."</td>\n"; |
|
| 152 | - |
|
| 153 | - // Nb of events |
|
| 154 | - print '<td align="center">'.$obj->cc.'</td>'; |
|
| 155 | - |
|
| 156 | - // Button to build doc |
|
| 157 | - print '<td align="center">'; |
|
| 158 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&page='.$page.'&month='.$obj->month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'),'filenew').'</a>'; |
|
| 159 | - print '</td>'; |
|
| 160 | - |
|
| 161 | - $name = "actions-".$obj->month."-".$obj->year.".pdf"; |
|
| 162 | - $relativepath= $name; |
|
| 163 | - $file = $conf->agenda->dir_temp."/".$name; |
|
| 164 | - $modulepart = 'actionsreport'; |
|
| 165 | - $documenturl= DOL_URL_ROOT.'/document.php'; |
|
| 166 | - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper |
|
| 167 | - |
|
| 168 | - if (file_exists($file)) |
|
| 169 | - { |
|
| 170 | - print '<td class="tdoverflowmax300">'; |
|
| 171 | - //print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&file='.urlencode($relativepath).'&modulepart=actionsreport">'.img_pdf().'</a>'; |
|
| 172 | - |
|
| 173 | - $filearray=array('name'=>basename($file),'fullname'=>$file,'type'=>'file'); |
|
| 174 | - $out=''; |
|
| 175 | - |
|
| 176 | - // Show file name with link to download |
|
| 177 | - $out.= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"'; |
|
| 178 | - $mime=dol_mimetype($relativepath,'',0); |
|
| 179 | - if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; |
|
| 180 | - $out.= ' target="_blank">'; |
|
| 181 | - $out.= img_mime($filearray["name"],$langs->trans("File").': '.$filearray["name"]); |
|
| 182 | - $out.= $filearray["name"]; |
|
| 183 | - $out.= '</a>'."\n"; |
|
| 184 | - $out.= $formfile->showPreview($filearray,$modulepart,$relativepath,0,$param); |
|
| 185 | - print $out; |
|
| 186 | - |
|
| 187 | - print '</td>'; |
|
| 188 | - print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>'; |
|
| 189 | - print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>'; |
|
| 190 | - } |
|
| 191 | - else { |
|
| 192 | - print '<td> </td>'; |
|
| 193 | - print '<td> </td>'; |
|
| 194 | - print '<td> </td>'; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - print "</tr>\n"; |
|
| 198 | - } |
|
| 199 | - $i++; |
|
| 200 | - } |
|
| 201 | - print "</table>"; |
|
| 202 | - print '</div>'; |
|
| 203 | - print '</form>'; |
|
| 204 | - |
|
| 205 | - $db->free($resql); |
|
| 133 | + print '<td>'.$langs->trans("Period").'</td>'; |
|
| 134 | + print '<td align="center">'.$langs->trans("EventsNb").'</td>'; |
|
| 135 | + print '<td align="center">'.$langs->trans("Action").'</td>'; |
|
| 136 | + print '<td>'.$langs->trans("PDF").'</td>'; |
|
| 137 | + print '<td align="center">'.$langs->trans("Date").'</td>'; |
|
| 138 | + print '<td align="center">'.$langs->trans("Size").'</td>'; |
|
| 139 | + print "</tr>\n"; |
|
| 140 | + |
|
| 141 | + while ($i < min($num,$limit)) |
|
| 142 | + { |
|
| 143 | + $obj=$db->fetch_object($resql); |
|
| 144 | + |
|
| 145 | + if ($obj) |
|
| 146 | + { |
|
| 147 | + |
|
| 148 | + print '<tr class="oddeven">'; |
|
| 149 | + |
|
| 150 | + // Date |
|
| 151 | + print "<td>".$obj->df."</td>\n"; |
|
| 152 | + |
|
| 153 | + // Nb of events |
|
| 154 | + print '<td align="center">'.$obj->cc.'</td>'; |
|
| 155 | + |
|
| 156 | + // Button to build doc |
|
| 157 | + print '<td align="center">'; |
|
| 158 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&page='.$page.'&month='.$obj->month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'),'filenew').'</a>'; |
|
| 159 | + print '</td>'; |
|
| 160 | + |
|
| 161 | + $name = "actions-".$obj->month."-".$obj->year.".pdf"; |
|
| 162 | + $relativepath= $name; |
|
| 163 | + $file = $conf->agenda->dir_temp."/".$name; |
|
| 164 | + $modulepart = 'actionsreport'; |
|
| 165 | + $documenturl= DOL_URL_ROOT.'/document.php'; |
|
| 166 | + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper |
|
| 167 | + |
|
| 168 | + if (file_exists($file)) |
|
| 169 | + { |
|
| 170 | + print '<td class="tdoverflowmax300">'; |
|
| 171 | + //print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&file='.urlencode($relativepath).'&modulepart=actionsreport">'.img_pdf().'</a>'; |
|
| 172 | + |
|
| 173 | + $filearray=array('name'=>basename($file),'fullname'=>$file,'type'=>'file'); |
|
| 174 | + $out=''; |
|
| 175 | + |
|
| 176 | + // Show file name with link to download |
|
| 177 | + $out.= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"'; |
|
| 178 | + $mime=dol_mimetype($relativepath,'',0); |
|
| 179 | + if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; |
|
| 180 | + $out.= ' target="_blank">'; |
|
| 181 | + $out.= img_mime($filearray["name"],$langs->trans("File").': '.$filearray["name"]); |
|
| 182 | + $out.= $filearray["name"]; |
|
| 183 | + $out.= '</a>'."\n"; |
|
| 184 | + $out.= $formfile->showPreview($filearray,$modulepart,$relativepath,0,$param); |
|
| 185 | + print $out; |
|
| 186 | + |
|
| 187 | + print '</td>'; |
|
| 188 | + print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>'; |
|
| 189 | + print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>'; |
|
| 190 | + } |
|
| 191 | + else { |
|
| 192 | + print '<td> </td>'; |
|
| 193 | + print '<td> </td>'; |
|
| 194 | + print '<td> </td>'; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + print "</tr>\n"; |
|
| 198 | + } |
|
| 199 | + $i++; |
|
| 200 | + } |
|
| 201 | + print "</table>"; |
|
| 202 | + print '</div>'; |
|
| 203 | + print '</form>'; |
|
| 204 | + |
|
| 205 | + $db->free($resql); |
|
| 206 | 206 | } |
| 207 | 207 | else |
| 208 | 208 | { |
| 209 | - dol_print_error($db); |
|
| 209 | + dol_print_error($db); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // End of page |
@@ -44,12 +44,18 @@ discard block |
||
| 44 | 44 | $page = GETPOST("page",'int'); |
| 45 | 45 | if ($page == -1 || $page == null) { $page = 0 ; } |
| 46 | 46 | $offset = $limit * $page ; |
| 47 | -if (! $sortorder) $sortorder="DESC"; |
|
| 48 | -if (! $sortfield) $sortfield="a.datep"; |
|
| 47 | +if (! $sortorder) { |
|
| 48 | + $sortorder="DESC"; |
|
| 49 | +} |
|
| 50 | +if (! $sortfield) { |
|
| 51 | + $sortfield="a.datep"; |
|
| 52 | +} |
|
| 49 | 53 | |
| 50 | 54 | // Security check |
| 51 | 55 | $socid = GETPOST('socid','int'); |
| 52 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 56 | +if ($user->societe_id) { |
|
| 57 | + $socid=$user->societe_id; |
|
| 58 | +} |
|
| 53 | 59 | $result = restrictedArea($user, 'agenda', $socid, '', 'myactions'); |
| 54 | 60 | |
| 55 | 61 | |
@@ -93,9 +99,11 @@ discard block |
||
| 93 | 99 | { |
| 94 | 100 | $result = $db->query($sql); |
| 95 | 101 | $nbtotalofrecords = $db->num_rows($result); |
| 96 | - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
| 102 | + if (($page * $limit) > $nbtotalofrecords) { |
|
| 103 | + // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
| 97 | 104 | { |
| 98 | 105 | $page = 0; |
| 106 | + } |
|
| 99 | 107 | $offset = 0; |
| 100 | 108 | } |
| 101 | 109 | } |
@@ -110,10 +118,14 @@ discard block |
||
| 110 | 118 | $num = $db->num_rows($resql); |
| 111 | 119 | |
| 112 | 120 | $param=''; |
| 113 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 121 | + if ($limit > 0 && $limit != $conf->liste_limit) { |
|
| 122 | + $param.='&limit='.$limit; |
|
| 123 | + } |
|
| 114 | 124 | |
| 115 | 125 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
| 116 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 126 | + if ($optioncss != '') { |
|
| 127 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 128 | + } |
|
| 117 | 129 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 118 | 130 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
| 119 | 131 | print '<input type="hidden" name="action" value="list">'; |
@@ -163,7 +175,10 @@ discard block |
||
| 163 | 175 | $file = $conf->agenda->dir_temp."/".$name; |
| 164 | 176 | $modulepart = 'actionsreport'; |
| 165 | 177 | $documenturl= DOL_URL_ROOT.'/document.php'; |
| 166 | - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper |
|
| 178 | + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) { |
|
| 179 | + $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; |
|
| 180 | + } |
|
| 181 | + // To use another wrapper |
|
| 167 | 182 | |
| 168 | 183 | if (file_exists($file)) |
| 169 | 184 | { |
@@ -176,7 +191,9 @@ discard block |
||
| 176 | 191 | // Show file name with link to download |
| 177 | 192 | $out.= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"'; |
| 178 | 193 | $mime=dol_mimetype($relativepath,'',0); |
| 179 | - if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; |
|
| 194 | + if (preg_match('/text/',$mime)) { |
|
| 195 | + $out.= ' target="_blank"'; |
|
| 196 | + } |
|
| 180 | 197 | $out.= ' target="_blank">'; |
| 181 | 198 | $out.= img_mime($filearray["name"],$langs->trans("File").': '.$filearray["name"]); |
| 182 | 199 | $out.= $filearray["name"]; |
@@ -187,8 +204,7 @@ discard block |
||
| 187 | 204 | print '</td>'; |
| 188 | 205 | print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>'; |
| 189 | 206 | print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>'; |
| 190 | - } |
|
| 191 | - else { |
|
| 207 | + } else { |
|
| 192 | 208 | print '<td> </td>'; |
| 193 | 209 | print '<td> </td>'; |
| 194 | 210 | print '<td> </td>'; |
@@ -203,8 +219,7 @@ discard block |
||
| 203 | 219 | print '</form>'; |
| 204 | 220 | |
| 205 | 221 | $db->free($resql); |
| 206 | -} |
|
| 207 | -else |
|
| 222 | +} else |
|
| 208 | 223 | { |
| 209 | 224 | dol_print_error($db); |
| 210 | 225 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 29 | 29 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 30 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 30 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 32 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
@@ -37,22 +37,22 @@ discard block |
||
| 37 | 37 | // Load translation files required by the page |
| 38 | 38 | $langs->loadLangs(array("agenda", "commercial")); |
| 39 | 39 | |
| 40 | -$action=GETPOST('action','alpha'); |
|
| 41 | -$month=GETPOST('month'); |
|
| 42 | -$year=GETPOST('year'); |
|
| 40 | +$action = GETPOST('action', 'alpha'); |
|
| 41 | +$month = GETPOST('month'); |
|
| 42 | +$year = GETPOST('year'); |
|
| 43 | 43 | |
| 44 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 45 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
| 46 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
| 47 | -$page = GETPOST("page",'int'); |
|
| 48 | -if ($page == -1 || $page == null) { $page = 0 ; } |
|
| 49 | -$offset = $limit * $page ; |
|
| 50 | -if (! $sortorder) $sortorder="DESC"; |
|
| 51 | -if (! $sortfield) $sortfield="a.datep"; |
|
| 44 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 45 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
| 46 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
| 47 | +$page = GETPOST("page", 'int'); |
|
| 48 | +if ($page == -1 || $page == null) { $page = 0; } |
|
| 49 | +$offset = $limit * $page; |
|
| 50 | +if (!$sortorder) $sortorder = "DESC"; |
|
| 51 | +if (!$sortfield) $sortfield = "a.datep"; |
|
| 52 | 52 | |
| 53 | 53 | // Security check |
| 54 | -$socid = GETPOST('socid','int'); |
|
| 55 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 54 | +$socid = GETPOST('socid', 'int'); |
|
| 55 | +if ($user->societe_id) $socid = $user->societe_id; |
|
| 56 | 56 | $result = restrictedArea($user, 'agenda', $socid, '', 'myactions'); |
| 57 | 57 | |
| 58 | 58 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | if ($action == 'builddoc') |
| 64 | 64 | { |
| 65 | 65 | $cat = new CommActionRapport($db, $month, $year); |
| 66 | - $result=$cat->write_file(GETPOST('id','int')); |
|
| 66 | + $result = $cat->write_file(GETPOST('id', 'int')); |
|
| 67 | 67 | if ($result < 0) |
| 68 | 68 | { |
| 69 | 69 | setEventMessages($cat->error, $cat->errors, 'errors'); |
@@ -75,21 +75,21 @@ discard block |
||
| 75 | 75 | * View |
| 76 | 76 | */ |
| 77 | 77 | |
| 78 | -$formfile=new FormFile($db); |
|
| 78 | +$formfile = new FormFile($db); |
|
| 79 | 79 | |
| 80 | 80 | llxHeader(); |
| 81 | 81 | |
| 82 | 82 | $sql = "SELECT count(*) as cc,"; |
| 83 | -$sql.= " date_format(a.datep, '%m/%Y') as df,"; |
|
| 84 | -$sql.= " date_format(a.datep, '%m') as month,"; |
|
| 85 | -$sql.= " date_format(a.datep, '%Y') as year"; |
|
| 86 | -$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a,"; |
|
| 87 | -$sql.= " ".MAIN_DB_PREFIX."user as u"; |
|
| 88 | -$sql.= " WHERE a.fk_user_author = u.rowid"; |
|
| 89 | -$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; |
|
| 83 | +$sql .= " date_format(a.datep, '%m/%Y') as df,"; |
|
| 84 | +$sql .= " date_format(a.datep, '%m') as month,"; |
|
| 85 | +$sql .= " date_format(a.datep, '%Y') as year"; |
|
| 86 | +$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a,"; |
|
| 87 | +$sql .= " ".MAIN_DB_PREFIX."user as u"; |
|
| 88 | +$sql .= " WHERE a.fk_user_author = u.rowid"; |
|
| 89 | +$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; |
|
| 90 | 90 | //$sql.= " AND percent = 100"; |
| 91 | -$sql.= " GROUP BY year, month, df"; |
|
| 92 | -$sql.= " ORDER BY year DESC, month DESC, df DESC"; |
|
| 91 | +$sql .= " GROUP BY year, month, df"; |
|
| 92 | +$sql .= " ORDER BY year DESC, month DESC, df DESC"; |
|
| 93 | 93 | |
| 94 | 94 | $nbtotalofrecords = ''; |
| 95 | 95 | if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) |
@@ -103,17 +103,17 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | -$sql.= $db->plimit($limit+1,$offset); |
|
| 106 | +$sql .= $db->plimit($limit + 1, $offset); |
|
| 107 | 107 | |
| 108 | 108 | //print $sql; |
| 109 | 109 | dol_syslog("select", LOG_DEBUG); |
| 110 | -$resql=$db->query($sql); |
|
| 110 | +$resql = $db->query($sql); |
|
| 111 | 111 | if ($resql) |
| 112 | 112 | { |
| 113 | 113 | $num = $db->num_rows($resql); |
| 114 | 114 | |
| 115 | - $param=''; |
|
| 116 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 115 | + $param = ''; |
|
| 116 | + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; |
|
| 117 | 117 | |
| 118 | 118 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
| 119 | 119 | if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit); |
| 128 | 128 | |
| 129 | - $moreforfilter=''; |
|
| 129 | + $moreforfilter = ''; |
|
| 130 | 130 | |
| 131 | 131 | $i = 0; |
| 132 | 132 | print '<div class="div-table-responsive">'; |
| 133 | - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
| 133 | + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
|
| 134 | 134 | |
| 135 | 135 | print '<tr class="liste_titre">'; |
| 136 | 136 | print '<td>'.$langs->trans("Period").'</td>'; |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | print '<td align="center">'.$langs->trans("Size").'</td>'; |
| 142 | 142 | print "</tr>\n"; |
| 143 | 143 | |
| 144 | - while ($i < min($num,$limit)) |
|
| 144 | + while ($i < min($num, $limit)) |
|
| 145 | 145 | { |
| 146 | - $obj=$db->fetch_object($resql); |
|
| 146 | + $obj = $db->fetch_object($resql); |
|
| 147 | 147 | |
| 148 | 148 | if ($obj) |
| 149 | 149 | { |
@@ -158,37 +158,37 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | // Button to build doc |
| 160 | 160 | print '<td align="center">'; |
| 161 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&page='.$page.'&month='.$obj->month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'),'filenew').'</a>'; |
|
| 161 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&page='.$page.'&month='.$obj->month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>'; |
|
| 162 | 162 | print '</td>'; |
| 163 | 163 | |
| 164 | 164 | $name = "actions-".$obj->month."-".$obj->year.".pdf"; |
| 165 | - $relativepath= $name; |
|
| 165 | + $relativepath = $name; |
|
| 166 | 166 | $file = $conf->agenda->dir_temp."/".$name; |
| 167 | 167 | $modulepart = 'actionsreport'; |
| 168 | - $documenturl= DOL_URL_ROOT.'/document.php'; |
|
| 169 | - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper |
|
| 168 | + $documenturl = DOL_URL_ROOT.'/document.php'; |
|
| 169 | + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper |
|
| 170 | 170 | |
| 171 | 171 | if (file_exists($file)) |
| 172 | 172 | { |
| 173 | 173 | print '<td class="tdoverflowmax300">'; |
| 174 | 174 | //print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&file='.urlencode($relativepath).'&modulepart=actionsreport">'.img_pdf().'</a>'; |
| 175 | 175 | |
| 176 | - $filearray=array('name'=>basename($file),'fullname'=>$file,'type'=>'file'); |
|
| 177 | - $out=''; |
|
| 176 | + $filearray = array('name'=>basename($file), 'fullname'=>$file, 'type'=>'file'); |
|
| 177 | + $out = ''; |
|
| 178 | 178 | |
| 179 | 179 | // Show file name with link to download |
| 180 | - $out.= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"'; |
|
| 181 | - $mime=dol_mimetype($relativepath,'',0); |
|
| 182 | - if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; |
|
| 183 | - $out.= ' target="_blank">'; |
|
| 184 | - $out.= img_mime($filearray["name"],$langs->trans("File").': '.$filearray["name"]); |
|
| 185 | - $out.= $filearray["name"]; |
|
| 186 | - $out.= '</a>'."\n"; |
|
| 187 | - $out.= $formfile->showPreview($filearray,$modulepart,$relativepath,0,$param); |
|
| 180 | + $out .= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"'; |
|
| 181 | + $mime = dol_mimetype($relativepath, '', 0); |
|
| 182 | + if (preg_match('/text/', $mime)) $out .= ' target="_blank"'; |
|
| 183 | + $out .= ' target="_blank">'; |
|
| 184 | + $out .= img_mime($filearray["name"], $langs->trans("File").': '.$filearray["name"]); |
|
| 185 | + $out .= $filearray["name"]; |
|
| 186 | + $out .= '</a>'."\n"; |
|
| 187 | + $out .= $formfile->showPreview($filearray, $modulepart, $relativepath, 0, $param); |
|
| 188 | 188 | print $out; |
| 189 | 189 | |
| 190 | 190 | print '</td>'; |
| 191 | - print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>'; |
|
| 191 | + print '<td align="center">'.dol_print_date(dol_filemtime($file), 'dayhour').'</td>'; |
|
| 192 | 192 | print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>'; |
| 193 | 193 | } |
| 194 | 194 | else { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | // If not choice done on calendar owner, we filter on user. |
| 52 | 52 | if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) |
| 53 | 53 | { |
| 54 | - $filtert=$user->id; |
|
| 54 | + $filtert=$user->id; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $sortfield = GETPOST("sortfield",'alpha'); |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); |
| 104 | 104 | if ($dateselect > 0) |
| 105 | 105 | { |
| 106 | - $day=GETPOST('dateselectday','int'); |
|
| 107 | - $month=GETPOST('dateselectmonth','int'); |
|
| 108 | - $year=GETPOST('dateselectyear','int'); |
|
| 106 | + $day=GETPOST('dateselectday','int'); |
|
| 107 | + $month=GETPOST('dateselectmonth','int'); |
|
| 108 | + $year=GETPOST('dateselectyear','int'); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | $param=''; |
| 204 | 204 | if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { |
| 205 | - if(is_array($actioncode)) { |
|
| 206 | - foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); |
|
| 207 | - } else $param.="&search_actioncode=".urlencode($actioncode); |
|
| 205 | + if(is_array($actioncode)) { |
|
| 206 | + foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); |
|
| 207 | + } else $param.="&search_actioncode=".urlencode($actioncode); |
|
| 208 | 208 | } |
| 209 | 209 | if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); |
| 210 | 210 | if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&search_status=".urlencode($status); |
@@ -308,68 +308,68 @@ discard block |
||
| 308 | 308 | // Legend |
| 309 | 309 | if ($conf->use_javascript_ajax) |
| 310 | 310 | { |
| 311 | - $s=''; |
|
| 312 | - $s.='<script type="text/javascript">' . "\n"; |
|
| 313 | - $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 314 | - $s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n"; |
|
| 315 | - $s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n"; |
|
| 316 | - $s.='jQuery(".family_birthday").toggle();' . "\n"; |
|
| 317 | - if ($action=="show_week" || $action=="show_month" || empty($action)) |
|
| 318 | - { |
|
| 319 | - $s.='jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; |
|
| 320 | - $s.='var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; |
|
| 321 | - } |
|
| 322 | - $s.='});' . "\n"; |
|
| 323 | - $s.='</script>' . "\n"; |
|
| 324 | - if (! empty($conf->use_javascript_ajax)) |
|
| 325 | - { |
|
| 326 | - $s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>'; |
|
| 327 | - if (is_array($showextcals) && count($showextcals) > 0) |
|
| 328 | - { |
|
| 329 | - foreach ($showextcals as $val) |
|
| 330 | - { |
|
| 331 | - $htmlname = md5($val['name']); |
|
| 332 | - $s.='<script type="text/javascript">' . "\n"; |
|
| 333 | - $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 334 | - $s.=' jQuery("#check_ext' . $htmlname . '").click(function() {'; |
|
| 335 | - $s.=' /* alert("'.$htmlname.'"); */'; |
|
| 336 | - $s.=' jQuery(".family_ext' . $htmlname . '").toggle();'; |
|
| 337 | - $s.=' });' . "\n"; |
|
| 338 | - $s.='});' . "\n"; |
|
| 339 | - $s.='</script>' . "\n"; |
|
| 340 | - $s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val ['name'] . ' </div>'; |
|
| 341 | - } |
|
| 342 | - } |
|
| 311 | + $s=''; |
|
| 312 | + $s.='<script type="text/javascript">' . "\n"; |
|
| 313 | + $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 314 | + $s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n"; |
|
| 315 | + $s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n"; |
|
| 316 | + $s.='jQuery(".family_birthday").toggle();' . "\n"; |
|
| 317 | + if ($action=="show_week" || $action=="show_month" || empty($action)) |
|
| 318 | + { |
|
| 319 | + $s.='jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; |
|
| 320 | + $s.='var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; |
|
| 321 | + } |
|
| 322 | + $s.='});' . "\n"; |
|
| 323 | + $s.='</script>' . "\n"; |
|
| 324 | + if (! empty($conf->use_javascript_ajax)) |
|
| 325 | + { |
|
| 326 | + $s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>'; |
|
| 327 | + if (is_array($showextcals) && count($showextcals) > 0) |
|
| 328 | + { |
|
| 329 | + foreach ($showextcals as $val) |
|
| 330 | + { |
|
| 331 | + $htmlname = md5($val['name']); |
|
| 332 | + $s.='<script type="text/javascript">' . "\n"; |
|
| 333 | + $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 334 | + $s.=' jQuery("#check_ext' . $htmlname . '").click(function() {'; |
|
| 335 | + $s.=' /* alert("'.$htmlname.'"); */'; |
|
| 336 | + $s.=' jQuery(".family_ext' . $htmlname . '").toggle();'; |
|
| 337 | + $s.=' });' . "\n"; |
|
| 338 | + $s.='});' . "\n"; |
|
| 339 | + $s.='</script>' . "\n"; |
|
| 340 | + $s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val ['name'] . ' </div>'; |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>'; |
|
| 344 | + //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>'; |
|
| 345 | 345 | |
| 346 | - // Calendars from hooks |
|
| 347 | - $parameters=array(); $object=null; |
|
| 348 | - $reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action); |
|
| 349 | - if (empty($reshook)) |
|
| 350 | - { |
|
| 351 | - $s.= $hookmanager->resPrint; |
|
| 352 | - } |
|
| 353 | - elseif ($reshook > 1) |
|
| 354 | - { |
|
| 355 | - $s = $hookmanager->resPrint; |
|
| 356 | - } |
|
| 357 | - } |
|
| 346 | + // Calendars from hooks |
|
| 347 | + $parameters=array(); $object=null; |
|
| 348 | + $reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action); |
|
| 349 | + if (empty($reshook)) |
|
| 350 | + { |
|
| 351 | + $s.= $hookmanager->resPrint; |
|
| 352 | + } |
|
| 353 | + elseif ($reshook > 1) |
|
| 354 | + { |
|
| 355 | + $s = $hookmanager->resPrint; |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | |
| 361 | 361 | $newcardbutton=''; |
| 362 | 362 | if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) |
| 363 | 363 | { |
| 364 | - $tmpforcreatebutton=dol_getdate(dol_now(), true); |
|
| 364 | + $tmpforcreatebutton=dol_getdate(dol_now(), true); |
|
| 365 | 365 | |
| 366 | - $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; |
|
| 366 | + $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; |
|
| 367 | 367 | |
| 368 | - //$param='month='.$monthshown.'&year='.$year; |
|
| 369 | - $hourminsec='100000'; |
|
| 370 | - $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$tmpforcreatebutton['year'],$tmpforcreatebutton['mon'],$tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'"><span class="valignmiddle">'.$langs->trans("AddAction").'</span>'; |
|
| 371 | - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 372 | - $newcardbutton.= '</a>'; |
|
| 368 | + //$param='month='.$monthshown.'&year='.$year; |
|
| 369 | + $hourminsec='100000'; |
|
| 370 | + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$tmpforcreatebutton['year'],$tmpforcreatebutton['mon'],$tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'"><span class="valignmiddle">'.$langs->trans("AddAction").'</span>'; |
|
| 371 | + $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 372 | + $newcardbutton.= '</a>'; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | $link=''; |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
| 419 | 419 | else |
| 420 | 420 | { |
| 421 | - if (is_array($actioncode)) |
|
| 422 | - { |
|
| 423 | - $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; |
|
| 424 | - } |
|
| 425 | - else |
|
| 426 | - { |
|
| 427 | - $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; |
|
| 428 | - } |
|
| 421 | + if (is_array($actioncode)) |
|
| 422 | + { |
|
| 423 | + $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; |
|
| 424 | + } |
|
| 425 | + else |
|
| 426 | + { |
|
| 427 | + $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; |
|
| 428 | + } |
|
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | } |
@@ -494,8 +494,8 @@ discard block |
||
| 494 | 494 | // Discard auto action if option is on |
| 495 | 495 | if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') |
| 496 | 496 | { |
| 497 | - $i++; |
|
| 498 | - continue; |
|
| 497 | + $i++; |
|
| 498 | + continue; |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | $datep=$db->jdate($obj->datep); |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | else $event->date_end_in_calendar=$datep; |
| 535 | 535 | } |
| 536 | 536 | else |
| 537 | - { |
|
| 537 | + { |
|
| 538 | 538 | $event->date_start_in_calendar=$datep; |
| 539 | 539 | if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
| 540 | 540 | else $event->date_end_in_calendar=$datep; |
@@ -553,11 +553,11 @@ discard block |
||
| 553 | 553 | unset($event); |
| 554 | 554 | } |
| 555 | 555 | else |
| 556 | - { |
|
| 557 | - //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
|
| 558 | - $event->fetch_userassigned(); // This load $event->userassigned |
|
| 556 | + { |
|
| 557 | + //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
|
| 558 | + $event->fetch_userassigned(); // This load $event->userassigned |
|
| 559 | 559 | |
| 560 | - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; |
|
| 560 | + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; |
|
| 561 | 561 | if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); |
| 562 | 562 | |
| 563 | 563 | // Add an entry in actionarray for each day |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | $loop=true; $j=0; |
| 571 | 571 | $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); |
| 572 | 572 | do |
| 573 | - { |
|
| 573 | + { |
|
| 574 | 574 | //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>'; |
| 575 | 575 | |
| 576 | 576 | $eventarray[$daykey][]=$event; |
@@ -632,105 +632,105 @@ discard block |
||
| 632 | 632 | |
| 633 | 633 | while($currentdaytoshow<$lastdaytoshow) { |
| 634 | 634 | |
| 635 | - echo '<table width="100%" class="noborder nocellnopadd cal_month">'; |
|
| 635 | + echo '<table width="100%" class="noborder nocellnopadd cal_month">'; |
|
| 636 | 636 | |
| 637 | - echo '<tr class="liste_titre">'; |
|
| 638 | - echo '<td></td>'; |
|
| 639 | - $i=0; // 0 = sunday, |
|
| 640 | - while ($i < 7) |
|
| 641 | - { |
|
| 642 | - if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
|
| 643 | - { |
|
| 644 | - $i++; |
|
| 645 | - continue; |
|
| 646 | - } |
|
| 647 | - echo '<td align="center" colspan="'.($end_h - $begin_h).'">'; |
|
| 648 | - echo $langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7)); |
|
| 649 | - print "<br>"; |
|
| 650 | - if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'),'day'); |
|
| 651 | - else print dol_print_date($currentdaytoshow,'day'); |
|
| 652 | - echo "</td>\n"; |
|
| 653 | - $i++; |
|
| 654 | - } |
|
| 655 | - echo "</tr>\n"; |
|
| 637 | + echo '<tr class="liste_titre">'; |
|
| 638 | + echo '<td></td>'; |
|
| 639 | + $i=0; // 0 = sunday, |
|
| 640 | + while ($i < 7) |
|
| 641 | + { |
|
| 642 | + if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
|
| 643 | + { |
|
| 644 | + $i++; |
|
| 645 | + continue; |
|
| 646 | + } |
|
| 647 | + echo '<td align="center" colspan="'.($end_h - $begin_h).'">'; |
|
| 648 | + echo $langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7)); |
|
| 649 | + print "<br>"; |
|
| 650 | + if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'),'day'); |
|
| 651 | + else print dol_print_date($currentdaytoshow,'day'); |
|
| 652 | + echo "</td>\n"; |
|
| 653 | + $i++; |
|
| 654 | + } |
|
| 655 | + echo "</tr>\n"; |
|
| 656 | 656 | |
| 657 | - echo '<tr class="liste_titre">'; |
|
| 658 | - echo '<td></td>'; |
|
| 659 | - $i=0; |
|
| 660 | - while ($i < 7) |
|
| 661 | - { |
|
| 662 | - if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
|
| 663 | - { |
|
| 664 | - $i++; |
|
| 665 | - continue; |
|
| 666 | - } |
|
| 667 | - for ($h = $begin_h; $h < $end_h; $h++) |
|
| 668 | - { |
|
| 669 | - echo '<td align="center">'; |
|
| 670 | - print '<small style="font-family: courier">'.sprintf("%02d",$h).'</small>'; |
|
| 671 | - print "</td>"; |
|
| 672 | - } |
|
| 673 | - echo "</td>\n"; |
|
| 674 | - $i++; |
|
| 675 | - } |
|
| 676 | - echo "</tr>\n"; |
|
| 657 | + echo '<tr class="liste_titre">'; |
|
| 658 | + echo '<td></td>'; |
|
| 659 | + $i=0; |
|
| 660 | + while ($i < 7) |
|
| 661 | + { |
|
| 662 | + if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
|
| 663 | + { |
|
| 664 | + $i++; |
|
| 665 | + continue; |
|
| 666 | + } |
|
| 667 | + for ($h = $begin_h; $h < $end_h; $h++) |
|
| 668 | + { |
|
| 669 | + echo '<td align="center">'; |
|
| 670 | + print '<small style="font-family: courier">'.sprintf("%02d",$h).'</small>'; |
|
| 671 | + print "</td>"; |
|
| 672 | + } |
|
| 673 | + echo "</td>\n"; |
|
| 674 | + $i++; |
|
| 675 | + } |
|
| 676 | + echo "</tr>\n"; |
|
| 677 | 677 | |
| 678 | 678 | |
| 679 | - // Define $usernames |
|
| 680 | - $usernames = array(); //init |
|
| 681 | - $usernamesid = array(); |
|
| 682 | - /* Use this to have list of users only if users have events */ |
|
| 683 | - if (! empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW)) |
|
| 684 | - { |
|
| 685 | - foreach ($eventarray as $daykey => $notused) |
|
| 686 | - { |
|
| 687 | - // Get all assigned users for each event |
|
| 688 | - foreach ($eventarray[$daykey] as $index => $event) |
|
| 689 | - { |
|
| 690 | - $event->fetch_userassigned(); |
|
| 691 | - $listofuserid=$event->userassigned; |
|
| 692 | - foreach($listofuserid as $userid => $tmp) |
|
| 693 | - { |
|
| 694 | - if (! in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; |
|
| 695 | - } |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - } |
|
| 699 | - /* Use this list to have for all users */ |
|
| 700 | - else |
|
| 701 | - { |
|
| 702 | - $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; |
|
| 703 | - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; |
|
| 704 | - if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; |
|
| 705 | - $sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; |
|
| 706 | - if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup; |
|
| 707 | - //print $sql; |
|
| 708 | - $resql=$db->query($sql); |
|
| 709 | - if ($resql) |
|
| 710 | - { |
|
| 711 | - $num = $db->num_rows($resql); |
|
| 712 | - $i = 0; |
|
| 713 | - if ($num) |
|
| 714 | - { |
|
| 715 | - while ($i < $num) |
|
| 716 | - { |
|
| 717 | - $obj = $db->fetch_object($resql); |
|
| 718 | - $usernamesid[$obj->rowid]=$obj->rowid; |
|
| 719 | - $i++; |
|
| 720 | - } |
|
| 721 | - } |
|
| 722 | - } |
|
| 723 | - else dol_print_error($db); |
|
| 724 | - } |
|
| 725 | - //var_dump($usernamesid); |
|
| 726 | - foreach($usernamesid as $id) |
|
| 727 | - { |
|
| 728 | - $tmpuser=new User($db); |
|
| 729 | - $result=$tmpuser->fetch($id); |
|
| 730 | - $usernames[]=$tmpuser; |
|
| 731 | - } |
|
| 679 | + // Define $usernames |
|
| 680 | + $usernames = array(); //init |
|
| 681 | + $usernamesid = array(); |
|
| 682 | + /* Use this to have list of users only if users have events */ |
|
| 683 | + if (! empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW)) |
|
| 684 | + { |
|
| 685 | + foreach ($eventarray as $daykey => $notused) |
|
| 686 | + { |
|
| 687 | + // Get all assigned users for each event |
|
| 688 | + foreach ($eventarray[$daykey] as $index => $event) |
|
| 689 | + { |
|
| 690 | + $event->fetch_userassigned(); |
|
| 691 | + $listofuserid=$event->userassigned; |
|
| 692 | + foreach($listofuserid as $userid => $tmp) |
|
| 693 | + { |
|
| 694 | + if (! in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; |
|
| 695 | + } |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + } |
|
| 699 | + /* Use this list to have for all users */ |
|
| 700 | + else |
|
| 701 | + { |
|
| 702 | + $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; |
|
| 703 | + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; |
|
| 704 | + if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; |
|
| 705 | + $sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; |
|
| 706 | + if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup; |
|
| 707 | + //print $sql; |
|
| 708 | + $resql=$db->query($sql); |
|
| 709 | + if ($resql) |
|
| 710 | + { |
|
| 711 | + $num = $db->num_rows($resql); |
|
| 712 | + $i = 0; |
|
| 713 | + if ($num) |
|
| 714 | + { |
|
| 715 | + while ($i < $num) |
|
| 716 | + { |
|
| 717 | + $obj = $db->fetch_object($resql); |
|
| 718 | + $usernamesid[$obj->rowid]=$obj->rowid; |
|
| 719 | + $i++; |
|
| 720 | + } |
|
| 721 | + } |
|
| 722 | + } |
|
| 723 | + else dol_print_error($db); |
|
| 724 | + } |
|
| 725 | + //var_dump($usernamesid); |
|
| 726 | + foreach($usernamesid as $id) |
|
| 727 | + { |
|
| 728 | + $tmpuser=new User($db); |
|
| 729 | + $result=$tmpuser->fetch($id); |
|
| 730 | + $usernames[]=$tmpuser; |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | - /* |
|
| 733 | + /* |
|
| 734 | 734 | if ($filtert > 0) |
| 735 | 735 | { |
| 736 | 736 | $tmpuser = new User($db); |
@@ -750,90 +750,90 @@ discard block |
||
| 750 | 750 | $usernames = $tmpgroup->listUsersForGroup(); |
| 751 | 751 | }*/ |
| 752 | 752 | |
| 753 | - // Load array of colors by type |
|
| 754 | - $colorsbytype=array(); |
|
| 755 | - $labelbytype=array(); |
|
| 756 | - $sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; |
|
| 757 | - $resql=$db->query($sql); |
|
| 758 | - while ($obj = $db->fetch_object($resql)) |
|
| 759 | - { |
|
| 760 | - $colorsbytype[$obj->code]=$obj->color; |
|
| 761 | - $labelbytype[$obj->code]=$obj->libelle; |
|
| 762 | - } |
|
| 753 | + // Load array of colors by type |
|
| 754 | + $colorsbytype=array(); |
|
| 755 | + $labelbytype=array(); |
|
| 756 | + $sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; |
|
| 757 | + $resql=$db->query($sql); |
|
| 758 | + while ($obj = $db->fetch_object($resql)) |
|
| 759 | + { |
|
| 760 | + $colorsbytype[$obj->code]=$obj->color; |
|
| 761 | + $labelbytype[$obj->code]=$obj->libelle; |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | - // Loop on each user to show calendar |
|
| 765 | - $todayarray=dol_getdate($now,'fast'); |
|
| 766 | - $sav = $tmpday; |
|
| 767 | - $showheader = true; |
|
| 768 | - $var = false; |
|
| 769 | - foreach ($usernames as $username) |
|
| 770 | - { |
|
| 771 | - $var = ! $var; |
|
| 772 | - echo "<tr>"; |
|
| 773 | - echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">'; |
|
| 774 | - print $username->getNomUrl(-1,'',0,0,20,1,''); |
|
| 775 | - print '</td>'; |
|
| 776 | - $tmpday = $sav; |
|
| 777 | - |
|
| 778 | - // Lopp on each day of week |
|
| 779 | - $i = 0; |
|
| 780 | - for ($iter_day = 0; $iter_day < 8; $iter_day++) |
|
| 781 | - { |
|
| 764 | + // Loop on each user to show calendar |
|
| 765 | + $todayarray=dol_getdate($now,'fast'); |
|
| 766 | + $sav = $tmpday; |
|
| 767 | + $showheader = true; |
|
| 768 | + $var = false; |
|
| 769 | + foreach ($usernames as $username) |
|
| 770 | + { |
|
| 771 | + $var = ! $var; |
|
| 772 | + echo "<tr>"; |
|
| 773 | + echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">'; |
|
| 774 | + print $username->getNomUrl(-1,'',0,0,20,1,''); |
|
| 775 | + print '</td>'; |
|
| 776 | + $tmpday = $sav; |
|
| 777 | + |
|
| 778 | + // Lopp on each day of week |
|
| 779 | + $i = 0; |
|
| 780 | + for ($iter_day = 0; $iter_day < 8; $iter_day++) |
|
| 781 | + { |
|
| 782 | 782 | |
| 783 | - if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
|
| 784 | - { |
|
| 785 | - $i++; |
|
| 786 | - continue; |
|
| 787 | - } |
|
| 783 | + if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
|
| 784 | + { |
|
| 785 | + $i++; |
|
| 786 | + continue; |
|
| 787 | + } |
|
| 788 | 788 | |
| 789 | - // Show days of the current week |
|
| 790 | - $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd'); |
|
| 791 | - $tmparray = dol_getdate($curtime,'fast'); |
|
| 792 | - $tmpday = $tmparray['mday']; |
|
| 793 | - $tmpmonth = $tmparray['mon']; |
|
| 794 | - $tmpyear = $tmparray['year']; |
|
| 789 | + // Show days of the current week |
|
| 790 | + $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd'); |
|
| 791 | + $tmparray = dol_getdate($curtime,'fast'); |
|
| 792 | + $tmpday = $tmparray['mday']; |
|
| 793 | + $tmpmonth = $tmparray['mon']; |
|
| 794 | + $tmpyear = $tmparray['year']; |
|
| 795 | 795 | |
| 796 | - $style='cal_current_month'; |
|
| 797 | - if ($iter_day == 6) $style.=' cal_other_month'; |
|
| 798 | - $today=0; |
|
| 799 | - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; |
|
| 800 | - if ($today) $style='cal_today_peruser'; |
|
| 796 | + $style='cal_current_month'; |
|
| 797 | + if ($iter_day == 6) $style.=' cal_other_month'; |
|
| 798 | + $today=0; |
|
| 799 | + if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; |
|
| 800 | + if ($today) $style='cal_today_peruser'; |
|
| 801 | 801 | |
| 802 | - show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
|
| 802 | + show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
|
| 803 | 803 | |
| 804 | - $i++; |
|
| 805 | - } |
|
| 806 | - echo "</tr>\n"; |
|
| 807 | - $showheader = false; |
|
| 808 | - } |
|
| 804 | + $i++; |
|
| 805 | + } |
|
| 806 | + echo "</tr>\n"; |
|
| 807 | + $showheader = false; |
|
| 808 | + } |
|
| 809 | 809 | |
| 810 | - echo "</table>\n"; |
|
| 811 | - echo "<br>"; |
|
| 810 | + echo "</table>\n"; |
|
| 811 | + echo "<br>"; |
|
| 812 | 812 | |
| 813 | - $currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd'); |
|
| 813 | + $currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd'); |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | echo '</div>'; |
| 817 | 817 | |
| 818 | 818 | if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) |
| 819 | 819 | { |
| 820 | - $langs->load("commercial"); |
|
| 821 | - print '<br>'.$langs->trans("Legend").': <br>'; |
|
| 822 | - foreach($colorsbytype as $code => $color) |
|
| 823 | - { |
|
| 824 | - if ($color) |
|
| 825 | - { |
|
| 826 | - print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color?'background: #'.$color.';':'').'width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 827 | - print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code]; |
|
| 828 | - //print $code; |
|
| 829 | - print '</div>'; |
|
| 830 | - } |
|
| 831 | - } |
|
| 832 | - //$color=sprintf("%02x%02x%02x",$theme_datacolor[0][0],$theme_datacolor[0][1],$theme_datacolor[0][2]); |
|
| 833 | - print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 834 | - print $langs->trans("Other"); |
|
| 835 | - print '</div>'; |
|
| 836 | - /* TODO Show this if at least one cumulated event |
|
| 820 | + $langs->load("commercial"); |
|
| 821 | + print '<br>'.$langs->trans("Legend").': <br>'; |
|
| 822 | + foreach($colorsbytype as $code => $color) |
|
| 823 | + { |
|
| 824 | + if ($color) |
|
| 825 | + { |
|
| 826 | + print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color?'background: #'.$color.';':'').'width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 827 | + print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code]; |
|
| 828 | + //print $code; |
|
| 829 | + print '</div>'; |
|
| 830 | + } |
|
| 831 | + } |
|
| 832 | + //$color=sprintf("%02x%02x%02x",$theme_datacolor[0][0],$theme_datacolor[0][1],$theme_datacolor[0][2]); |
|
| 833 | + print '<div style="float: left; padding: 2px; margin-right: 6px;"><div class="peruser_busy" style="width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 834 | + print $langs->trans("Other"); |
|
| 835 | + print '</div>'; |
|
| 836 | + /* TODO Show this if at least one cumulated event |
|
| 837 | 837 | print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="background: #222222; width:16px; float: left; margin-right: 4px;"> </div>'; |
| 838 | 838 | print $langs->trans("SeveralEvents"); |
| 839 | 839 | print '</div>'; |
@@ -907,341 +907,341 @@ discard block |
||
| 907 | 907 | */ |
| 908 | 908 | function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false) |
| 909 | 909 | { |
| 910 | - global $db; |
|
| 911 | - global $user, $conf, $langs, $hookmanager, $action; |
|
| 912 | - global $filter, $filtert, $status, $actioncode; // Filters used into search form |
|
| 913 | - global $theme_datacolor; // Array with a list of different we can use (come from theme) |
|
| 914 | - global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused; |
|
| 915 | - global $begin_h, $end_h; |
|
| 910 | + global $db; |
|
| 911 | + global $user, $conf, $langs, $hookmanager, $action; |
|
| 912 | + global $filter, $filtert, $status, $actioncode; // Filters used into search form |
|
| 913 | + global $theme_datacolor; // Array with a list of different we can use (come from theme) |
|
| 914 | + global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused; |
|
| 915 | + global $begin_h, $end_h; |
|
| 916 | 916 | |
| 917 | - $cases1 = array(); // Color first half hour |
|
| 918 | - $cases2 = array(); // Color second half hour |
|
| 917 | + $cases1 = array(); // Color first half hour |
|
| 918 | + $cases2 = array(); // Color second half hour |
|
| 919 | 919 | |
| 920 | - $curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0); |
|
| 920 | + $curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0); |
|
| 921 | 921 | |
| 922 | - $i=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); |
|
| 923 | - $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); |
|
| 922 | + $i=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); |
|
| 923 | + $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); |
|
| 924 | 924 | |
| 925 | - $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 |
|
| 926 | - $nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... |
|
| 927 | - //if ($username->id && $day==1) var_dump($eventarray); |
|
| 925 | + $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 |
|
| 926 | + $nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... |
|
| 927 | + //if ($username->id && $day==1) var_dump($eventarray); |
|
| 928 | 928 | |
| 929 | - // We are in a particular day for $username, now we scan all events |
|
| 930 | - foreach ($eventarray as $daykey => $notused) |
|
| 931 | - { |
|
| 932 | - $annee = date('Y',$daykey); |
|
| 933 | - $mois = date('m',$daykey); |
|
| 934 | - $jour = date('d',$daykey); |
|
| 935 | - //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n"; |
|
| 929 | + // We are in a particular day for $username, now we scan all events |
|
| 930 | + foreach ($eventarray as $daykey => $notused) |
|
| 931 | + { |
|
| 932 | + $annee = date('Y',$daykey); |
|
| 933 | + $mois = date('m',$daykey); |
|
| 934 | + $jour = date('d',$daykey); |
|
| 935 | + //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n"; |
|
| 936 | 936 | |
| 937 | - if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? |
|
| 938 | - { |
|
| 939 | - // Scan all event for this date |
|
| 940 | - foreach ($eventarray[$daykey] as $index => $event) |
|
| 941 | - { |
|
| 942 | - //var_dump($event); |
|
| 943 | - |
|
| 944 | - $keysofuserassigned=array_keys($event->userassigned); |
|
| 945 | - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); |
|
| 946 | - |
|
| 947 | - if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 948 | - //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
|
| 949 | - |
|
| 950 | - $parameters=array(); |
|
| 951 | - $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks |
|
| 952 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 953 | - |
|
| 954 | - // Define $color (Hex string like '0088FF') and $cssclass of event |
|
| 955 | - $color=-1; $cssclass=''; $colorindex=-1; |
|
| 956 | - if (in_array($user->id, $keysofuserassigned)) |
|
| 957 | - { |
|
| 958 | - $cssclass='family_mytasks'; |
|
| 959 | - |
|
| 960 | - if (empty($cacheusers[$event->userownerid])) |
|
| 961 | - { |
|
| 962 | - $newuser=new User($db); |
|
| 963 | - $newuser->fetch($event->userownerid); |
|
| 964 | - $cacheusers[$event->userownerid]=$newuser; |
|
| 965 | - } |
|
| 966 | - //var_dump($cacheusers[$event->userownerid]->color); |
|
| 967 | - |
|
| 968 | - // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
|
| 969 | - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; |
|
| 970 | - |
|
| 971 | - if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; |
|
| 972 | - } |
|
| 973 | - else if ($event->type_code == 'ICALEVENT') |
|
| 974 | - { |
|
| 975 | - $numical++; |
|
| 976 | - if (! empty($event->icalname)) |
|
| 977 | - { |
|
| 978 | - if (! isset($numicals[dol_string_nospecial($event->icalname)])) { |
|
| 979 | - $numicals[dol_string_nospecial($event->icalname)] = 0; |
|
| 980 | - } |
|
| 981 | - $numicals[dol_string_nospecial($event->icalname)]++; |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - $color=$event->icalcolor; |
|
| 985 | - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); |
|
| 986 | - } |
|
| 987 | - else if ($event->type_code == 'BIRTHDAY') |
|
| 988 | - { |
|
| 989 | - $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 990 | - } |
|
| 991 | - else |
|
| 992 | - { |
|
| 993 | - $numother++; |
|
| 994 | - $color=($event->icalcolor?$event->icalcolor:-1); |
|
| 995 | - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other'); |
|
| 996 | - |
|
| 997 | - if (empty($cacheusers[$event->userownerid])) |
|
| 998 | - { |
|
| 999 | - $newuser=new User($db); |
|
| 1000 | - $newuser->fetch($event->userownerid); |
|
| 1001 | - $cacheusers[$event->userownerid]=$newuser; |
|
| 1002 | - } |
|
| 1003 | - //var_dump($cacheusers[$event->userownerid]->color); |
|
| 1004 | - |
|
| 1005 | - // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
|
| 1006 | - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; |
|
| 1007 | - |
|
| 1008 | - if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - if ($color < 0) // Color was not set on user card. Set color according to color index. |
|
| 1012 | - { |
|
| 1013 | - // Define color index if not yet defined |
|
| 1014 | - $idusertouse=($event->userownerid?$event->userownerid:0); |
|
| 1015 | - if (isset($colorindexused[$idusertouse])) |
|
| 1016 | - { |
|
| 1017 | - $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user |
|
| 1018 | - } |
|
| 1019 | - else |
|
| 1020 | - { |
|
| 1021 | - $colorindex=$nextindextouse; |
|
| 1022 | - $colorindexused[$idusertouse]=$colorindex; |
|
| 1023 | - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color |
|
| 1024 | - } |
|
| 1025 | - // Define color |
|
| 1026 | - $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 1027 | - } |
|
| 1028 | - //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; |
|
| 1029 | - |
|
| 1030 | - // Define all rects with event (cases1 is first half hour, cases2 is second half hour) |
|
| 1031 | - for ($h = $begin_h; $h < $end_h; $h++) |
|
| 1032 | - { |
|
| 1033 | - //if ($username->id == 1 && $day==1) print 'h='.$h; |
|
| 1034 | - $newcolor = ''; //init |
|
| 1035 | - if (empty($event->fulldayevent)) |
|
| 1036 | - { |
|
| 1037 | - $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0); |
|
| 1038 | - $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0); |
|
| 1039 | - $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); |
|
| 1040 | - |
|
| 1041 | - $dateendtouse=$event->date_end_in_calendar; |
|
| 1042 | - if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; |
|
| 1043 | - |
|
| 1044 | - //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
|
| 1045 | - |
|
| 1046 | - if ($event->date_start_in_calendar < $b && $dateendtouse > $a) |
|
| 1047 | - { |
|
| 1048 | - $busy=$event->transparency; |
|
| 1049 | - $cases1[$h][$event->id]['busy']=$busy; |
|
| 1050 | - $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 1051 | - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
|
| 1052 | - { |
|
| 1053 | - $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 1054 | - $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 1055 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1056 | - else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1057 | - } |
|
| 1058 | - if ($event->label) $cases1[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1059 | - $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 1060 | - $cases1[$h][$event->id]['color']=$color; |
|
| 1061 | - if ($event->fk_project > 0) |
|
| 1062 | - { |
|
| 1063 | - if (empty($cacheprojects[$event->fk_project])) |
|
| 1064 | - { |
|
| 1065 | - $tmpproj=new Project($db); |
|
| 1066 | - $tmpproj->fetch($event->fk_project); |
|
| 1067 | - $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 1068 | - } |
|
| 1069 | - $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 1070 | - } |
|
| 1071 | - if ($event->socid > 0) |
|
| 1072 | - { |
|
| 1073 | - if (empty($cachethirdparties[$event->socid])) |
|
| 1074 | - { |
|
| 1075 | - $tmpthirdparty=new Societe($db); |
|
| 1076 | - $tmpthirdparty->fetch($event->socid); |
|
| 1077 | - $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 1078 | - } |
|
| 1079 | - $cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 1080 | - } |
|
| 1081 | - if ($event->contactid > 0) |
|
| 1082 | - { |
|
| 1083 | - if (empty($cachecontacts[$event->contactid])) |
|
| 1084 | - { |
|
| 1085 | - $tmpcontact=new Contact($db); |
|
| 1086 | - $tmpcontact->fetch($event->contactid); |
|
| 1087 | - $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 1088 | - } |
|
| 1089 | - $cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 1090 | - } |
|
| 1091 | - } |
|
| 1092 | - if ($event->date_start_in_calendar < $c && $dateendtouse > $b) |
|
| 1093 | - { |
|
| 1094 | - $busy=$event->transparency; |
|
| 1095 | - $cases2[$h][$event->id]['busy']=$busy; |
|
| 1096 | - $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 1097 | - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
|
| 1098 | - { |
|
| 1099 | - $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 1100 | - $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 1101 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1102 | - else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1103 | - } |
|
| 1104 | - if ($event->label) $cases2[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1105 | - $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 1106 | - $cases2[$h][$event->id]['color']=$color; |
|
| 1107 | - if ($event->fk_project > 0) |
|
| 1108 | - { |
|
| 1109 | - if (empty($cacheprojects[$event->fk_project])) |
|
| 1110 | - { |
|
| 1111 | - $tmpproj=new Project($db); |
|
| 1112 | - $tmpproj->fetch($event->fk_project); |
|
| 1113 | - $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 1114 | - } |
|
| 1115 | - $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 1116 | - } |
|
| 1117 | - if ($event->socid > 0) |
|
| 1118 | - { |
|
| 1119 | - if (empty($cachethirdparties[$event->socid])) |
|
| 1120 | - { |
|
| 1121 | - $tmpthirdparty=new Societe($db); |
|
| 1122 | - $tmpthirdparty->fetch($event->socid); |
|
| 1123 | - $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 1124 | - } |
|
| 1125 | - $cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 1126 | - } |
|
| 1127 | - if ($event->contactid > 0) |
|
| 1128 | - { |
|
| 1129 | - if (empty($cachecontacts[$event->contactid])) |
|
| 1130 | - { |
|
| 1131 | - $tmpcontact=new Contact($db); |
|
| 1132 | - $tmpcontact->fetch($event->contactid); |
|
| 1133 | - $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 1134 | - } |
|
| 1135 | - $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 1136 | - } |
|
| 1137 | - } |
|
| 1138 | - } |
|
| 1139 | - else |
|
| 1140 | - { |
|
| 1141 | - $busy=$event->transparency; |
|
| 1142 | - $cases1[$h][$event->id]['busy']=$busy; |
|
| 1143 | - $cases2[$h][$event->id]['busy']=$busy; |
|
| 1144 | - $cases1[$h][$event->id]['string']=$event->label; |
|
| 1145 | - $cases2[$h][$event->id]['string']=$event->label; |
|
| 1146 | - $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 1147 | - $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 1148 | - $cases1[$h][$event->id]['color']=$color; |
|
| 1149 | - $cases2[$h][$event->id]['color']=$color; |
|
| 1150 | - } |
|
| 1151 | - } |
|
| 1152 | - $i++; |
|
| 1153 | - } |
|
| 1154 | - |
|
| 1155 | - break; // We found the date we were looking for. No need to search anymore. |
|
| 1156 | - } |
|
| 1157 | - } |
|
| 937 | + if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? |
|
| 938 | + { |
|
| 939 | + // Scan all event for this date |
|
| 940 | + foreach ($eventarray[$daykey] as $index => $event) |
|
| 941 | + { |
|
| 942 | + //var_dump($event); |
|
| 943 | + |
|
| 944 | + $keysofuserassigned=array_keys($event->userassigned); |
|
| 945 | + $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); |
|
| 946 | + |
|
| 947 | + if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 948 | + //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
|
| 949 | + |
|
| 950 | + $parameters=array(); |
|
| 951 | + $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks |
|
| 952 | + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 953 | + |
|
| 954 | + // Define $color (Hex string like '0088FF') and $cssclass of event |
|
| 955 | + $color=-1; $cssclass=''; $colorindex=-1; |
|
| 956 | + if (in_array($user->id, $keysofuserassigned)) |
|
| 957 | + { |
|
| 958 | + $cssclass='family_mytasks'; |
|
| 959 | + |
|
| 960 | + if (empty($cacheusers[$event->userownerid])) |
|
| 961 | + { |
|
| 962 | + $newuser=new User($db); |
|
| 963 | + $newuser->fetch($event->userownerid); |
|
| 964 | + $cacheusers[$event->userownerid]=$newuser; |
|
| 965 | + } |
|
| 966 | + //var_dump($cacheusers[$event->userownerid]->color); |
|
| 967 | + |
|
| 968 | + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
|
| 969 | + if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; |
|
| 970 | + |
|
| 971 | + if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; |
|
| 972 | + } |
|
| 973 | + else if ($event->type_code == 'ICALEVENT') |
|
| 974 | + { |
|
| 975 | + $numical++; |
|
| 976 | + if (! empty($event->icalname)) |
|
| 977 | + { |
|
| 978 | + if (! isset($numicals[dol_string_nospecial($event->icalname)])) { |
|
| 979 | + $numicals[dol_string_nospecial($event->icalname)] = 0; |
|
| 980 | + } |
|
| 981 | + $numicals[dol_string_nospecial($event->icalname)]++; |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + $color=$event->icalcolor; |
|
| 985 | + $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); |
|
| 986 | + } |
|
| 987 | + else if ($event->type_code == 'BIRTHDAY') |
|
| 988 | + { |
|
| 989 | + $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 990 | + } |
|
| 991 | + else |
|
| 992 | + { |
|
| 993 | + $numother++; |
|
| 994 | + $color=($event->icalcolor?$event->icalcolor:-1); |
|
| 995 | + $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other'); |
|
| 996 | + |
|
| 997 | + if (empty($cacheusers[$event->userownerid])) |
|
| 998 | + { |
|
| 999 | + $newuser=new User($db); |
|
| 1000 | + $newuser->fetch($event->userownerid); |
|
| 1001 | + $cacheusers[$event->userownerid]=$newuser; |
|
| 1002 | + } |
|
| 1003 | + //var_dump($cacheusers[$event->userownerid]->color); |
|
| 1004 | + |
|
| 1005 | + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
|
| 1006 | + if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; |
|
| 1007 | + |
|
| 1008 | + if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + if ($color < 0) // Color was not set on user card. Set color according to color index. |
|
| 1012 | + { |
|
| 1013 | + // Define color index if not yet defined |
|
| 1014 | + $idusertouse=($event->userownerid?$event->userownerid:0); |
|
| 1015 | + if (isset($colorindexused[$idusertouse])) |
|
| 1016 | + { |
|
| 1017 | + $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user |
|
| 1018 | + } |
|
| 1019 | + else |
|
| 1020 | + { |
|
| 1021 | + $colorindex=$nextindextouse; |
|
| 1022 | + $colorindexused[$idusertouse]=$colorindex; |
|
| 1023 | + if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color |
|
| 1024 | + } |
|
| 1025 | + // Define color |
|
| 1026 | + $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 1027 | + } |
|
| 1028 | + //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; |
|
| 1029 | + |
|
| 1030 | + // Define all rects with event (cases1 is first half hour, cases2 is second half hour) |
|
| 1031 | + for ($h = $begin_h; $h < $end_h; $h++) |
|
| 1032 | + { |
|
| 1033 | + //if ($username->id == 1 && $day==1) print 'h='.$h; |
|
| 1034 | + $newcolor = ''; //init |
|
| 1035 | + if (empty($event->fulldayevent)) |
|
| 1036 | + { |
|
| 1037 | + $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0); |
|
| 1038 | + $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0); |
|
| 1039 | + $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); |
|
| 1040 | + |
|
| 1041 | + $dateendtouse=$event->date_end_in_calendar; |
|
| 1042 | + if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; |
|
| 1043 | + |
|
| 1044 | + //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
|
| 1045 | + |
|
| 1046 | + if ($event->date_start_in_calendar < $b && $dateendtouse > $a) |
|
| 1047 | + { |
|
| 1048 | + $busy=$event->transparency; |
|
| 1049 | + $cases1[$h][$event->id]['busy']=$busy; |
|
| 1050 | + $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 1051 | + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
|
| 1052 | + { |
|
| 1053 | + $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 1054 | + $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 1055 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1056 | + else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1057 | + } |
|
| 1058 | + if ($event->label) $cases1[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1059 | + $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 1060 | + $cases1[$h][$event->id]['color']=$color; |
|
| 1061 | + if ($event->fk_project > 0) |
|
| 1062 | + { |
|
| 1063 | + if (empty($cacheprojects[$event->fk_project])) |
|
| 1064 | + { |
|
| 1065 | + $tmpproj=new Project($db); |
|
| 1066 | + $tmpproj->fetch($event->fk_project); |
|
| 1067 | + $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 1068 | + } |
|
| 1069 | + $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 1070 | + } |
|
| 1071 | + if ($event->socid > 0) |
|
| 1072 | + { |
|
| 1073 | + if (empty($cachethirdparties[$event->socid])) |
|
| 1074 | + { |
|
| 1075 | + $tmpthirdparty=new Societe($db); |
|
| 1076 | + $tmpthirdparty->fetch($event->socid); |
|
| 1077 | + $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 1078 | + } |
|
| 1079 | + $cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 1080 | + } |
|
| 1081 | + if ($event->contactid > 0) |
|
| 1082 | + { |
|
| 1083 | + if (empty($cachecontacts[$event->contactid])) |
|
| 1084 | + { |
|
| 1085 | + $tmpcontact=new Contact($db); |
|
| 1086 | + $tmpcontact->fetch($event->contactid); |
|
| 1087 | + $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 1088 | + } |
|
| 1089 | + $cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 1090 | + } |
|
| 1091 | + } |
|
| 1092 | + if ($event->date_start_in_calendar < $c && $dateendtouse > $b) |
|
| 1093 | + { |
|
| 1094 | + $busy=$event->transparency; |
|
| 1095 | + $cases2[$h][$event->id]['busy']=$busy; |
|
| 1096 | + $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 1097 | + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
|
| 1098 | + { |
|
| 1099 | + $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 1100 | + $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 1101 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1102 | + else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1103 | + } |
|
| 1104 | + if ($event->label) $cases2[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1105 | + $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 1106 | + $cases2[$h][$event->id]['color']=$color; |
|
| 1107 | + if ($event->fk_project > 0) |
|
| 1108 | + { |
|
| 1109 | + if (empty($cacheprojects[$event->fk_project])) |
|
| 1110 | + { |
|
| 1111 | + $tmpproj=new Project($db); |
|
| 1112 | + $tmpproj->fetch($event->fk_project); |
|
| 1113 | + $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 1114 | + } |
|
| 1115 | + $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 1116 | + } |
|
| 1117 | + if ($event->socid > 0) |
|
| 1118 | + { |
|
| 1119 | + if (empty($cachethirdparties[$event->socid])) |
|
| 1120 | + { |
|
| 1121 | + $tmpthirdparty=new Societe($db); |
|
| 1122 | + $tmpthirdparty->fetch($event->socid); |
|
| 1123 | + $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 1124 | + } |
|
| 1125 | + $cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 1126 | + } |
|
| 1127 | + if ($event->contactid > 0) |
|
| 1128 | + { |
|
| 1129 | + if (empty($cachecontacts[$event->contactid])) |
|
| 1130 | + { |
|
| 1131 | + $tmpcontact=new Contact($db); |
|
| 1132 | + $tmpcontact->fetch($event->contactid); |
|
| 1133 | + $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 1134 | + } |
|
| 1135 | + $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 1136 | + } |
|
| 1137 | + } |
|
| 1138 | + } |
|
| 1139 | + else |
|
| 1140 | + { |
|
| 1141 | + $busy=$event->transparency; |
|
| 1142 | + $cases1[$h][$event->id]['busy']=$busy; |
|
| 1143 | + $cases2[$h][$event->id]['busy']=$busy; |
|
| 1144 | + $cases1[$h][$event->id]['string']=$event->label; |
|
| 1145 | + $cases2[$h][$event->id]['string']=$event->label; |
|
| 1146 | + $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 1147 | + $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 1148 | + $cases1[$h][$event->id]['color']=$color; |
|
| 1149 | + $cases2[$h][$event->id]['color']=$color; |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1152 | + $i++; |
|
| 1153 | + } |
|
| 1158 | 1154 | |
| 1159 | - // Now output $casesX |
|
| 1160 | - for ($h = $begin_h; $h < $end_h; $h++) |
|
| 1161 | - { |
|
| 1162 | - $color1='';$color2=''; |
|
| 1163 | - $style1='';$style2=''; |
|
| 1164 | - $string1=' ';$string2=' '; |
|
| 1165 | - $title1='';$title2=''; |
|
| 1166 | - if (isset($cases1[$h]) && $cases1[$h] != '') |
|
| 1167 | - { |
|
| 1168 | - //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1169 | - if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1170 | - $string1=' '; |
|
| 1171 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; |
|
| 1172 | - else $style1='peruser_busy'; |
|
| 1173 | - foreach($cases1[$h] as $id => $ev) |
|
| 1174 | - { |
|
| 1175 | - if ($ev['busy']) $style1='peruser_busy'; |
|
| 1176 | - } |
|
| 1177 | - } |
|
| 1178 | - if (isset($cases2[$h]) && $cases2[$h] != '') |
|
| 1179 | - { |
|
| 1180 | - //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1181 | - if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1182 | - $string2=' '; |
|
| 1183 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; |
|
| 1184 | - else $style2='peruser_busy'; |
|
| 1185 | - foreach($cases2[$h] as $id => $ev) |
|
| 1186 | - { |
|
| 1187 | - if ($ev['busy']) $style2='peruser_busy'; |
|
| 1188 | - } |
|
| 1189 | - } |
|
| 1155 | + break; // We found the date we were looking for. No need to search anymore. |
|
| 1156 | + } |
|
| 1157 | + } |
|
| 1190 | 1158 | |
| 1191 | - $ids1='';$ids2=''; |
|
| 1192 | - if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h])); |
|
| 1193 | - if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h])); |
|
| 1159 | + // Now output $casesX |
|
| 1160 | + for ($h = $begin_h; $h < $end_h; $h++) |
|
| 1161 | + { |
|
| 1162 | + $color1='';$color2=''; |
|
| 1163 | + $style1='';$style2=''; |
|
| 1164 | + $string1=' ';$string2=' '; |
|
| 1165 | + $title1='';$title2=''; |
|
| 1166 | + if (isset($cases1[$h]) && $cases1[$h] != '') |
|
| 1167 | + { |
|
| 1168 | + //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1169 | + if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1170 | + $string1=' '; |
|
| 1171 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; |
|
| 1172 | + else $style1='peruser_busy'; |
|
| 1173 | + foreach($cases1[$h] as $id => $ev) |
|
| 1174 | + { |
|
| 1175 | + if ($ev['busy']) $style1='peruser_busy'; |
|
| 1176 | + } |
|
| 1177 | + } |
|
| 1178 | + if (isset($cases2[$h]) && $cases2[$h] != '') |
|
| 1179 | + { |
|
| 1180 | + //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1181 | + if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1182 | + $string2=' '; |
|
| 1183 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; |
|
| 1184 | + else $style2='peruser_busy'; |
|
| 1185 | + foreach($cases2[$h] as $id => $ev) |
|
| 1186 | + { |
|
| 1187 | + if ($ev['busy']) $style2='peruser_busy'; |
|
| 1188 | + } |
|
| 1189 | + } |
|
| 1194 | 1190 | |
| 1195 | - if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1196 | - else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1197 | - if (count($cases1[$h]) == 1) // only 1 event |
|
| 1198 | - { |
|
| 1199 | - $output = array_slice($cases1[$h], 0, 1); |
|
| 1200 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1201 | - if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1202 | - if ($output[0]['color']) $color1 = $output[0]['color']; |
|
| 1203 | - } |
|
| 1204 | - else if (count($cases1[$h]) > 1) |
|
| 1205 | - { |
|
| 1206 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1207 | - $color1='222222'; |
|
| 1208 | - } |
|
| 1191 | + $ids1='';$ids2=''; |
|
| 1192 | + if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h])); |
|
| 1193 | + if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h])); |
|
| 1209 | 1194 | |
| 1210 | - if (count($cases2[$h]) == 1) // only 1 event |
|
| 1211 | - { |
|
| 1212 | - $output = array_slice($cases2[$h], 0, 1); |
|
| 1213 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1214 | - if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1215 | - if ($output[0]['color']) $color2 = $output[0]['color']; |
|
| 1216 | - } |
|
| 1217 | - else if (count($cases2[$h]) > 1) |
|
| 1218 | - { |
|
| 1219 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1220 | - $color2='222222'; |
|
| 1221 | - } |
|
| 1222 | - print '<table class="nobordernopadding" width="100%">'; |
|
| 1223 | - print '<tr><td '; |
|
| 1224 | - if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1?$color1:"888").' !important" '; |
|
| 1225 | - elseif ($color1) |
|
| 1226 | - { |
|
| 1227 | - print ($color1?'style="background: #'.$color1.';"':''); |
|
| 1228 | - } |
|
| 1229 | - print 'class="'; |
|
| 1230 | - print ($style1?$style1.' ':''); |
|
| 1231 | - print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>'; |
|
| 1232 | - print $string1; |
|
| 1233 | - print '</td><td '; |
|
| 1234 | - if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2?$color2:"888").' !important" '; |
|
| 1235 | - elseif ($color2) |
|
| 1236 | - { |
|
| 1237 | - print ($color2?'style="background: #'.$color2.';"':''); |
|
| 1238 | - } |
|
| 1239 | - print 'class="'; |
|
| 1240 | - print ($style2?$style2.' ':''); |
|
| 1241 | - print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>'; |
|
| 1242 | - print $string2; |
|
| 1243 | - print '</td></tr>'; |
|
| 1244 | - print '</table>'; |
|
| 1245 | - print '</td>'; |
|
| 1246 | - } |
|
| 1195 | + if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1196 | + else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1197 | + if (count($cases1[$h]) == 1) // only 1 event |
|
| 1198 | + { |
|
| 1199 | + $output = array_slice($cases1[$h], 0, 1); |
|
| 1200 | + $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1201 | + if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1202 | + if ($output[0]['color']) $color1 = $output[0]['color']; |
|
| 1203 | + } |
|
| 1204 | + else if (count($cases1[$h]) > 1) |
|
| 1205 | + { |
|
| 1206 | + $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1207 | + $color1='222222'; |
|
| 1208 | + } |
|
| 1209 | + |
|
| 1210 | + if (count($cases2[$h]) == 1) // only 1 event |
|
| 1211 | + { |
|
| 1212 | + $output = array_slice($cases2[$h], 0, 1); |
|
| 1213 | + $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1214 | + if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1215 | + if ($output[0]['color']) $color2 = $output[0]['color']; |
|
| 1216 | + } |
|
| 1217 | + else if (count($cases2[$h]) > 1) |
|
| 1218 | + { |
|
| 1219 | + $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1220 | + $color2='222222'; |
|
| 1221 | + } |
|
| 1222 | + print '<table class="nobordernopadding" width="100%">'; |
|
| 1223 | + print '<tr><td '; |
|
| 1224 | + if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1?$color1:"888").' !important" '; |
|
| 1225 | + elseif ($color1) |
|
| 1226 | + { |
|
| 1227 | + print ($color1?'style="background: #'.$color1.';"':''); |
|
| 1228 | + } |
|
| 1229 | + print 'class="'; |
|
| 1230 | + print ($style1?$style1.' ':''); |
|
| 1231 | + print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>'; |
|
| 1232 | + print $string1; |
|
| 1233 | + print '</td><td '; |
|
| 1234 | + if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2?$color2:"888").' !important" '; |
|
| 1235 | + elseif ($color2) |
|
| 1236 | + { |
|
| 1237 | + print ($color2?'style="background: #'.$color2.';"':''); |
|
| 1238 | + } |
|
| 1239 | + print 'class="'; |
|
| 1240 | + print ($style2?$style2.' ':''); |
|
| 1241 | + print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>'; |
|
| 1242 | + print $string2; |
|
| 1243 | + print '</td></tr>'; |
|
| 1244 | + print '</table>'; |
|
| 1245 | + print '</td>'; |
|
| 1246 | + } |
|
| 1247 | 1247 | } |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 40 | 40 | |
| 41 | 41 | |
| 42 | -if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; |
|
| 42 | +if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { |
|
| 43 | + $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; |
|
| 44 | +} |
|
| 43 | 45 | |
| 44 | 46 | $filter = GETPOST("search_filter",'alpha',3)?GETPOST("search_filter",'alpha',3):GETPOST("filter",'alpha',3); |
| 45 | 47 | $filtert = GETPOST("search_filtert","int",3)?GETPOST("search_filtert","int",3):GETPOST("filtert","int",3); |
@@ -60,22 +62,36 @@ discard block |
||
| 60 | 62 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 61 | 63 | $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
| 62 | 64 | $offset = $limit * $page; |
| 63 | -if (! $sortorder) $sortorder="ASC"; |
|
| 64 | -if (! $sortfield) $sortfield="a.datec"; |
|
| 65 | +if (! $sortorder) { |
|
| 66 | + $sortorder="ASC"; |
|
| 67 | +} |
|
| 68 | +if (! $sortfield) { |
|
| 69 | + $sortfield="a.datec"; |
|
| 70 | +} |
|
| 65 | 71 | |
| 66 | 72 | // Security check |
| 67 | 73 | $socid = GETPOST("search_socid","int")?GETPOST("search_socid","int"):GETPOST("socid","int"); |
| 68 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 74 | +if ($user->societe_id) { |
|
| 75 | + $socid=$user->societe_id; |
|
| 76 | +} |
|
| 69 | 77 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
| 70 | -if ($socid < 0) $socid=''; |
|
| 78 | +if ($socid < 0) { |
|
| 79 | + $socid=''; |
|
| 80 | +} |
|
| 71 | 81 | |
| 72 | 82 | $canedit=1; |
| 73 | -if (! $user->rights->agenda->myactions->read) accessforbidden(); |
|
| 74 | -if (! $user->rights->agenda->allactions->read) $canedit=0; |
|
| 75 | -if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me |
|
| 83 | +if (! $user->rights->agenda->myactions->read) { |
|
| 84 | + accessforbidden(); |
|
| 85 | +} |
|
| 86 | +if (! $user->rights->agenda->allactions->read) { |
|
| 87 | + $canedit=0; |
|
| 88 | +} |
|
| 89 | +if (! $user->rights->agenda->allactions->read || $filter =='mine') { |
|
| 90 | + // If no permission to see all, we show only affected to me |
|
| 76 | 91 | { |
| 77 | 92 | $filtert=$user->id; |
| 78 | 93 | } |
| 94 | +} |
|
| 79 | 95 | |
| 80 | 96 | //$action=GETPOST('action','alpha'); |
| 81 | 97 | $action='show_peruser'; //We use 'show_week' mode |
@@ -92,13 +108,16 @@ discard block |
||
| 92 | 108 | if (GETPOST('search_actioncode','array')) |
| 93 | 109 | { |
| 94 | 110 | $actioncode=GETPOST('search_actioncode','array',3); |
| 95 | - if (! count($actioncode)) $actioncode='0'; |
|
| 96 | -} |
|
| 97 | -else |
|
| 111 | + if (! count($actioncode)) { |
|
| 112 | + $actioncode='0'; |
|
| 113 | + } |
|
| 114 | + } else |
|
| 98 | 115 | { |
| 99 | 116 | $actioncode=GETPOST("search_actioncode","alpha",3)?GETPOST("search_actioncode","alpha",3):(GETPOST("search_actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
| 100 | 117 | } |
| 101 | -if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 118 | +if ($actioncode == '' && empty($actioncodearray)) { |
|
| 119 | + $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 120 | +} |
|
| 102 | 121 | |
| 103 | 122 | $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); |
| 104 | 123 | if ($dateselect > 0) |
@@ -112,20 +131,36 @@ discard block |
||
| 112 | 131 | $tmparray=explode('-',$tmp); |
| 113 | 132 | $begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); |
| 114 | 133 | $end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18); |
| 115 | -if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; |
|
| 116 | -if ($end_h < 1 || $end_h > 24) $end_h = 18; |
|
| 117 | -if ($end_h <= $begin_h) $end_h = $begin_h + 1; |
|
| 134 | +if ($begin_h < 0 || $begin_h > 23) { |
|
| 135 | + $begin_h = 9; |
|
| 136 | +} |
|
| 137 | +if ($end_h < 1 || $end_h > 24) { |
|
| 138 | + $end_h = 18; |
|
| 139 | +} |
|
| 140 | +if ($end_h <= $begin_h) { |
|
| 141 | + $end_h = $begin_h + 1; |
|
| 142 | +} |
|
| 118 | 143 | |
| 119 | 144 | $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS; |
| 120 | 145 | $tmparray=explode('-',$tmp); |
| 121 | 146 | $begin_d = GETPOST('begin_d','int')?GETPOST('begin_d','int'):($tmparray[0] != '' ? $tmparray[0] : 1); |
| 122 | 147 | $end_d = GETPOST('end_d','int')?GETPOST('end_d','int'):($tmparray[1] != '' ? $tmparray[1] : 5); |
| 123 | -if ($begin_d < 1 || $begin_d > 7) $begin_d = 1; |
|
| 124 | -if ($end_d < 1 || $end_d > 7) $end_d = 7; |
|
| 125 | -if ($end_d < $begin_d) $end_d = $begin_d + 1; |
|
| 148 | +if ($begin_d < 1 || $begin_d > 7) { |
|
| 149 | + $begin_d = 1; |
|
| 150 | +} |
|
| 151 | +if ($end_d < 1 || $end_d > 7) { |
|
| 152 | + $end_d = 7; |
|
| 153 | +} |
|
| 154 | +if ($end_d < $begin_d) { |
|
| 155 | + $end_d = $begin_d + 1; |
|
| 156 | +} |
|
| 126 | 157 | |
| 127 | -if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 128 | -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); |
|
| 158 | +if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) { |
|
| 159 | + $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 160 | +} |
|
| 161 | +if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) { |
|
| 162 | + $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); |
|
| 163 | +} |
|
| 129 | 164 | |
| 130 | 165 | if (GETPOST('viewcal','alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { |
| 131 | 166 | $action='show_month'; $day=''; |
@@ -197,29 +232,65 @@ discard block |
||
| 197 | 232 | //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; |
| 198 | 233 | |
| 199 | 234 | $title=$langs->trans("DoneAndToDoActions"); |
| 200 | -if ($status == 'done') $title=$langs->trans("DoneActions"); |
|
| 201 | -if ($status == 'todo') $title=$langs->trans("ToDoActions"); |
|
| 235 | +if ($status == 'done') { |
|
| 236 | + $title=$langs->trans("DoneActions"); |
|
| 237 | +} |
|
| 238 | +if ($status == 'todo') { |
|
| 239 | + $title=$langs->trans("ToDoActions"); |
|
| 240 | +} |
|
| 202 | 241 | |
| 203 | 242 | $param=''; |
| 204 | 243 | if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { |
| 205 | 244 | if(is_array($actioncode)) { |
| 206 | - foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); |
|
| 207 | - } else $param.="&search_actioncode=".urlencode($actioncode); |
|
| 208 | -} |
|
| 209 | -if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); |
|
| 210 | -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&search_status=".urlencode($status); |
|
| 211 | -if ($filter) $param.="&search_filter=".urlencode($filter); |
|
| 212 | -if ($filtert) $param.="&search_filtert=".urlencode($filtert); |
|
| 213 | -if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); |
|
| 214 | -if ($socid) $param.="&search_socid=".urlencode($socid); |
|
| 215 | -if ($showbirthday) $param.="&search_showbirthday=1"; |
|
| 216 | -if ($pid) $param.="&search_projectid=".urlencode($pid); |
|
| 217 | -if ($type) $param.="&search_type=".urlencode($type); |
|
| 218 | -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param.='&action='.urlencode($action); |
|
| 219 | -if ($begin_h != '') $param.='&begin_h='.urlencode($begin_h); |
|
| 220 | -if ($end_h != '') $param.='&end_h='.urlencode($end_h); |
|
| 221 | -if ($begin_d != '') $param.='&begin_d='.urlencode($begin_d); |
|
| 222 | -if ($end_d != '') $param.='&end_d='.urlencode($end_d); |
|
| 245 | + foreach($actioncode as $str_action) { |
|
| 246 | + $param.="&search_actioncode[]=".urlencode($str_action); |
|
| 247 | + } |
|
| 248 | + } else { |
|
| 249 | + $param.="&search_actioncode=".urlencode($actioncode); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | +if ($resourceid > 0) { |
|
| 253 | + $param.="&search_resourceid=".urlencode($resourceid); |
|
| 254 | +} |
|
| 255 | +if ($status || isset($_GET['status']) || isset($_POST['status'])) { |
|
| 256 | + $param.="&search_status=".urlencode($status); |
|
| 257 | +} |
|
| 258 | +if ($filter) { |
|
| 259 | + $param.="&search_filter=".urlencode($filter); |
|
| 260 | +} |
|
| 261 | +if ($filtert) { |
|
| 262 | + $param.="&search_filtert=".urlencode($filtert); |
|
| 263 | +} |
|
| 264 | +if ($usergroup) { |
|
| 265 | + $param.="&search_usergroup=".urlencode($usergroup); |
|
| 266 | +} |
|
| 267 | +if ($socid) { |
|
| 268 | + $param.="&search_socid=".urlencode($socid); |
|
| 269 | +} |
|
| 270 | +if ($showbirthday) { |
|
| 271 | + $param.="&search_showbirthday=1"; |
|
| 272 | +} |
|
| 273 | +if ($pid) { |
|
| 274 | + $param.="&search_projectid=".urlencode($pid); |
|
| 275 | +} |
|
| 276 | +if ($type) { |
|
| 277 | + $param.="&search_type=".urlencode($type); |
|
| 278 | +} |
|
| 279 | +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') { |
|
| 280 | + $param.='&action='.urlencode($action); |
|
| 281 | +} |
|
| 282 | +if ($begin_h != '') { |
|
| 283 | + $param.='&begin_h='.urlencode($begin_h); |
|
| 284 | +} |
|
| 285 | +if ($end_h != '') { |
|
| 286 | + $param.='&end_h='.urlencode($end_h); |
|
| 287 | +} |
|
| 288 | +if ($begin_d != '') { |
|
| 289 | + $param.='&begin_d='.urlencode($begin_d); |
|
| 290 | +} |
|
| 291 | +if ($end_d != '') { |
|
| 292 | + $param.='&end_d='.urlencode($end_d); |
|
| 293 | +} |
|
| 223 | 294 | $param.="&maxprint=".urlencode($maxprint); |
| 224 | 295 | |
| 225 | 296 | |
@@ -288,11 +359,21 @@ discard block |
||
| 288 | 359 | |
| 289 | 360 | |
| 290 | 361 | $tabactive=''; |
| 291 | -if ($action == 'show_month') $tabactive='cardmonth'; |
|
| 292 | -if ($action == 'show_week') $tabactive='cardweek'; |
|
| 293 | -if ($action == 'show_day') $tabactive='cardday'; |
|
| 294 | -if ($action == 'show_list') $tabactive='cardlist'; |
|
| 295 | -if ($action == 'show_peruser') $tabactive='cardperuser'; |
|
| 362 | +if ($action == 'show_month') { |
|
| 363 | + $tabactive='cardmonth'; |
|
| 364 | +} |
|
| 365 | +if ($action == 'show_week') { |
|
| 366 | + $tabactive='cardweek'; |
|
| 367 | +} |
|
| 368 | +if ($action == 'show_day') { |
|
| 369 | + $tabactive='cardday'; |
|
| 370 | +} |
|
| 371 | +if ($action == 'show_list') { |
|
| 372 | + $tabactive='cardlist'; |
|
| 373 | +} |
|
| 374 | +if ($action == 'show_peruser') { |
|
| 375 | + $tabactive='cardperuser'; |
|
| 376 | +} |
|
| 296 | 377 | |
| 297 | 378 | $paramnoaction=preg_replace('/action=[a-z_]+/','',$param); |
| 298 | 379 | |
@@ -349,8 +430,7 @@ discard block |
||
| 349 | 430 | if (empty($reshook)) |
| 350 | 431 | { |
| 351 | 432 | $s.= $hookmanager->resPrint; |
| 352 | - } |
|
| 353 | - elseif ($reshook > 1) |
|
| 433 | + } elseif ($reshook > 1) |
|
| 354 | 434 | { |
| 355 | 435 | $s = $hookmanager->resPrint; |
| 356 | 436 | } |
@@ -381,7 +461,9 @@ discard block |
||
| 381 | 461 | $eventarray=array(); |
| 382 | 462 | |
| 383 | 463 | $sql = 'SELECT'; |
| 384 | -if ($usergroup > 0) $sql.=" DISTINCT"; |
|
| 464 | +if ($usergroup > 0) { |
|
| 465 | + $sql.=" DISTINCT"; |
|
| 466 | +} |
|
| 385 | 467 | $sql.= ' a.id, a.label,'; |
| 386 | 468 | $sql.= ' a.datep,'; |
| 387 | 469 | $sql.= ' a.datep2,'; |
@@ -391,12 +473,20 @@ discard block |
||
| 391 | 473 | $sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; |
| 392 | 474 | $sql.= ' ca.code, ca.color'; |
| 393 | 475 | $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; |
| 394 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 476 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 477 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 478 | +} |
|
| 395 | 479 | // We must filter on resource table |
| 396 | -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 480 | +if ($resourceid > 0) { |
|
| 481 | + $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 482 | +} |
|
| 397 | 483 | // We must filter on assignement table |
| 398 | -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 399 | -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 484 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 485 | + $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 486 | +} |
|
| 487 | +if ($usergroup > 0) { |
|
| 488 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 489 | +} |
|
| 400 | 490 | $sql.= ' WHERE a.fk_action = ca.id'; |
| 401 | 491 | $sql.= ' AND a.entity IN ('.getEntity('agenda').')'; |
| 402 | 492 | // Condition on actioncode |
@@ -404,37 +494,53 @@ discard block |
||
| 404 | 494 | { |
| 405 | 495 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 406 | 496 | { |
| 407 | - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; |
|
| 408 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 409 | - else |
|
| 497 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 498 | + $sql.= " AND ca.type != 'systemauto'"; |
|
| 499 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 500 | + $sql.= " AND ca.type = 'systemauto'"; |
|
| 501 | + } else |
|
| 410 | 502 | { |
| 411 | - if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'"; |
|
| 412 | - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 503 | + if ($actioncode == 'AC_OTH') { |
|
| 504 | + $sql.= " AND ca.type != 'systemauto'"; |
|
| 505 | + } |
|
| 506 | + if ($actioncode == 'AC_OTH_AUTO') { |
|
| 507 | + $sql.= " AND ca.type = 'systemauto'"; |
|
| 508 | + } |
|
| 413 | 509 | } |
| 414 | - } |
|
| 415 | - else |
|
| 510 | + } else |
|
| 416 | 511 | { |
| 417 | - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; |
|
| 418 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 419 | - else |
|
| 512 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 513 | + $sql.= " AND ca.type != 'systemauto'"; |
|
| 514 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 515 | + $sql.= " AND ca.type = 'systemauto'"; |
|
| 516 | + } else |
|
| 420 | 517 | { |
| 421 | 518 | if (is_array($actioncode)) |
| 422 | 519 | { |
| 423 | 520 | $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; |
| 424 | - } |
|
| 425 | - else |
|
| 521 | + } else |
|
| 426 | 522 | { |
| 427 | 523 | $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; |
| 428 | 524 | } |
| 429 | 525 | } |
| 430 | 526 | } |
| 431 | 527 | } |
| 432 | -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 433 | -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); |
|
| 434 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; |
|
| 435 | -if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; |
|
| 528 | +if ($resourceid > 0) { |
|
| 529 | + $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 530 | +} |
|
| 531 | +if ($pid) { |
|
| 532 | + $sql.=" AND a.fk_project=".$db->escape($pid); |
|
| 533 | +} |
|
| 534 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
| 535 | + $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; |
|
| 536 | +} |
|
| 537 | +if ($socid > 0) { |
|
| 538 | + $sql.= ' AND a.fk_soc = '.$socid; |
|
| 539 | +} |
|
| 436 | 540 | // We must filter on assignement table |
| 437 | -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 541 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 542 | + $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 543 | +} |
|
| 438 | 544 | if ($action == 'show_day') |
| 439 | 545 | { |
| 440 | 546 | $sql.= " AND ("; |
@@ -447,8 +553,7 @@ discard block |
||
| 447 | 553 | $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; |
| 448 | 554 | $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; |
| 449 | 555 | $sql.= ')'; |
| 450 | -} |
|
| 451 | -else |
|
| 556 | +} else |
|
| 452 | 557 | { |
| 453 | 558 | // To limit array |
| 454 | 559 | $sql.= " AND ("; |
@@ -462,7 +567,9 @@ discard block |
||
| 462 | 567 | $sql.= " AND a.datep2 > '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; |
| 463 | 568 | $sql.= ')'; |
| 464 | 569 | } |
| 465 | -if ($type) $sql.= " AND ca.id = ".$type; |
|
| 570 | +if ($type) { |
|
| 571 | + $sql.= " AND ca.id = ".$type; |
|
| 572 | +} |
|
| 466 | 573 | if ($status == '0') { $sql.= " AND a.percent = 0"; } |
| 467 | 574 | if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable |
| 468 | 575 | if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
@@ -472,8 +579,12 @@ discard block |
||
| 472 | 579 | if ($filtert > 0 || $usergroup > 0) |
| 473 | 580 | { |
| 474 | 581 | $sql.= " AND ("; |
| 475 | - if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; |
|
| 476 | - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; |
|
| 582 | + if ($filtert > 0) { |
|
| 583 | + $sql.= "ar.fk_element = ".$filtert; |
|
| 584 | + } |
|
| 585 | + if ($usergroup > 0) { |
|
| 586 | + $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; |
|
| 587 | + } |
|
| 477 | 588 | $sql.= ")"; |
| 478 | 589 | } |
| 479 | 590 | // Sort on date |
@@ -530,14 +641,19 @@ discard block |
||
| 530 | 641 | if ($event->percentage <= 0) |
| 531 | 642 | { |
| 532 | 643 | $event->date_start_in_calendar=$datep; |
| 533 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 534 | - else $event->date_end_in_calendar=$datep; |
|
| 535 | - } |
|
| 536 | - else |
|
| 644 | + if ($datep2 != '' && $datep2 >= $datep) { |
|
| 645 | + $event->date_end_in_calendar=$datep2; |
|
| 646 | + } else { |
|
| 647 | + $event->date_end_in_calendar=$datep; |
|
| 648 | + } |
|
| 649 | + } else |
|
| 537 | 650 | { |
| 538 | 651 | $event->date_start_in_calendar=$datep; |
| 539 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 540 | - else $event->date_end_in_calendar=$datep; |
|
| 652 | + if ($datep2 != '' && $datep2 >= $datep) { |
|
| 653 | + $event->date_end_in_calendar=$datep2; |
|
| 654 | + } else { |
|
| 655 | + $event->date_end_in_calendar=$datep; |
|
| 656 | + } |
|
| 541 | 657 | } |
| 542 | 658 | // Define ponctual property |
| 543 | 659 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) |
@@ -551,14 +667,17 @@ discard block |
||
| 551 | 667 | { |
| 552 | 668 | // This record is out of visible range |
| 553 | 669 | unset($event); |
| 554 | - } |
|
| 555 | - else |
|
| 670 | + } else |
|
| 556 | 671 | { |
| 557 | 672 | //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
| 558 | 673 | $event->fetch_userassigned(); // This load $event->userassigned |
| 559 | 674 | |
| 560 | - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; |
|
| 561 | - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); |
|
| 675 | + if ($event->date_start_in_calendar < $firstdaytoshow) { |
|
| 676 | + $event->date_start_in_calendar=$firstdaytoshow; |
|
| 677 | + } |
|
| 678 | + if ($event->date_end_in_calendar >= $lastdaytoshow) { |
|
| 679 | + $event->date_end_in_calendar=($lastdaytoshow - 1); |
|
| 680 | + } |
|
| 562 | 681 | |
| 563 | 682 | // Add an entry in actionarray for each day |
| 564 | 683 | $daycursor=$event->date_start_in_calendar; |
@@ -577,7 +696,9 @@ discard block |
||
| 577 | 696 | $j++; |
| 578 | 697 | |
| 579 | 698 | $daykey+=60*60*24; |
| 580 | - if ($daykey > $event->date_end_in_calendar) $loop=false; |
|
| 699 | + if ($daykey > $event->date_end_in_calendar) { |
|
| 700 | + $loop=false; |
|
| 701 | + } |
|
| 581 | 702 | } |
| 582 | 703 | while ($loop); |
| 583 | 704 | |
@@ -587,8 +708,7 @@ discard block |
||
| 587 | 708 | $i++; |
| 588 | 709 | } |
| 589 | 710 | $db->free($resql); |
| 590 | -} |
|
| 591 | -else |
|
| 711 | +} else |
|
| 592 | 712 | { |
| 593 | 713 | dol_print_error($db); |
| 594 | 714 | } |
@@ -604,7 +724,9 @@ discard block |
||
| 604 | 724 | { |
| 605 | 725 | include_once $color_file; |
| 606 | 726 | } |
| 607 | -if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); |
|
| 727 | +if (! is_array($theme_datacolor)) { |
|
| 728 | + $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); |
|
| 729 | +} |
|
| 608 | 730 | |
| 609 | 731 | |
| 610 | 732 | $newparam=$param; // newparam is for birthday links |
@@ -647,8 +769,11 @@ discard block |
||
| 647 | 769 | echo '<td align="center" colspan="'.($end_h - $begin_h).'">'; |
| 648 | 770 | echo $langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7)); |
| 649 | 771 | print "<br>"; |
| 650 | - if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'),'day'); |
|
| 651 | - else print dol_print_date($currentdaytoshow,'day'); |
|
| 772 | + if ($i) { |
|
| 773 | + print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'),'day'); |
|
| 774 | + } else { |
|
| 775 | + print dol_print_date($currentdaytoshow,'day'); |
|
| 776 | + } |
|
| 652 | 777 | echo "</td>\n"; |
| 653 | 778 | $i++; |
| 654 | 779 | } |
@@ -691,7 +816,9 @@ discard block |
||
| 691 | 816 | $listofuserid=$event->userassigned; |
| 692 | 817 | foreach($listofuserid as $userid => $tmp) |
| 693 | 818 | { |
| 694 | - if (! in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; |
|
| 819 | + if (! in_array($userid, $usernamesid)) { |
|
| 820 | + $usernamesid[$userid] = $userid; |
|
| 821 | + } |
|
| 695 | 822 | } |
| 696 | 823 | } |
| 697 | 824 | } |
@@ -701,9 +828,13 @@ discard block |
||
| 701 | 828 | { |
| 702 | 829 | $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; |
| 703 | 830 | $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; |
| 704 | - if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; |
|
| 831 | + if ($usergroup > 0) { |
|
| 832 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; |
|
| 833 | + } |
|
| 705 | 834 | $sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; |
| 706 | - if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup; |
|
| 835 | + if ($usergroup > 0) { |
|
| 836 | + $sql.= " AND ug.fk_usergroup = ".$usergroup; |
|
| 837 | + } |
|
| 707 | 838 | //print $sql; |
| 708 | 839 | $resql=$db->query($sql); |
| 709 | 840 | if ($resql) |
@@ -719,8 +850,9 @@ discard block |
||
| 719 | 850 | $i++; |
| 720 | 851 | } |
| 721 | 852 | } |
| 853 | + } else { |
|
| 854 | + dol_print_error($db); |
|
| 722 | 855 | } |
| 723 | - else dol_print_error($db); |
|
| 724 | 856 | } |
| 725 | 857 | //var_dump($usernamesid); |
| 726 | 858 | foreach($usernamesid as $id) |
@@ -794,10 +926,16 @@ discard block |
||
| 794 | 926 | $tmpyear = $tmparray['year']; |
| 795 | 927 | |
| 796 | 928 | $style='cal_current_month'; |
| 797 | - if ($iter_day == 6) $style.=' cal_other_month'; |
|
| 929 | + if ($iter_day == 6) { |
|
| 930 | + $style.=' cal_other_month'; |
|
| 931 | + } |
|
| 798 | 932 | $today=0; |
| 799 | - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; |
|
| 800 | - if ($today) $style='cal_today_peruser'; |
|
| 933 | + if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) { |
|
| 934 | + $today=1; |
|
| 935 | + } |
|
| 936 | + if ($today) { |
|
| 937 | + $style='cal_today_peruser'; |
|
| 938 | + } |
|
| 801 | 939 | |
| 802 | 940 | show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
| 803 | 941 | |
@@ -934,7 +1072,8 @@ discard block |
||
| 934 | 1072 | $jour = date('d',$daykey); |
| 935 | 1073 | //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n"; |
| 936 | 1074 | |
| 937 | - if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? |
|
| 1075 | + if ($day==$jour && $month==$mois && $year==$annee) { |
|
| 1076 | + // Is it the day we are looking for when calling function ? |
|
| 938 | 1077 | { |
| 939 | 1078 | // Scan all event for this date |
| 940 | 1079 | foreach ($eventarray[$daykey] as $index => $event) |
@@ -942,14 +1081,20 @@ discard block |
||
| 942 | 1081 | //var_dump($event); |
| 943 | 1082 | |
| 944 | 1083 | $keysofuserassigned=array_keys($event->userassigned); |
| 1084 | + } |
|
| 945 | 1085 | $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); |
| 946 | 1086 | |
| 947 | - if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 1087 | + if (! in_array($username->id,$keysofuserassigned)) { |
|
| 1088 | + continue; |
|
| 1089 | + } |
|
| 1090 | + // We discard record if event is from another user than user we want to show |
|
| 948 | 1091 | //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
| 949 | 1092 | |
| 950 | 1093 | $parameters=array(); |
| 951 | 1094 | $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks |
| 952 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 1095 | + if ($reshook < 0) { |
|
| 1096 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 1097 | + } |
|
| 953 | 1098 | |
| 954 | 1099 | // Define $color (Hex string like '0088FF') and $cssclass of event |
| 955 | 1100 | $color=-1; $cssclass=''; $colorindex=-1; |
@@ -966,11 +1111,14 @@ discard block |
||
| 966 | 1111 | //var_dump($cacheusers[$event->userownerid]->color); |
| 967 | 1112 | |
| 968 | 1113 | // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
| 969 | - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; |
|
| 1114 | + if (! empty($cacheusers[$event->userownerid]->color)) { |
|
| 1115 | + $color=$cacheusers[$event->userownerid]->color; |
|
| 1116 | + } |
|
| 970 | 1117 | |
| 971 | - if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; |
|
| 972 | - } |
|
| 973 | - else if ($event->type_code == 'ICALEVENT') |
|
| 1118 | + if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) { |
|
| 1119 | + $color=$event->type_color; |
|
| 1120 | + } |
|
| 1121 | + } else if ($event->type_code == 'ICALEVENT') |
|
| 974 | 1122 | { |
| 975 | 1123 | $numical++; |
| 976 | 1124 | if (! empty($event->icalname)) |
@@ -983,12 +1131,10 @@ discard block |
||
| 983 | 1131 | |
| 984 | 1132 | $color=$event->icalcolor; |
| 985 | 1133 | $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); |
| 986 | - } |
|
| 987 | - else if ($event->type_code == 'BIRTHDAY') |
|
| 1134 | + } else if ($event->type_code == 'BIRTHDAY') |
|
| 988 | 1135 | { |
| 989 | 1136 | $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
| 990 | - } |
|
| 991 | - else |
|
| 1137 | + } else |
|
| 992 | 1138 | { |
| 993 | 1139 | $numother++; |
| 994 | 1140 | $color=($event->icalcolor?$event->icalcolor:-1); |
@@ -1003,24 +1149,32 @@ discard block |
||
| 1003 | 1149 | //var_dump($cacheusers[$event->userownerid]->color); |
| 1004 | 1150 | |
| 1005 | 1151 | // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
| 1006 | - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; |
|
| 1152 | + if (! empty($cacheusers[$event->userownerid]->color)) { |
|
| 1153 | + $color=$cacheusers[$event->userownerid]->color; |
|
| 1154 | + } |
|
| 1007 | 1155 | |
| 1008 | - if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; |
|
| 1156 | + if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) { |
|
| 1157 | + $color=$event->type_color; |
|
| 1158 | + } |
|
| 1009 | 1159 | } |
| 1010 | 1160 | |
| 1011 | - if ($color < 0) // Color was not set on user card. Set color according to color index. |
|
| 1161 | + if ($color < 0) { |
|
| 1162 | + // Color was not set on user card. Set color according to color index. |
|
| 1012 | 1163 | { |
| 1013 | 1164 | // Define color index if not yet defined |
| 1014 | 1165 | $idusertouse=($event->userownerid?$event->userownerid:0); |
| 1166 | + } |
|
| 1015 | 1167 | if (isset($colorindexused[$idusertouse])) |
| 1016 | 1168 | { |
| 1017 | 1169 | $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user |
| 1018 | - } |
|
| 1019 | - else |
|
| 1170 | + } else |
|
| 1020 | 1171 | { |
| 1021 | 1172 | $colorindex=$nextindextouse; |
| 1022 | 1173 | $colorindexused[$idusertouse]=$colorindex; |
| 1023 | - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color |
|
| 1174 | + if (! empty($theme_datacolor[$nextindextouse+1])) { |
|
| 1175 | + $nextindextouse++; |
|
| 1176 | + } |
|
| 1177 | + // Prepare to use next color |
|
| 1024 | 1178 | } |
| 1025 | 1179 | // Define color |
| 1026 | 1180 | $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
@@ -1039,7 +1193,9 @@ discard block |
||
| 1039 | 1193 | $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); |
| 1040 | 1194 | |
| 1041 | 1195 | $dateendtouse=$event->date_end_in_calendar; |
| 1042 | - if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; |
|
| 1196 | + if ($dateendtouse==$event->date_start_in_calendar) { |
|
| 1197 | + $dateendtouse++; |
|
| 1198 | + } |
|
| 1043 | 1199 | |
| 1044 | 1200 | //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
| 1045 | 1201 | |
@@ -1052,10 +1208,15 @@ discard block |
||
| 1052 | 1208 | { |
| 1053 | 1209 | $tmpa=dol_getdate($event->date_start_in_calendar,true); |
| 1054 | 1210 | $tmpb=dol_getdate($event->date_end_in_calendar,true); |
| 1055 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1056 | - else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1211 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
|
| 1212 | + $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1213 | + } else { |
|
| 1214 | + $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1215 | + } |
|
| 1057 | 1216 | } |
| 1058 | - if ($event->label) $cases1[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1217 | + if ($event->label) { |
|
| 1218 | + $cases1[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1219 | + } |
|
| 1059 | 1220 | $cases1[$h][$event->id]['typecode']=$event->type_code; |
| 1060 | 1221 | $cases1[$h][$event->id]['color']=$color; |
| 1061 | 1222 | if ($event->fk_project > 0) |
@@ -1098,10 +1259,15 @@ discard block |
||
| 1098 | 1259 | { |
| 1099 | 1260 | $tmpa=dol_getdate($event->date_start_in_calendar,true); |
| 1100 | 1261 | $tmpb=dol_getdate($event->date_end_in_calendar,true); |
| 1101 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1102 | - else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1262 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
|
| 1263 | + $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1264 | + } else { |
|
| 1265 | + $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1266 | + } |
|
| 1103 | 1267 | } |
| 1104 | - if ($event->label) $cases2[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1268 | + if ($event->label) { |
|
| 1269 | + $cases2[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1270 | + } |
|
| 1105 | 1271 | $cases2[$h][$event->id]['typecode']=$event->type_code; |
| 1106 | 1272 | $cases2[$h][$event->id]['color']=$color; |
| 1107 | 1273 | if ($event->fk_project > 0) |
@@ -1135,8 +1301,7 @@ discard block |
||
| 1135 | 1301 | $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
| 1136 | 1302 | } |
| 1137 | 1303 | } |
| 1138 | - } |
|
| 1139 | - else |
|
| 1304 | + } else |
|
| 1140 | 1305 | { |
| 1141 | 1306 | $busy=$event->transparency; |
| 1142 | 1307 | $cases1[$h][$event->id]['busy']=$busy; |
@@ -1166,63 +1331,95 @@ discard block |
||
| 1166 | 1331 | if (isset($cases1[$h]) && $cases1[$h] != '') |
| 1167 | 1332 | { |
| 1168 | 1333 | //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1169 | - if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1334 | + if (count($cases1[$h]) > 1) { |
|
| 1335 | + $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1336 | + } |
|
| 1170 | 1337 | $string1=' '; |
| 1171 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; |
|
| 1172 | - else $style1='peruser_busy'; |
|
| 1338 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { |
|
| 1339 | + $style1='peruser_notbusy'; |
|
| 1340 | + } else { |
|
| 1341 | + $style1='peruser_busy'; |
|
| 1342 | + } |
|
| 1173 | 1343 | foreach($cases1[$h] as $id => $ev) |
| 1174 | 1344 | { |
| 1175 | - if ($ev['busy']) $style1='peruser_busy'; |
|
| 1345 | + if ($ev['busy']) { |
|
| 1346 | + $style1='peruser_busy'; |
|
| 1347 | + } |
|
| 1176 | 1348 | } |
| 1177 | 1349 | } |
| 1178 | 1350 | if (isset($cases2[$h]) && $cases2[$h] != '') |
| 1179 | 1351 | { |
| 1180 | 1352 | //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1181 | - if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1353 | + if (count($cases2[$h]) > 1) { |
|
| 1354 | + $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1355 | + } |
|
| 1182 | 1356 | $string2=' '; |
| 1183 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; |
|
| 1184 | - else $style2='peruser_busy'; |
|
| 1357 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { |
|
| 1358 | + $style2='peruser_notbusy'; |
|
| 1359 | + } else { |
|
| 1360 | + $style2='peruser_busy'; |
|
| 1361 | + } |
|
| 1185 | 1362 | foreach($cases2[$h] as $id => $ev) |
| 1186 | 1363 | { |
| 1187 | - if ($ev['busy']) $style2='peruser_busy'; |
|
| 1364 | + if ($ev['busy']) { |
|
| 1365 | + $style2='peruser_busy'; |
|
| 1366 | + } |
|
| 1188 | 1367 | } |
| 1189 | 1368 | } |
| 1190 | 1369 | |
| 1191 | 1370 | $ids1='';$ids2=''; |
| 1192 | - if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h])); |
|
| 1193 | - if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h])); |
|
| 1371 | + if (count($cases1[$h]) && array_keys($cases1[$h])) { |
|
| 1372 | + $ids1=join(',',array_keys($cases1[$h])); |
|
| 1373 | + } |
|
| 1374 | + if (count($cases2[$h]) && array_keys($cases2[$h])) { |
|
| 1375 | + $ids2=join(',',array_keys($cases2[$h])); |
|
| 1376 | + } |
|
| 1194 | 1377 | |
| 1195 | - if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1196 | - else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1197 | - if (count($cases1[$h]) == 1) // only 1 event |
|
| 1378 | + if ($h == $begin_h) { |
|
| 1379 | + echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1380 | + } else { |
|
| 1381 | + echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1382 | + } |
|
| 1383 | + if (count($cases1[$h]) == 1) { |
|
| 1384 | + // only 1 event |
|
| 1198 | 1385 | { |
| 1199 | 1386 | $output = array_slice($cases1[$h], 0, 1); |
| 1200 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1201 | - if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1202 | - if ($output[0]['color']) $color1 = $output[0]['color']; |
|
| 1203 | 1387 | } |
| 1204 | - else if (count($cases1[$h]) > 1) |
|
| 1388 | + $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1389 | + if ($output[0]['string']) { |
|
| 1390 | + $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1391 | + } |
|
| 1392 | + if ($output[0]['color']) { |
|
| 1393 | + $color1 = $output[0]['color']; |
|
| 1394 | + } |
|
| 1395 | + } else if (count($cases1[$h]) > 1) |
|
| 1205 | 1396 | { |
| 1206 | 1397 | $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
| 1207 | 1398 | $color1='222222'; |
| 1208 | 1399 | } |
| 1209 | 1400 | |
| 1210 | - if (count($cases2[$h]) == 1) // only 1 event |
|
| 1401 | + if (count($cases2[$h]) == 1) { |
|
| 1402 | + // only 1 event |
|
| 1211 | 1403 | { |
| 1212 | 1404 | $output = array_slice($cases2[$h], 0, 1); |
| 1213 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1214 | - if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1215 | - if ($output[0]['color']) $color2 = $output[0]['color']; |
|
| 1216 | 1405 | } |
| 1217 | - else if (count($cases2[$h]) > 1) |
|
| 1406 | + $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1407 | + if ($output[0]['string']) { |
|
| 1408 | + $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1409 | + } |
|
| 1410 | + if ($output[0]['color']) { |
|
| 1411 | + $color2 = $output[0]['color']; |
|
| 1412 | + } |
|
| 1413 | + } else if (count($cases2[$h]) > 1) |
|
| 1218 | 1414 | { |
| 1219 | 1415 | $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
| 1220 | 1416 | $color2='222222'; |
| 1221 | 1417 | } |
| 1222 | 1418 | print '<table class="nobordernopadding" width="100%">'; |
| 1223 | 1419 | print '<tr><td '; |
| 1224 | - if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1?$color1:"888").' !important" '; |
|
| 1225 | - elseif ($color1) |
|
| 1420 | + if ($style1 == 'peruser_notbusy') { |
|
| 1421 | + print 'style="border: 1px solid #'.($color1?$color1:"888").' !important" '; |
|
| 1422 | + } elseif ($color1) |
|
| 1226 | 1423 | { |
| 1227 | 1424 | print ($color1?'style="background: #'.$color1.';"':''); |
| 1228 | 1425 | } |
@@ -1231,8 +1428,9 @@ discard block |
||
| 1231 | 1428 | print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>'; |
| 1232 | 1429 | print $string1; |
| 1233 | 1430 | print '</td><td '; |
| 1234 | - if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2?$color2:"888").' !important" '; |
|
| 1235 | - elseif ($color2) |
|
| 1431 | + if ($style2 == 'peruser_notbusy') { |
|
| 1432 | + print 'style="border: 1px solid #'.($color2?$color2:"888").' !important" '; |
|
| 1433 | + } elseif ($color2) |
|
| 1236 | 1434 | { |
| 1237 | 1435 | print ($color2?'style="background: #'.$color2.';"':''); |
| 1238 | 1436 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
| 33 | 33 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
| 34 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
| 34 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
| 35 | 35 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
| 36 | 36 | require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
| 37 | 37 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 43 | 43 | |
| 44 | 44 | |
| 45 | -if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; |
|
| 45 | +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; |
|
| 46 | 46 | |
| 47 | -$filter = GETPOST("search_filter",'alpha',3)?GETPOST("search_filter",'alpha',3):GETPOST("filter",'alpha',3); |
|
| 48 | -$filtert = GETPOST("search_filtert","int",3)?GETPOST("search_filtert","int",3):GETPOST("filtert","int",3); |
|
| 49 | -$usergroup = GETPOST("search_usergroup","int",3)?GETPOST("search_usergroup","int",3):GETPOST("usergroup","int",3); |
|
| 47 | +$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); |
|
| 48 | +$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); |
|
| 49 | +$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); |
|
| 50 | 50 | //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; |
| 51 | 51 | //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; |
| 52 | 52 | $showbirthday = 0; |
@@ -54,90 +54,90 @@ discard block |
||
| 54 | 54 | // If not choice done on calendar owner, we filter on user. |
| 55 | 55 | if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) |
| 56 | 56 | { |
| 57 | - $filtert=$user->id; |
|
| 57 | + $filtert = $user->id; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
| 61 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
| 62 | -$page = GETPOST("page","int"); |
|
| 60 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
| 61 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
| 62 | +$page = GETPOST("page", "int"); |
|
| 63 | 63 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 64 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 64 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 65 | 65 | $offset = $limit * $page; |
| 66 | -if (! $sortorder) $sortorder="ASC"; |
|
| 67 | -if (! $sortfield) $sortfield="a.datec"; |
|
| 66 | +if (!$sortorder) $sortorder = "ASC"; |
|
| 67 | +if (!$sortfield) $sortfield = "a.datec"; |
|
| 68 | 68 | |
| 69 | 69 | // Security check |
| 70 | -$socid = GETPOST("search_socid","int")?GETPOST("search_socid","int"):GETPOST("socid","int"); |
|
| 71 | -if ($user->societe_id) $socid=$user->societe_id; |
|
| 70 | +$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); |
|
| 71 | +if ($user->societe_id) $socid = $user->societe_id; |
|
| 72 | 72 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
| 73 | -if ($socid < 0) $socid=''; |
|
| 73 | +if ($socid < 0) $socid = ''; |
|
| 74 | 74 | |
| 75 | -$canedit=1; |
|
| 76 | -if (! $user->rights->agenda->myactions->read) accessforbidden(); |
|
| 77 | -if (! $user->rights->agenda->allactions->read) $canedit=0; |
|
| 78 | -if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me |
|
| 75 | +$canedit = 1; |
|
| 76 | +if (!$user->rights->agenda->myactions->read) accessforbidden(); |
|
| 77 | +if (!$user->rights->agenda->allactions->read) $canedit = 0; |
|
| 78 | +if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me |
|
| 79 | 79 | { |
| 80 | - $filtert=$user->id; |
|
| 80 | + $filtert = $user->id; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | //$action=GETPOST('action','alpha'); |
| 84 | -$action='show_peruser'; //We use 'show_week' mode |
|
| 85 | -$resourceid=GETPOST("search_resourceid","int")?GETPOST("search_resourceid","int"):GETPOST("resourceid","int"); |
|
| 86 | -$year=GETPOST("year","int")?GETPOST("year","int"):date("Y"); |
|
| 87 | -$month=GETPOST("month","int")?GETPOST("month","int"):date("m"); |
|
| 88 | -$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); |
|
| 89 | -$day=GETPOST("day","int")?GETPOST("day","int"):date("d"); |
|
| 90 | -$pid=GETPOST("search_projectid","int",3)?GETPOST("search_projectid","int",3):GETPOST("projectid","int",3); |
|
| 91 | -$status=GETPOST("search_status",'alpha')?GETPOST("search_status",'alpha'):GETPOST("status",'alpha'); |
|
| 92 | -$type=GETPOST("search_type",'alpha')?GETPOST("search_type",'alpha'):GETPOST("type",'alpha'); |
|
| 93 | -$maxprint=((GETPOST("maxprint",'int')!='')?GETPOST("maxprint",'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); |
|
| 84 | +$action = 'show_peruser'; //We use 'show_week' mode |
|
| 85 | +$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); |
|
| 86 | +$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); |
|
| 87 | +$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); |
|
| 88 | +$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); |
|
| 89 | +$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); |
|
| 90 | +$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); |
|
| 91 | +$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); |
|
| 92 | +$type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); |
|
| 93 | +$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); |
|
| 94 | 94 | // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) |
| 95 | -if (GETPOST('search_actioncode','array')) |
|
| 95 | +if (GETPOST('search_actioncode', 'array')) |
|
| 96 | 96 | { |
| 97 | - $actioncode=GETPOST('search_actioncode','array',3); |
|
| 98 | - if (! count($actioncode)) $actioncode='0'; |
|
| 97 | + $actioncode = GETPOST('search_actioncode', 'array', 3); |
|
| 98 | + if (!count($actioncode)) $actioncode = '0'; |
|
| 99 | 99 | } |
| 100 | 100 | else |
| 101 | 101 | { |
| 102 | - $actioncode=GETPOST("search_actioncode","alpha",3)?GETPOST("search_actioncode","alpha",3):(GETPOST("search_actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
|
| 102 | + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
|
| 103 | 103 | } |
| 104 | -if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 104 | +if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 105 | 105 | |
| 106 | -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); |
|
| 106 | +$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); |
|
| 107 | 107 | if ($dateselect > 0) |
| 108 | 108 | { |
| 109 | - $day=GETPOST('dateselectday','int'); |
|
| 110 | - $month=GETPOST('dateselectmonth','int'); |
|
| 111 | - $year=GETPOST('dateselectyear','int'); |
|
| 109 | + $day = GETPOST('dateselectday', 'int'); |
|
| 110 | + $month = GETPOST('dateselectmonth', 'int'); |
|
| 111 | + $year = GETPOST('dateselectyear', 'int'); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; |
|
| 115 | -$tmparray=explode('-',$tmp); |
|
| 116 | -$begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); |
|
| 117 | -$end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18); |
|
| 114 | +$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; |
|
| 115 | +$tmparray = explode('-', $tmp); |
|
| 116 | +$begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); |
|
| 117 | +$end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); |
|
| 118 | 118 | if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; |
| 119 | 119 | if ($end_h < 1 || $end_h > 24) $end_h = 18; |
| 120 | 120 | if ($end_h <= $begin_h) $end_h = $begin_h + 1; |
| 121 | 121 | |
| 122 | -$tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS; |
|
| 123 | -$tmparray=explode('-',$tmp); |
|
| 124 | -$begin_d = GETPOST('begin_d','int')?GETPOST('begin_d','int'):($tmparray[0] != '' ? $tmparray[0] : 1); |
|
| 125 | -$end_d = GETPOST('end_d','int')?GETPOST('end_d','int'):($tmparray[1] != '' ? $tmparray[1] : 5); |
|
| 122 | +$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; |
|
| 123 | +$tmparray = explode('-', $tmp); |
|
| 124 | +$begin_d = GETPOST('begin_d', 'int') ?GETPOST('begin_d', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 1); |
|
| 125 | +$end_d = GETPOST('end_d', 'int') ?GETPOST('end_d', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 5); |
|
| 126 | 126 | if ($begin_d < 1 || $begin_d > 7) $begin_d = 1; |
| 127 | 127 | if ($end_d < 1 || $end_d > 7) $end_d = 7; |
| 128 | 128 | if ($end_d < $begin_d) $end_d = $begin_d + 1; |
| 129 | 129 | |
| 130 | -if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 131 | -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); |
|
| 130 | +if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 131 | +if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
|
| 132 | 132 | |
| 133 | -if (GETPOST('viewcal','alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { |
|
| 134 | - $action='show_month'; $day=''; |
|
| 133 | +if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { |
|
| 134 | + $action = 'show_month'; $day = ''; |
|
| 135 | 135 | } // View by month |
| 136 | -if (GETPOST('viewweek','alpha') || $action == 'show_week') { |
|
| 137 | - $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d")); |
|
| 136 | +if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { |
|
| 137 | + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); |
|
| 138 | 138 | } // View by week |
| 139 | -if (GETPOST('viewday','alpha') || $action == 'show_day') { |
|
| 140 | - $action='show_day'; $day=($day?$day:date("d")); |
|
| 139 | +if (GETPOST('viewday', 'alpha') || $action == 'show_day') { |
|
| 140 | + $action = 'show_day'; $day = ($day ? $day : date("d")); |
|
| 141 | 141 | } // View by day |
| 142 | 142 | |
| 143 | 143 | // Load translation files required by the page |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | * Actions |
| 152 | 152 | */ |
| 153 | 153 | |
| 154 | -if ($action =='delete_action') |
|
| 154 | +if ($action == 'delete_action') |
|
| 155 | 155 | { |
| 156 | 156 | $event = new ActionComm($db); |
| 157 | 157 | $event->fetch($actionid); |
| 158 | - $result=$event->delete(); |
|
| 158 | + $result = $event->delete(); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -164,21 +164,21 @@ discard block |
||
| 164 | 164 | * View |
| 165 | 165 | */ |
| 166 | 166 | |
| 167 | -$form=new Form($db); |
|
| 168 | -$companystatic=new Societe($db); |
|
| 167 | +$form = new Form($db); |
|
| 168 | +$companystatic = new Societe($db); |
|
| 169 | 169 | |
| 170 | -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; |
|
| 171 | -llxHeader('',$langs->trans("Agenda"),$help_url); |
|
| 170 | +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; |
|
| 171 | +llxHeader('', $langs->trans("Agenda"), $help_url); |
|
| 172 | 172 | |
| 173 | -$now=dol_now(); |
|
| 174 | -$nowarray=dol_getdate($now); |
|
| 175 | -$nowyear=$nowarray['year']; |
|
| 176 | -$nowmonth=$nowarray['mon']; |
|
| 177 | -$nowday=$nowarray['mday']; |
|
| 173 | +$now = dol_now(); |
|
| 174 | +$nowarray = dol_getdate($now); |
|
| 175 | +$nowyear = $nowarray['year']; |
|
| 176 | +$nowmonth = $nowarray['mon']; |
|
| 177 | +$nowday = $nowarray['mday']; |
|
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | // Define list of all external calendars (global setup) |
| 181 | -$listofextcals=array(); |
|
| 181 | +$listofextcals = array(); |
|
| 182 | 182 | |
| 183 | 183 | $prev = dol_get_first_day_week($day, $month, $year); |
| 184 | 184 | $first_day = $prev['first_day']; |
@@ -193,37 +193,37 @@ discard block |
||
| 193 | 193 | $next_month = $next['month']; |
| 194 | 194 | $next_day = $next['day']; |
| 195 | 195 | |
| 196 | -$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); |
|
| 196 | +$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); |
|
| 197 | 197 | |
| 198 | 198 | $tmpday = $first_day; |
| 199 | 199 | //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day; |
| 200 | 200 | //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; |
| 201 | 201 | |
| 202 | -$title=$langs->trans("DoneAndToDoActions"); |
|
| 203 | -if ($status == 'done') $title=$langs->trans("DoneActions"); |
|
| 204 | -if ($status == 'todo') $title=$langs->trans("ToDoActions"); |
|
| 202 | +$title = $langs->trans("DoneAndToDoActions"); |
|
| 203 | +if ($status == 'done') $title = $langs->trans("DoneActions"); |
|
| 204 | +if ($status == 'todo') $title = $langs->trans("ToDoActions"); |
|
| 205 | 205 | |
| 206 | -$param=''; |
|
| 206 | +$param = ''; |
|
| 207 | 207 | if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { |
| 208 | - if(is_array($actioncode)) { |
|
| 209 | - foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); |
|
| 210 | - } else $param.="&search_actioncode=".urlencode($actioncode); |
|
| 208 | + if (is_array($actioncode)) { |
|
| 209 | + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); |
|
| 210 | + } else $param .= "&search_actioncode=".urlencode($actioncode); |
|
| 211 | 211 | } |
| 212 | -if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); |
|
| 213 | -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&search_status=".urlencode($status); |
|
| 214 | -if ($filter) $param.="&search_filter=".urlencode($filter); |
|
| 215 | -if ($filtert) $param.="&search_filtert=".urlencode($filtert); |
|
| 216 | -if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); |
|
| 217 | -if ($socid) $param.="&search_socid=".urlencode($socid); |
|
| 218 | -if ($showbirthday) $param.="&search_showbirthday=1"; |
|
| 219 | -if ($pid) $param.="&search_projectid=".urlencode($pid); |
|
| 220 | -if ($type) $param.="&search_type=".urlencode($type); |
|
| 221 | -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param.='&action='.urlencode($action); |
|
| 222 | -if ($begin_h != '') $param.='&begin_h='.urlencode($begin_h); |
|
| 223 | -if ($end_h != '') $param.='&end_h='.urlencode($end_h); |
|
| 224 | -if ($begin_d != '') $param.='&begin_d='.urlencode($begin_d); |
|
| 225 | -if ($end_d != '') $param.='&end_d='.urlencode($end_d); |
|
| 226 | -$param.="&maxprint=".urlencode($maxprint); |
|
| 212 | +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); |
|
| 213 | +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); |
|
| 214 | +if ($filter) $param .= "&search_filter=".urlencode($filter); |
|
| 215 | +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); |
|
| 216 | +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); |
|
| 217 | +if ($socid) $param .= "&search_socid=".urlencode($socid); |
|
| 218 | +if ($showbirthday) $param .= "&search_showbirthday=1"; |
|
| 219 | +if ($pid) $param .= "&search_projectid=".urlencode($pid); |
|
| 220 | +if ($type) $param .= "&search_type=".urlencode($type); |
|
| 221 | +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param .= '&action='.urlencode($action); |
|
| 222 | +if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h); |
|
| 223 | +if ($end_h != '') $param .= '&end_h='.urlencode($end_h); |
|
| 224 | +if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d); |
|
| 225 | +if ($end_d != '') $param .= '&end_d='.urlencode($end_d); |
|
| 226 | +$param .= "&maxprint=".urlencode($maxprint); |
|
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | $prev = dol_get_first_day_week($day, $month, $year); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $prev_month = $prev['prev_month']; |
| 234 | 234 | $prev_day = $prev['prev_day']; |
| 235 | 235 | $first_day = $prev['first_day']; |
| 236 | -$first_month= $prev['first_month']; |
|
| 236 | +$first_month = $prev['first_month']; |
|
| 237 | 237 | $first_year = $prev['first_year']; |
| 238 | 238 | |
| 239 | 239 | $week = $prev['week']; |
@@ -245,24 +245,24 @@ discard block |
||
| 245 | 245 | $next_day = $next['day']; |
| 246 | 246 | |
| 247 | 247 | // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) |
| 248 | -$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); |
|
| 248 | +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); |
|
| 249 | 249 | |
| 250 | -$nb_weeks_to_show = (! empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7; |
|
| 251 | -$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); |
|
| 250 | +$nb_weeks_to_show = (!empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7; |
|
| 251 | +$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); |
|
| 252 | 252 | //print $firstday.'-'.$first_month.'-'.$first_year; |
| 253 | 253 | //print dol_print_date($firstdaytoshow,'dayhour'); |
| 254 | 254 | //print dol_print_date($lastdaytoshow,'dayhour'); |
| 255 | 255 | |
| 256 | -$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); |
|
| 256 | +$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); |
|
| 257 | 257 | |
| 258 | 258 | $tmpday = $first_day; |
| 259 | -$picto='calendarweek'; |
|
| 259 | +$picto = 'calendarweek'; |
|
| 260 | 260 | |
| 261 | -$nav ="<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> \n"; |
|
| 262 | -$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week; |
|
| 263 | -$nav.=" </span>\n"; |
|
| 264 | -$nav.=" <a href=\"?year=".$next_year."&month=".$next_month."&day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n"; |
|
| 265 | -$nav.=" (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)"; |
|
| 261 | +$nav = "<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> \n"; |
|
| 262 | +$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; |
|
| 263 | +$nav .= " </span>\n"; |
|
| 264 | +$nav .= " <a href=\"?year=".$next_year."&month=".$next_month."&day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n"; |
|
| 265 | +$nav .= " (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)"; |
|
| 266 | 266 | |
| 267 | 267 | /*$nav.=' <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">'; |
| 268 | 268 | $nav.='<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
@@ -280,24 +280,24 @@ discard block |
||
| 280 | 280 | $nav.='<input type="hidden" name="end_d" value="' . $end_d . '">'; |
| 281 | 281 | $nav.='<input type="hidden" name="showbirthday" value="' . $showbirthday . '">'; |
| 282 | 282 | */ |
| 283 | -$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); |
|
| 284 | -$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">'; |
|
| 283 | +$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); |
|
| 284 | +$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">'; |
|
| 285 | 285 | //$nav.='</form>'; |
| 286 | 286 | |
| 287 | 287 | // Must be after the nav definition |
| 288 | -$param.='&year='.urlencode($year).'&month='.urlencode($month).($day?'&day='.urlencode($day):''); |
|
| 288 | +$param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : ''); |
|
| 289 | 289 | //print 'x'.$param; |
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | |
| 293 | -$tabactive=''; |
|
| 294 | -if ($action == 'show_month') $tabactive='cardmonth'; |
|
| 295 | -if ($action == 'show_week') $tabactive='cardweek'; |
|
| 296 | -if ($action == 'show_day') $tabactive='cardday'; |
|
| 297 | -if ($action == 'show_list') $tabactive='cardlist'; |
|
| 298 | -if ($action == 'show_peruser') $tabactive='cardperuser'; |
|
| 293 | +$tabactive = ''; |
|
| 294 | +if ($action == 'show_month') $tabactive = 'cardmonth'; |
|
| 295 | +if ($action == 'show_week') $tabactive = 'cardweek'; |
|
| 296 | +if ($action == 'show_day') $tabactive = 'cardday'; |
|
| 297 | +if ($action == 'show_list') $tabactive = 'cardlist'; |
|
| 298 | +if ($action == 'show_peruser') $tabactive = 'cardperuser'; |
|
| 299 | 299 | |
| 300 | -$paramnoaction=preg_replace('/action=[a-z_]+/','',$param); |
|
| 300 | +$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); |
|
| 301 | 301 | |
| 302 | 302 | $head = calendars_prepare_head($paramnoaction); |
| 303 | 303 | |
@@ -307,51 +307,51 @@ discard block |
||
| 307 | 307 | print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); |
| 308 | 308 | dol_fiche_end(); |
| 309 | 309 | |
| 310 | -$showextcals=$listofextcals; |
|
| 310 | +$showextcals = $listofextcals; |
|
| 311 | 311 | // Legend |
| 312 | 312 | if ($conf->use_javascript_ajax) |
| 313 | 313 | { |
| 314 | - $s=''; |
|
| 315 | - $s.='<script type="text/javascript">' . "\n"; |
|
| 316 | - $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 317 | - $s.='jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });' . "\n"; |
|
| 318 | - $s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n"; |
|
| 319 | - $s.='jQuery(".family_birthday").toggle();' . "\n"; |
|
| 320 | - if ($action=="show_week" || $action=="show_month" || empty($action)) |
|
| 314 | + $s = ''; |
|
| 315 | + $s .= '<script type="text/javascript">'."\n"; |
|
| 316 | + $s .= 'jQuery(document).ready(function () {'."\n"; |
|
| 317 | + $s .= 'jQuery("#check_mytasks").click(function() { jQuery(".family_mytasks").toggle(); jQuery(".family_other").toggle(); });'."\n"; |
|
| 318 | + $s .= 'jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });'."\n"; |
|
| 319 | + $s .= 'jQuery(".family_birthday").toggle();'."\n"; |
|
| 320 | + if ($action == "show_week" || $action == "show_month" || empty($action)) |
|
| 321 | 321 | { |
| 322 | - $s.='jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; |
|
| 323 | - $s.='var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; |
|
| 322 | + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; |
|
| 323 | + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; |
|
| 324 | 324 | } |
| 325 | - $s.='});' . "\n"; |
|
| 326 | - $s.='</script>' . "\n"; |
|
| 327 | - if (! empty($conf->use_javascript_ajax)) |
|
| 325 | + $s .= '});'."\n"; |
|
| 326 | + $s .= '</script>'."\n"; |
|
| 327 | + if (!empty($conf->use_javascript_ajax)) |
|
| 328 | 328 | { |
| 329 | - $s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>'; |
|
| 329 | + $s .= '<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' </div>'; |
|
| 330 | 330 | if (is_array($showextcals) && count($showextcals) > 0) |
| 331 | 331 | { |
| 332 | 332 | foreach ($showextcals as $val) |
| 333 | 333 | { |
| 334 | 334 | $htmlname = md5($val['name']); |
| 335 | - $s.='<script type="text/javascript">' . "\n"; |
|
| 336 | - $s.='jQuery(document).ready(function () {' . "\n"; |
|
| 337 | - $s.=' jQuery("#check_ext' . $htmlname . '").click(function() {'; |
|
| 338 | - $s.=' /* alert("'.$htmlname.'"); */'; |
|
| 339 | - $s.=' jQuery(".family_ext' . $htmlname . '").toggle();'; |
|
| 340 | - $s.=' });' . "\n"; |
|
| 341 | - $s.='});' . "\n"; |
|
| 342 | - $s.='</script>' . "\n"; |
|
| 343 | - $s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val ['name'] . ' </div>'; |
|
| 335 | + $s .= '<script type="text/javascript">'."\n"; |
|
| 336 | + $s .= 'jQuery(document).ready(function () {'."\n"; |
|
| 337 | + $s .= ' jQuery("#check_ext'.$htmlname.'").click(function() {'; |
|
| 338 | + $s .= ' /* alert("'.$htmlname.'"); */'; |
|
| 339 | + $s .= ' jQuery(".family_ext'.$htmlname.'").toggle();'; |
|
| 340 | + $s .= ' });'."\n"; |
|
| 341 | + $s .= '});'."\n"; |
|
| 342 | + $s .= '</script>'."\n"; |
|
| 343 | + $s .= '<div class="nowrap float"><input type="checkbox" id="check_ext'.$htmlname.'" name="check_ext'.$htmlname.'" checked> '.$val ['name'].' </div>'; |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | //$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>'; |
| 348 | 348 | |
| 349 | 349 | // Calendars from hooks |
| 350 | - $parameters=array(); $object=null; |
|
| 351 | - $reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action); |
|
| 350 | + $parameters = array(); $object = null; |
|
| 351 | + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); |
|
| 352 | 352 | if (empty($reshook)) |
| 353 | 353 | { |
| 354 | - $s.= $hookmanager->resPrint; |
|
| 354 | + $s .= $hookmanager->resPrint; |
|
| 355 | 355 | } |
| 356 | 356 | elseif ($reshook > 1) |
| 357 | 357 | { |
@@ -361,191 +361,191 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | |
| 364 | -$newcardbutton=''; |
|
| 364 | +$newcardbutton = ''; |
|
| 365 | 365 | if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) |
| 366 | 366 | { |
| 367 | - $tmpforcreatebutton=dol_getdate(dol_now(), true); |
|
| 367 | + $tmpforcreatebutton = dol_getdate(dol_now(), true); |
|
| 368 | 368 | |
| 369 | - $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; |
|
| 369 | + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; |
|
| 370 | 370 | |
| 371 | 371 | //$param='month='.$monthshown.'&year='.$year; |
| 372 | - $hourminsec='100000'; |
|
| 373 | - $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$tmpforcreatebutton['year'],$tmpforcreatebutton['mon'],$tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'"><span class="valignmiddle">'.$langs->trans("AddAction").'</span>'; |
|
| 374 | - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 375 | - $newcardbutton.= '</a>'; |
|
| 372 | + $hourminsec = '100000'; |
|
| 373 | + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')).'"><span class="valignmiddle">'.$langs->trans("AddAction").'</span>'; |
|
| 374 | + $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
| 375 | + $newcardbutton .= '</a>'; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | -$link=''; |
|
| 378 | +$link = ''; |
|
| 379 | 379 | print load_fiche_titre($s, $link.' '.$nav.' '.$newcardbutton, ''); |
| 380 | 380 | |
| 381 | 381 | |
| 382 | 382 | |
| 383 | 383 | // Get event in an array |
| 384 | -$eventarray=array(); |
|
| 384 | +$eventarray = array(); |
|
| 385 | 385 | |
| 386 | 386 | $sql = 'SELECT'; |
| 387 | -if ($usergroup > 0) $sql.=" DISTINCT"; |
|
| 388 | -$sql.= ' a.id, a.label,'; |
|
| 389 | -$sql.= ' a.datep,'; |
|
| 390 | -$sql.= ' a.datep2,'; |
|
| 391 | -$sql.= ' a.percent,'; |
|
| 392 | -$sql.= ' a.fk_user_author,a.fk_user_action,'; |
|
| 393 | -$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; |
|
| 394 | -$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; |
|
| 395 | -$sql.= ' ca.code, ca.color'; |
|
| 396 | -$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; |
|
| 397 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 387 | +if ($usergroup > 0) $sql .= " DISTINCT"; |
|
| 388 | +$sql .= ' a.id, a.label,'; |
|
| 389 | +$sql .= ' a.datep,'; |
|
| 390 | +$sql .= ' a.datep2,'; |
|
| 391 | +$sql .= ' a.percent,'; |
|
| 392 | +$sql .= ' a.fk_user_author,a.fk_user_action,'; |
|
| 393 | +$sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,'; |
|
| 394 | +$sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; |
|
| 395 | +$sql .= ' ca.code, ca.color'; |
|
| 396 | +$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; |
|
| 397 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 398 | 398 | // We must filter on resource table |
| 399 | -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 399 | +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 400 | 400 | // We must filter on assignement table |
| 401 | -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 402 | -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 403 | -$sql.= ' WHERE a.fk_action = ca.id'; |
|
| 404 | -$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; |
|
| 401 | +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 402 | +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 403 | +$sql .= ' WHERE a.fk_action = ca.id'; |
|
| 404 | +$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; |
|
| 405 | 405 | // Condition on actioncode |
| 406 | -if (! empty($actioncode)) |
|
| 406 | +if (!empty($actioncode)) |
|
| 407 | 407 | { |
| 408 | 408 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 409 | 409 | { |
| 410 | - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; |
|
| 411 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 410 | + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; |
|
| 411 | + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 412 | 412 | else |
| 413 | 413 | { |
| 414 | - if ($actioncode == 'AC_OTH') $sql.= " AND ca.type != 'systemauto'"; |
|
| 415 | - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 414 | + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; |
|
| 415 | + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | else |
| 419 | 419 | { |
| 420 | - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND ca.type != 'systemauto'"; |
|
| 421 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; |
|
| 420 | + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; |
|
| 421 | + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 422 | 422 | else |
| 423 | 423 | { |
| 424 | 424 | if (is_array($actioncode)) |
| 425 | 425 | { |
| 426 | - $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; |
|
| 426 | + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; |
|
| 427 | 427 | } |
| 428 | 428 | else |
| 429 | 429 | { |
| 430 | - $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; |
|
| 430 | + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 436 | -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); |
|
| 437 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; |
|
| 438 | -if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid; |
|
| 435 | +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 436 | +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); |
|
| 437 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 438 | +if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; |
|
| 439 | 439 | // We must filter on assignement table |
| 440 | -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 440 | +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 441 | 441 | if ($action == 'show_day') |
| 442 | 442 | { |
| 443 | - $sql.= " AND ("; |
|
| 444 | - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; |
|
| 445 | - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; |
|
| 446 | - $sql.= " OR "; |
|
| 447 | - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; |
|
| 448 | - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; |
|
| 449 | - $sql.= " OR "; |
|
| 450 | - $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; |
|
| 451 | - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; |
|
| 452 | - $sql.= ')'; |
|
| 443 | + $sql .= " AND ("; |
|
| 444 | + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; |
|
| 445 | + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; |
|
| 446 | + $sql .= " OR "; |
|
| 447 | + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; |
|
| 448 | + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; |
|
| 449 | + $sql .= " OR "; |
|
| 450 | + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; |
|
| 451 | + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; |
|
| 452 | + $sql .= ')'; |
|
| 453 | 453 | } |
| 454 | 454 | else |
| 455 | 455 | { |
| 456 | 456 | // To limit array |
| 457 | - $sql.= " AND ("; |
|
| 458 | - $sql.= " (a.datep BETWEEN '".$db->idate($firstdaytoshow-(60*60*24*2))."'"; // Start 2 day before $firstdaytoshow |
|
| 459 | - $sql.= " AND '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; // End 2 day after $lastdaytoshow |
|
| 460 | - $sql.= " OR "; |
|
| 461 | - $sql.= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow-(60*60*24*2))."'"; |
|
| 462 | - $sql.= " AND '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; |
|
| 463 | - $sql.= " OR "; |
|
| 464 | - $sql.= " (a.datep < '".$db->idate($firstdaytoshow-(60*60*24*2))."'"; |
|
| 465 | - $sql.= " AND a.datep2 > '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; |
|
| 466 | - $sql.= ')'; |
|
| 457 | + $sql .= " AND ("; |
|
| 458 | + $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow |
|
| 459 | + $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow |
|
| 460 | + $sql .= " OR "; |
|
| 461 | + $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; |
|
| 462 | + $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; |
|
| 463 | + $sql .= " OR "; |
|
| 464 | + $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; |
|
| 465 | + $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; |
|
| 466 | + $sql .= ')'; |
|
| 467 | 467 | } |
| 468 | -if ($type) $sql.= " AND ca.id = ".$type; |
|
| 469 | -if ($status == '0') { $sql.= " AND a.percent = 0"; } |
|
| 470 | -if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable |
|
| 471 | -if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
|
| 472 | -if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100)"; } |
|
| 473 | -if ($status == 'todo') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } |
|
| 468 | +if ($type) $sql .= " AND ca.id = ".$type; |
|
| 469 | +if ($status == '0') { $sql .= " AND a.percent = 0"; } |
|
| 470 | +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable |
|
| 471 | +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
|
| 472 | +if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } |
|
| 473 | +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } |
|
| 474 | 474 | // We must filter on assignement table |
| 475 | 475 | if ($filtert > 0 || $usergroup > 0) |
| 476 | 476 | { |
| 477 | - $sql.= " AND ("; |
|
| 478 | - if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert; |
|
| 479 | - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; |
|
| 480 | - $sql.= ")"; |
|
| 477 | + $sql .= " AND ("; |
|
| 478 | + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; |
|
| 479 | + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; |
|
| 480 | + $sql .= ")"; |
|
| 481 | 481 | } |
| 482 | 482 | // Sort on date |
| 483 | -$sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action |
|
| 483 | +$sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action |
|
| 484 | 484 | |
| 485 | 485 | |
| 486 | 486 | dol_syslog("comm/action/peruser.php", LOG_DEBUG); |
| 487 | -$resql=$db->query($sql); |
|
| 487 | +$resql = $db->query($sql); |
|
| 488 | 488 | if ($resql) |
| 489 | 489 | { |
| 490 | 490 | $num = $db->num_rows($resql); |
| 491 | 491 | |
| 492 | - $i=0; |
|
| 492 | + $i = 0; |
|
| 493 | 493 | while ($i < $num) |
| 494 | 494 | { |
| 495 | 495 | $obj = $db->fetch_object($resql); |
| 496 | 496 | |
| 497 | 497 | // Discard auto action if option is on |
| 498 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') |
|
| 498 | + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') |
|
| 499 | 499 | { |
| 500 | 500 | $i++; |
| 501 | 501 | continue; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $datep=$db->jdate($obj->datep); |
|
| 505 | - $datep2=$db->jdate($obj->datep2); |
|
| 504 | + $datep = $db->jdate($obj->datep); |
|
| 505 | + $datep2 = $db->jdate($obj->datep2); |
|
| 506 | 506 | |
| 507 | 507 | // Create a new object action |
| 508 | - $event=new ActionComm($db); |
|
| 509 | - $event->id=$obj->id; |
|
| 510 | - $event->datep=$datep; // datep and datef are GMT date |
|
| 511 | - $event->datef=$datep2; |
|
| 512 | - $event->type_code=$obj->code; |
|
| 513 | - $event->type_color=$obj->color; |
|
| 514 | - $event->label=$obj->label; |
|
| 515 | - $event->percentage=$obj->percent; |
|
| 516 | - $event->authorid=$obj->fk_user_author; // user id of creator |
|
| 517 | - $event->userownerid=$obj->fk_user_action; // user id of owner |
|
| 518 | - $event->priority=$obj->priority; |
|
| 519 | - $event->fulldayevent=$obj->fulldayevent; |
|
| 520 | - $event->location=$obj->location; |
|
| 521 | - $event->transparency=$obj->transparency; |
|
| 522 | - |
|
| 523 | - $event->fk_project=$obj->fk_project; |
|
| 524 | - |
|
| 525 | - $event->socid=$obj->fk_soc; |
|
| 526 | - $event->contactid=$obj->fk_contact; |
|
| 527 | - |
|
| 528 | - $event->fk_element=$obj->fk_element; |
|
| 529 | - $event->elementtype=$obj->elementtype; |
|
| 508 | + $event = new ActionComm($db); |
|
| 509 | + $event->id = $obj->id; |
|
| 510 | + $event->datep = $datep; // datep and datef are GMT date |
|
| 511 | + $event->datef = $datep2; |
|
| 512 | + $event->type_code = $obj->code; |
|
| 513 | + $event->type_color = $obj->color; |
|
| 514 | + $event->label = $obj->label; |
|
| 515 | + $event->percentage = $obj->percent; |
|
| 516 | + $event->authorid = $obj->fk_user_author; // user id of creator |
|
| 517 | + $event->userownerid = $obj->fk_user_action; // user id of owner |
|
| 518 | + $event->priority = $obj->priority; |
|
| 519 | + $event->fulldayevent = $obj->fulldayevent; |
|
| 520 | + $event->location = $obj->location; |
|
| 521 | + $event->transparency = $obj->transparency; |
|
| 522 | + |
|
| 523 | + $event->fk_project = $obj->fk_project; |
|
| 524 | + |
|
| 525 | + $event->socid = $obj->fk_soc; |
|
| 526 | + $event->contactid = $obj->fk_contact; |
|
| 527 | + |
|
| 528 | + $event->fk_element = $obj->fk_element; |
|
| 529 | + $event->elementtype = $obj->elementtype; |
|
| 530 | 530 | |
| 531 | 531 | // Defined date_start_in_calendar and date_end_in_calendar property |
| 532 | 532 | // They are date start and end of action but modified to not be outside calendar view. |
| 533 | 533 | if ($event->percentage <= 0) |
| 534 | 534 | { |
| 535 | - $event->date_start_in_calendar=$datep; |
|
| 536 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 537 | - else $event->date_end_in_calendar=$datep; |
|
| 535 | + $event->date_start_in_calendar = $datep; |
|
| 536 | + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; |
|
| 537 | + else $event->date_end_in_calendar = $datep; |
|
| 538 | 538 | } |
| 539 | 539 | else |
| 540 | 540 | { |
| 541 | - $event->date_start_in_calendar=$datep; |
|
| 542 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; |
|
| 543 | - else $event->date_end_in_calendar=$datep; |
|
| 541 | + $event->date_start_in_calendar = $datep; |
|
| 542 | + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; |
|
| 543 | + else $event->date_end_in_calendar = $datep; |
|
| 544 | 544 | } |
| 545 | 545 | // Define ponctual property |
| 546 | 546 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) |
| 547 | 547 | { |
| 548 | - $event->ponctuel=1; |
|
| 548 | + $event->ponctuel = 1; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // Check values |
@@ -558,29 +558,29 @@ discard block |
||
| 558 | 558 | else |
| 559 | 559 | { |
| 560 | 560 | //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
| 561 | - $event->fetch_userassigned(); // This load $event->userassigned |
|
| 561 | + $event->fetch_userassigned(); // This load $event->userassigned |
|
| 562 | 562 | |
| 563 | - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; |
|
| 564 | - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); |
|
| 563 | + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; |
|
| 564 | + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
| 565 | 565 | |
| 566 | 566 | // Add an entry in actionarray for each day |
| 567 | - $daycursor=$event->date_start_in_calendar; |
|
| 568 | - $annee = date('Y',$daycursor); |
|
| 569 | - $mois = date('m',$daycursor); |
|
| 570 | - $jour = date('d',$daycursor); |
|
| 567 | + $daycursor = $event->date_start_in_calendar; |
|
| 568 | + $annee = date('Y', $daycursor); |
|
| 569 | + $mois = date('m', $daycursor); |
|
| 570 | + $jour = date('d', $daycursor); |
|
| 571 | 571 | |
| 572 | 572 | // Loop on each day covered by action to prepare an index to show on calendar |
| 573 | - $loop=true; $j=0; |
|
| 574 | - $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); |
|
| 573 | + $loop = true; $j = 0; |
|
| 574 | + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); |
|
| 575 | 575 | do |
| 576 | 576 | { |
| 577 | 577 | //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'<br>'; |
| 578 | 578 | |
| 579 | - $eventarray[$daykey][]=$event; |
|
| 579 | + $eventarray[$daykey][] = $event; |
|
| 580 | 580 | $j++; |
| 581 | 581 | |
| 582 | - $daykey+=60*60*24; |
|
| 583 | - if ($daykey > $event->date_end_in_calendar) $loop=false; |
|
| 582 | + $daykey += 60 * 60 * 24; |
|
| 583 | + if ($daykey > $event->date_end_in_calendar) $loop = false; |
|
| 584 | 584 | } |
| 585 | 585 | while ($loop); |
| 586 | 586 | |
@@ -596,10 +596,10 @@ discard block |
||
| 596 | 596 | dol_print_error($db); |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | -$maxnbofchar=18; |
|
| 600 | -$cachethirdparties=array(); |
|
| 601 | -$cachecontacts=array(); |
|
| 602 | -$cacheusers=array(); |
|
| 599 | +$maxnbofchar = 18; |
|
| 600 | +$cachethirdparties = array(); |
|
| 601 | +$cachecontacts = array(); |
|
| 602 | +$cacheusers = array(); |
|
| 603 | 603 | |
| 604 | 604 | // Define theme_datacolor array |
| 605 | 605 | $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php"; |
@@ -607,23 +607,23 @@ discard block |
||
| 607 | 607 | { |
| 608 | 608 | include_once $color_file; |
| 609 | 609 | } |
| 610 | -if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); |
|
| 610 | +if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); |
|
| 611 | 611 | |
| 612 | 612 | |
| 613 | -$newparam=$param; // newparam is for birthday links |
|
| 614 | -$newparam=preg_replace('/showbirthday=/i','showbirthday_=',$newparam); // To avoid replacement when replace day= is done |
|
| 615 | -$newparam=preg_replace('/action=show_month&?/i','',$newparam); |
|
| 616 | -$newparam=preg_replace('/action=show_week&?/i','',$newparam); |
|
| 617 | -$newparam=preg_replace('/day=[0-9]+&?/i','',$newparam); |
|
| 618 | -$newparam=preg_replace('/month=[0-9]+&?/i','',$newparam); |
|
| 619 | -$newparam=preg_replace('/year=[0-9]+&?/i','',$newparam); |
|
| 620 | -$newparam=preg_replace('/viewweek=[0-9]+&?/i','',$newparam); |
|
| 621 | -$newparam=preg_replace('/showbirthday_=/i','showbirthday=',$newparam); // Restore correct parameter |
|
| 622 | -$newparam.='&viewweek=1'; |
|
| 613 | +$newparam = $param; // newparam is for birthday links |
|
| 614 | +$newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done |
|
| 615 | +$newparam = preg_replace('/action=show_month&?/i', '', $newparam); |
|
| 616 | +$newparam = preg_replace('/action=show_week&?/i', '', $newparam); |
|
| 617 | +$newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); |
|
| 618 | +$newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); |
|
| 619 | +$newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); |
|
| 620 | +$newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); |
|
| 621 | +$newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter |
|
| 622 | +$newparam .= '&viewweek=1'; |
|
| 623 | 623 | |
| 624 | 624 | echo '<input type="hidden" name="actionmove" value="mupdate">'; |
| 625 | 625 | echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">'; |
| 626 | -echo '<input type="hidden" name="newdate" id="newdate">' ; |
|
| 626 | +echo '<input type="hidden" name="newdate" id="newdate">'; |
|
| 627 | 627 | |
| 628 | 628 | |
| 629 | 629 | // Line header with list of days |
@@ -633,13 +633,13 @@ discard block |
||
| 633 | 633 | $currentdaytoshow = $firstdaytoshow; |
| 634 | 634 | echo '<div class="div-table-responsive">'; |
| 635 | 635 | |
| 636 | -while($currentdaytoshow<$lastdaytoshow) { |
|
| 636 | +while ($currentdaytoshow < $lastdaytoshow) { |
|
| 637 | 637 | |
| 638 | 638 | echo '<table width="100%" class="noborder nocellnopadd cal_month">'; |
| 639 | 639 | |
| 640 | 640 | echo '<tr class="liste_titre">'; |
| 641 | 641 | echo '<td></td>'; |
| 642 | - $i=0; // 0 = sunday, |
|
| 642 | + $i = 0; // 0 = sunday, |
|
| 643 | 643 | while ($i < 7) |
| 644 | 644 | { |
| 645 | 645 | if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
@@ -648,10 +648,10 @@ discard block |
||
| 648 | 648 | continue; |
| 649 | 649 | } |
| 650 | 650 | echo '<td align="center" colspan="'.($end_h - $begin_h).'">'; |
| 651 | - echo $langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7)); |
|
| 651 | + echo $langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)); |
|
| 652 | 652 | print "<br>"; |
| 653 | - if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'),'day'); |
|
| 654 | - else print dol_print_date($currentdaytoshow,'day'); |
|
| 653 | + if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day'); |
|
| 654 | + else print dol_print_date($currentdaytoshow, 'day'); |
|
| 655 | 655 | echo "</td>\n"; |
| 656 | 656 | $i++; |
| 657 | 657 | } |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | |
| 660 | 660 | echo '<tr class="liste_titre">'; |
| 661 | 661 | echo '<td></td>'; |
| 662 | - $i=0; |
|
| 662 | + $i = 0; |
|
| 663 | 663 | while ($i < 7) |
| 664 | 664 | { |
| 665 | 665 | if (($i + 1) < $begin_d || ($i + 1) > $end_d) |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | for ($h = $begin_h; $h < $end_h; $h++) |
| 671 | 671 | { |
| 672 | 672 | echo '<td align="center">'; |
| 673 | - print '<small style="font-family: courier">'.sprintf("%02d",$h).'</small>'; |
|
| 673 | + print '<small style="font-family: courier">'.sprintf("%02d", $h).'</small>'; |
|
| 674 | 674 | print "</td>"; |
| 675 | 675 | } |
| 676 | 676 | echo "</td>\n"; |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | $usernames = array(); //init |
| 684 | 684 | $usernamesid = array(); |
| 685 | 685 | /* Use this to have list of users only if users have events */ |
| 686 | - if (! empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW)) |
|
| 686 | + if (!empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW)) |
|
| 687 | 687 | { |
| 688 | 688 | foreach ($eventarray as $daykey => $notused) |
| 689 | 689 | { |
@@ -691,10 +691,10 @@ discard block |
||
| 691 | 691 | foreach ($eventarray[$daykey] as $index => $event) |
| 692 | 692 | { |
| 693 | 693 | $event->fetch_userassigned(); |
| 694 | - $listofuserid=$event->userassigned; |
|
| 695 | - foreach($listofuserid as $userid => $tmp) |
|
| 694 | + $listofuserid = $event->userassigned; |
|
| 695 | + foreach ($listofuserid as $userid => $tmp) |
|
| 696 | 696 | { |
| 697 | - if (! in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; |
|
| 697 | + if (!in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; |
|
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | } |
@@ -703,12 +703,12 @@ discard block |
||
| 703 | 703 | else |
| 704 | 704 | { |
| 705 | 705 | $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; |
| 706 | - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; |
|
| 707 | - if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; |
|
| 708 | - $sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; |
|
| 709 | - if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup; |
|
| 706 | + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; |
|
| 707 | + if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; |
|
| 708 | + $sql .= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; |
|
| 709 | + if ($usergroup > 0) $sql .= " AND ug.fk_usergroup = ".$usergroup; |
|
| 710 | 710 | //print $sql; |
| 711 | - $resql=$db->query($sql); |
|
| 711 | + $resql = $db->query($sql); |
|
| 712 | 712 | if ($resql) |
| 713 | 713 | { |
| 714 | 714 | $num = $db->num_rows($resql); |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | while ($i < $num) |
| 719 | 719 | { |
| 720 | 720 | $obj = $db->fetch_object($resql); |
| 721 | - $usernamesid[$obj->rowid]=$obj->rowid; |
|
| 721 | + $usernamesid[$obj->rowid] = $obj->rowid; |
|
| 722 | 722 | $i++; |
| 723 | 723 | } |
| 724 | 724 | } |
@@ -726,11 +726,11 @@ discard block |
||
| 726 | 726 | else dol_print_error($db); |
| 727 | 727 | } |
| 728 | 728 | //var_dump($usernamesid); |
| 729 | - foreach($usernamesid as $id) |
|
| 729 | + foreach ($usernamesid as $id) |
|
| 730 | 730 | { |
| 731 | - $tmpuser=new User($db); |
|
| 732 | - $result=$tmpuser->fetch($id); |
|
| 733 | - $usernames[]=$tmpuser; |
|
| 731 | + $tmpuser = new User($db); |
|
| 732 | + $result = $tmpuser->fetch($id); |
|
| 733 | + $usernames[] = $tmpuser; |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | /* |
@@ -754,27 +754,27 @@ discard block |
||
| 754 | 754 | }*/ |
| 755 | 755 | |
| 756 | 756 | // Load array of colors by type |
| 757 | - $colorsbytype=array(); |
|
| 758 | - $labelbytype=array(); |
|
| 759 | - $sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; |
|
| 760 | - $resql=$db->query($sql); |
|
| 757 | + $colorsbytype = array(); |
|
| 758 | + $labelbytype = array(); |
|
| 759 | + $sql = "SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position"; |
|
| 760 | + $resql = $db->query($sql); |
|
| 761 | 761 | while ($obj = $db->fetch_object($resql)) |
| 762 | 762 | { |
| 763 | - $colorsbytype[$obj->code]=$obj->color; |
|
| 764 | - $labelbytype[$obj->code]=$obj->libelle; |
|
| 763 | + $colorsbytype[$obj->code] = $obj->color; |
|
| 764 | + $labelbytype[$obj->code] = $obj->libelle; |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | // Loop on each user to show calendar |
| 768 | - $todayarray=dol_getdate($now,'fast'); |
|
| 768 | + $todayarray = dol_getdate($now, 'fast'); |
|
| 769 | 769 | $sav = $tmpday; |
| 770 | 770 | $showheader = true; |
| 771 | 771 | $var = false; |
| 772 | 772 | foreach ($usernames as $username) |
| 773 | 773 | { |
| 774 | - $var = ! $var; |
|
| 774 | + $var = !$var; |
|
| 775 | 775 | echo "<tr>"; |
| 776 | - echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">'; |
|
| 777 | - print $username->getNomUrl(-1,'',0,0,20,1,''); |
|
| 776 | + echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var ? ' cal_impair' : '').'">'; |
|
| 777 | + print $username->getNomUrl(-1, '', 0, 0, 20, 1, ''); |
|
| 778 | 778 | print '</td>'; |
| 779 | 779 | $tmpday = $sav; |
| 780 | 780 | |
@@ -791,16 +791,16 @@ discard block |
||
| 791 | 791 | |
| 792 | 792 | // Show days of the current week |
| 793 | 793 | $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd'); |
| 794 | - $tmparray = dol_getdate($curtime,'fast'); |
|
| 794 | + $tmparray = dol_getdate($curtime, 'fast'); |
|
| 795 | 795 | $tmpday = $tmparray['mday']; |
| 796 | 796 | $tmpmonth = $tmparray['mon']; |
| 797 | 797 | $tmpyear = $tmparray['year']; |
| 798 | 798 | |
| 799 | - $style='cal_current_month'; |
|
| 800 | - if ($iter_day == 6) $style.=' cal_other_month'; |
|
| 801 | - $today=0; |
|
| 802 | - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; |
|
| 803 | - if ($today) $style='cal_today_peruser'; |
|
| 799 | + $style = 'cal_current_month'; |
|
| 800 | + if ($iter_day == 6) $style .= ' cal_other_month'; |
|
| 801 | + $today = 0; |
|
| 802 | + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; |
|
| 803 | + if ($today) $style = 'cal_today_peruser'; |
|
| 804 | 804 | |
| 805 | 805 | show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
| 806 | 806 | |
@@ -813,21 +813,21 @@ discard block |
||
| 813 | 813 | echo "</table>\n"; |
| 814 | 814 | echo "<br>"; |
| 815 | 815 | |
| 816 | - $currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd'); |
|
| 816 | + $currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd'); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | echo '</div>'; |
| 820 | 820 | |
| 821 | -if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) |
|
| 821 | +if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && !empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) |
|
| 822 | 822 | { |
| 823 | 823 | $langs->load("commercial"); |
| 824 | 824 | print '<br>'.$langs->trans("Legend").': <br>'; |
| 825 | - foreach($colorsbytype as $code => $color) |
|
| 825 | + foreach ($colorsbytype as $code => $color) |
|
| 826 | 826 | { |
| 827 | 827 | if ($color) |
| 828 | 828 | { |
| 829 | - print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color?'background: #'.$color.';':'').'width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 830 | - print $langs->trans("Action".$code)!="Action".$code?$langs->trans("Action".$code):$labelbytype[$code]; |
|
| 829 | + print '<div style="float: left; padding: 2px; margin-right: 6px;"><div style="'.($color ? 'background: #'.$color.';' : '').'width:16px; float: left; margin-right: 4px;"> </div>'; |
|
| 830 | + print $langs->trans("Action".$code) != "Action".$code ? $langs->trans("Action".$code) : $labelbytype[$code]; |
|
| 831 | 831 | //print $code; |
| 832 | 832 | print '</div>'; |
| 833 | 833 | } |
@@ -908,125 +908,125 @@ discard block |
||
| 908 | 908 | * @param bool $var true or false for alternat style on tr/td |
| 909 | 909 | * @return void |
| 910 | 910 | */ |
| 911 | -function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false, $colorsbytype=array(), $var=false) |
|
| 911 | +function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $showheader = false, $colorsbytype = array(), $var = false) |
|
| 912 | 912 | { |
| 913 | 913 | global $db; |
| 914 | 914 | global $user, $conf, $langs, $hookmanager, $action; |
| 915 | - global $filter, $filtert, $status, $actioncode; // Filters used into search form |
|
| 916 | - global $theme_datacolor; // Array with a list of different we can use (come from theme) |
|
| 915 | + global $filter, $filtert, $status, $actioncode; // Filters used into search form |
|
| 916 | + global $theme_datacolor; // Array with a list of different we can use (come from theme) |
|
| 917 | 917 | global $cachethirdparties, $cachecontacts, $cacheusers, $cacheprojects, $colorindexused; |
| 918 | 918 | global $begin_h, $end_h; |
| 919 | 919 | |
| 920 | - $cases1 = array(); // Color first half hour |
|
| 920 | + $cases1 = array(); // Color first half hour |
|
| 921 | 921 | $cases2 = array(); // Color second half hour |
| 922 | 922 | |
| 923 | 923 | $curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0); |
| 924 | 924 | |
| 925 | - $i=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); |
|
| 926 | - $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); |
|
| 925 | + $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); |
|
| 926 | + $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); |
|
| 927 | 927 | |
| 928 | - $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 |
|
| 929 | - $nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... |
|
| 928 | + $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 |
|
| 929 | + $nextindextouse = count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... |
|
| 930 | 930 | //if ($username->id && $day==1) var_dump($eventarray); |
| 931 | 931 | |
| 932 | 932 | // We are in a particular day for $username, now we scan all events |
| 933 | 933 | foreach ($eventarray as $daykey => $notused) |
| 934 | 934 | { |
| 935 | - $annee = date('Y',$daykey); |
|
| 936 | - $mois = date('m',$daykey); |
|
| 937 | - $jour = date('d',$daykey); |
|
| 935 | + $annee = date('Y', $daykey); |
|
| 936 | + $mois = date('m', $daykey); |
|
| 937 | + $jour = date('d', $daykey); |
|
| 938 | 938 | //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n"; |
| 939 | 939 | |
| 940 | - if ($day==$jour && $month==$mois && $year==$annee) // Is it the day we are looking for when calling function ? |
|
| 940 | + if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ? |
|
| 941 | 941 | { |
| 942 | 942 | // Scan all event for this date |
| 943 | 943 | foreach ($eventarray[$daykey] as $index => $event) |
| 944 | 944 | { |
| 945 | 945 | //var_dump($event); |
| 946 | 946 | |
| 947 | - $keysofuserassigned=array_keys($event->userassigned); |
|
| 948 | - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); |
|
| 947 | + $keysofuserassigned = array_keys($event->userassigned); |
|
| 948 | + $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); |
|
| 949 | 949 | |
| 950 | - if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 950 | + if (!in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 951 | 951 | //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
| 952 | 952 | |
| 953 | - $parameters=array(); |
|
| 954 | - $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks |
|
| 953 | + $parameters = array(); |
|
| 954 | + $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks |
|
| 955 | 955 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 956 | 956 | |
| 957 | 957 | // Define $color (Hex string like '0088FF') and $cssclass of event |
| 958 | - $color=-1; $cssclass=''; $colorindex=-1; |
|
| 958 | + $color = -1; $cssclass = ''; $colorindex = -1; |
|
| 959 | 959 | if (in_array($user->id, $keysofuserassigned)) |
| 960 | 960 | { |
| 961 | - $cssclass='family_mytasks'; |
|
| 961 | + $cssclass = 'family_mytasks'; |
|
| 962 | 962 | |
| 963 | 963 | if (empty($cacheusers[$event->userownerid])) |
| 964 | 964 | { |
| 965 | - $newuser=new User($db); |
|
| 965 | + $newuser = new User($db); |
|
| 966 | 966 | $newuser->fetch($event->userownerid); |
| 967 | - $cacheusers[$event->userownerid]=$newuser; |
|
| 967 | + $cacheusers[$event->userownerid] = $newuser; |
|
| 968 | 968 | } |
| 969 | 969 | //var_dump($cacheusers[$event->userownerid]->color); |
| 970 | 970 | |
| 971 | 971 | // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
| 972 | - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; |
|
| 972 | + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; |
|
| 973 | 973 | |
| 974 | - if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; |
|
| 974 | + if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color; |
|
| 975 | 975 | } |
| 976 | 976 | else if ($event->type_code == 'ICALEVENT') |
| 977 | 977 | { |
| 978 | 978 | $numical++; |
| 979 | - if (! empty($event->icalname)) |
|
| 979 | + if (!empty($event->icalname)) |
|
| 980 | 980 | { |
| 981 | - if (! isset($numicals[dol_string_nospecial($event->icalname)])) { |
|
| 981 | + if (!isset($numicals[dol_string_nospecial($event->icalname)])) { |
|
| 982 | 982 | $numicals[dol_string_nospecial($event->icalname)] = 0; |
| 983 | 983 | } |
| 984 | 984 | $numicals[dol_string_nospecial($event->icalname)]++; |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | - $color=$event->icalcolor; |
|
| 988 | - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other unsortable'); |
|
| 987 | + $color = $event->icalcolor; |
|
| 988 | + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other unsortable'); |
|
| 989 | 989 | } |
| 990 | 990 | else if ($event->type_code == 'BIRTHDAY') |
| 991 | 991 | { |
| 992 | - $numbirthday++; $colorindex=2; $cssclass='family_birthday unsortable'; $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 992 | + $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); |
|
| 993 | 993 | } |
| 994 | 994 | else |
| 995 | 995 | { |
| 996 | 996 | $numother++; |
| 997 | - $color=($event->icalcolor?$event->icalcolor:-1); |
|
| 998 | - $cssclass=(! empty($event->icalname)?'family_ext'.md5($event->icalname):'family_other'); |
|
| 997 | + $color = ($event->icalcolor ? $event->icalcolor : -1); |
|
| 998 | + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); |
|
| 999 | 999 | |
| 1000 | 1000 | if (empty($cacheusers[$event->userownerid])) |
| 1001 | 1001 | { |
| 1002 | - $newuser=new User($db); |
|
| 1002 | + $newuser = new User($db); |
|
| 1003 | 1003 | $newuser->fetch($event->userownerid); |
| 1004 | - $cacheusers[$event->userownerid]=$newuser; |
|
| 1004 | + $cacheusers[$event->userownerid] = $newuser; |
|
| 1005 | 1005 | } |
| 1006 | 1006 | //var_dump($cacheusers[$event->userownerid]->color); |
| 1007 | 1007 | |
| 1008 | 1008 | // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
| 1009 | - if (! empty($cacheusers[$event->userownerid]->color)) $color=$cacheusers[$event->userownerid]->color; |
|
| 1009 | + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; |
|
| 1010 | 1010 | |
| 1011 | - if (! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color=$event->type_color; |
|
| 1011 | + if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color; |
|
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | if ($color < 0) // Color was not set on user card. Set color according to color index. |
| 1015 | 1015 | { |
| 1016 | 1016 | // Define color index if not yet defined |
| 1017 | - $idusertouse=($event->userownerid?$event->userownerid:0); |
|
| 1017 | + $idusertouse = ($event->userownerid ? $event->userownerid : 0); |
|
| 1018 | 1018 | if (isset($colorindexused[$idusertouse])) |
| 1019 | 1019 | { |
| 1020 | - $colorindex=$colorindexused[$idusertouse]; // Color already assigned to this user |
|
| 1020 | + $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user |
|
| 1021 | 1021 | } |
| 1022 | 1022 | else |
| 1023 | 1023 | { |
| 1024 | - $colorindex=$nextindextouse; |
|
| 1025 | - $colorindexused[$idusertouse]=$colorindex; |
|
| 1026 | - if (! empty($theme_datacolor[$nextindextouse+1])) $nextindextouse++; // Prepare to use next color |
|
| 1024 | + $colorindex = $nextindextouse; |
|
| 1025 | + $colorindexused[$idusertouse] = $colorindex; |
|
| 1026 | + if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color |
|
| 1027 | 1027 | } |
| 1028 | 1028 | // Define color |
| 1029 | - $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); |
|
| 1029 | + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); |
|
| 1030 | 1030 | } |
| 1031 | 1031 | //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd; |
| 1032 | 1032 | |
@@ -1037,211 +1037,211 @@ discard block |
||
| 1037 | 1037 | $newcolor = ''; //init |
| 1038 | 1038 | if (empty($event->fulldayevent)) |
| 1039 | 1039 | { |
| 1040 | - $a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0); |
|
| 1041 | - $b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0); |
|
| 1042 | - $c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0); |
|
| 1040 | + $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, false, 0); |
|
| 1041 | + $b = dol_mktime((int) $h, 30, 0, $month, $day, $year, false, 0); |
|
| 1042 | + $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, false, 0); |
|
| 1043 | 1043 | |
| 1044 | - $dateendtouse=$event->date_end_in_calendar; |
|
| 1045 | - if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++; |
|
| 1044 | + $dateendtouse = $event->date_end_in_calendar; |
|
| 1045 | + if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++; |
|
| 1046 | 1046 | |
| 1047 | 1047 | //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
| 1048 | 1048 | |
| 1049 | 1049 | if ($event->date_start_in_calendar < $b && $dateendtouse > $a) |
| 1050 | 1050 | { |
| 1051 | - $busy=$event->transparency; |
|
| 1052 | - $cases1[$h][$event->id]['busy']=$busy; |
|
| 1053 | - $cases1[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 1051 | + $busy = $event->transparency; |
|
| 1052 | + $cases1[$h][$event->id]['busy'] = $busy; |
|
| 1053 | + $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); |
|
| 1054 | 1054 | if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
| 1055 | 1055 | { |
| 1056 | - $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 1057 | - $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 1058 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1059 | - else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1056 | + $tmpa = dol_getdate($event->date_start_in_calendar, true); |
|
| 1057 | + $tmpb = dol_getdate($event->date_end_in_calendar, true); |
|
| 1058 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); |
|
| 1059 | + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); |
|
| 1060 | 1060 | } |
| 1061 | - if ($event->label) $cases1[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1062 | - $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 1063 | - $cases1[$h][$event->id]['color']=$color; |
|
| 1061 | + if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 1062 | + $cases1[$h][$event->id]['typecode'] = $event->type_code; |
|
| 1063 | + $cases1[$h][$event->id]['color'] = $color; |
|
| 1064 | 1064 | if ($event->fk_project > 0) |
| 1065 | 1065 | { |
| 1066 | 1066 | if (empty($cacheprojects[$event->fk_project])) |
| 1067 | 1067 | { |
| 1068 | - $tmpproj=new Project($db); |
|
| 1068 | + $tmpproj = new Project($db); |
|
| 1069 | 1069 | $tmpproj->fetch($event->fk_project); |
| 1070 | - $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 1070 | + $cacheprojects[$event->fk_project] = $tmpproj; |
|
| 1071 | 1071 | } |
| 1072 | - $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 1072 | + $cases1[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 1073 | 1073 | } |
| 1074 | 1074 | if ($event->socid > 0) |
| 1075 | 1075 | { |
| 1076 | 1076 | if (empty($cachethirdparties[$event->socid])) |
| 1077 | 1077 | { |
| 1078 | - $tmpthirdparty=new Societe($db); |
|
| 1078 | + $tmpthirdparty = new Societe($db); |
|
| 1079 | 1079 | $tmpthirdparty->fetch($event->socid); |
| 1080 | - $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 1080 | + $cachethirdparties[$event->socid] = $tmpthirdparty; |
|
| 1081 | 1081 | } |
| 1082 | - $cases1[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 1082 | + $cases1[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | if ($event->contactid > 0) |
| 1085 | 1085 | { |
| 1086 | 1086 | if (empty($cachecontacts[$event->contactid])) |
| 1087 | 1087 | { |
| 1088 | - $tmpcontact=new Contact($db); |
|
| 1088 | + $tmpcontact = new Contact($db); |
|
| 1089 | 1089 | $tmpcontact->fetch($event->contactid); |
| 1090 | - $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 1090 | + $cachecontacts[$event->contactid] = $tmpcontact; |
|
| 1091 | 1091 | } |
| 1092 | - $cases1[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 1092 | + $cases1[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 1093 | 1093 | } |
| 1094 | 1094 | } |
| 1095 | 1095 | if ($event->date_start_in_calendar < $c && $dateendtouse > $b) |
| 1096 | 1096 | { |
| 1097 | - $busy=$event->transparency; |
|
| 1098 | - $cases2[$h][$event->id]['busy']=$busy; |
|
| 1099 | - $cases2[$h][$event->id]['string']=dol_print_date($event->date_start_in_calendar,'dayhour'); |
|
| 1097 | + $busy = $event->transparency; |
|
| 1098 | + $cases2[$h][$event->id]['busy'] = $busy; |
|
| 1099 | + $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); |
|
| 1100 | 1100 | if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) |
| 1101 | 1101 | { |
| 1102 | - $tmpa=dol_getdate($event->date_start_in_calendar,true); |
|
| 1103 | - $tmpb=dol_getdate($event->date_end_in_calendar,true); |
|
| 1104 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); |
|
| 1105 | - else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); |
|
| 1102 | + $tmpa = dol_getdate($event->date_start_in_calendar, true); |
|
| 1103 | + $tmpb = dol_getdate($event->date_end_in_calendar, true); |
|
| 1104 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); |
|
| 1105 | + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); |
|
| 1106 | 1106 | } |
| 1107 | - if ($event->label) $cases2[$h][$event->id]['string'].=' - '.$event->label; |
|
| 1108 | - $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 1109 | - $cases2[$h][$event->id]['color']=$color; |
|
| 1107 | + if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 1108 | + $cases2[$h][$event->id]['typecode'] = $event->type_code; |
|
| 1109 | + $cases2[$h][$event->id]['color'] = $color; |
|
| 1110 | 1110 | if ($event->fk_project > 0) |
| 1111 | 1111 | { |
| 1112 | 1112 | if (empty($cacheprojects[$event->fk_project])) |
| 1113 | 1113 | { |
| 1114 | - $tmpproj=new Project($db); |
|
| 1114 | + $tmpproj = new Project($db); |
|
| 1115 | 1115 | $tmpproj->fetch($event->fk_project); |
| 1116 | - $cacheprojects[$event->fk_project]=$tmpproj; |
|
| 1116 | + $cacheprojects[$event->fk_project] = $tmpproj; |
|
| 1117 | 1117 | } |
| 1118 | - $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 1118 | + $cases2[$h][$event->id]['string'] .= ', '.$langs->trans("Project").': '.$cacheprojects[$event->fk_project]->ref.' - '.$cacheprojects[$event->fk_project]->title; |
|
| 1119 | 1119 | } |
| 1120 | 1120 | if ($event->socid > 0) |
| 1121 | 1121 | { |
| 1122 | 1122 | if (empty($cachethirdparties[$event->socid])) |
| 1123 | 1123 | { |
| 1124 | - $tmpthirdparty=new Societe($db); |
|
| 1124 | + $tmpthirdparty = new Societe($db); |
|
| 1125 | 1125 | $tmpthirdparty->fetch($event->socid); |
| 1126 | - $cachethirdparties[$event->socid]=$tmpthirdparty; |
|
| 1126 | + $cachethirdparties[$event->socid] = $tmpthirdparty; |
|
| 1127 | 1127 | } |
| 1128 | - $cases2[$h][$event->id]['string'].=', '.$cachethirdparties[$event->socid]->name; |
|
| 1128 | + $cases2[$h][$event->id]['string'] .= ', '.$cachethirdparties[$event->socid]->name; |
|
| 1129 | 1129 | } |
| 1130 | 1130 | if ($event->contactid > 0) |
| 1131 | 1131 | { |
| 1132 | 1132 | if (empty($cachecontacts[$event->contactid])) |
| 1133 | 1133 | { |
| 1134 | - $tmpcontact=new Contact($db); |
|
| 1134 | + $tmpcontact = new Contact($db); |
|
| 1135 | 1135 | $tmpcontact->fetch($event->contactid); |
| 1136 | - $cachecontacts[$event->contactid]=$tmpcontact; |
|
| 1136 | + $cachecontacts[$event->contactid] = $tmpcontact; |
|
| 1137 | 1137 | } |
| 1138 | - $cases2[$h][$event->id]['string'].=', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 1138 | + $cases2[$h][$event->id]['string'] .= ', '.$cachecontacts[$event->contactid]->getFullName($langs); |
|
| 1139 | 1139 | } |
| 1140 | 1140 | } |
| 1141 | 1141 | } |
| 1142 | 1142 | else |
| 1143 | 1143 | { |
| 1144 | - $busy=$event->transparency; |
|
| 1145 | - $cases1[$h][$event->id]['busy']=$busy; |
|
| 1146 | - $cases2[$h][$event->id]['busy']=$busy; |
|
| 1147 | - $cases1[$h][$event->id]['string']=$event->label; |
|
| 1148 | - $cases2[$h][$event->id]['string']=$event->label; |
|
| 1149 | - $cases1[$h][$event->id]['typecode']=$event->type_code; |
|
| 1150 | - $cases2[$h][$event->id]['typecode']=$event->type_code; |
|
| 1151 | - $cases1[$h][$event->id]['color']=$color; |
|
| 1152 | - $cases2[$h][$event->id]['color']=$color; |
|
| 1144 | + $busy = $event->transparency; |
|
| 1145 | + $cases1[$h][$event->id]['busy'] = $busy; |
|
| 1146 | + $cases2[$h][$event->id]['busy'] = $busy; |
|
| 1147 | + $cases1[$h][$event->id]['string'] = $event->label; |
|
| 1148 | + $cases2[$h][$event->id]['string'] = $event->label; |
|
| 1149 | + $cases1[$h][$event->id]['typecode'] = $event->type_code; |
|
| 1150 | + $cases2[$h][$event->id]['typecode'] = $event->type_code; |
|
| 1151 | + $cases1[$h][$event->id]['color'] = $color; |
|
| 1152 | + $cases2[$h][$event->id]['color'] = $color; |
|
| 1153 | 1153 | } |
| 1154 | 1154 | } |
| 1155 | 1155 | $i++; |
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | - break; // We found the date we were looking for. No need to search anymore. |
|
| 1158 | + break; // We found the date we were looking for. No need to search anymore. |
|
| 1159 | 1159 | } |
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | 1162 | // Now output $casesX |
| 1163 | 1163 | for ($h = $begin_h; $h < $end_h; $h++) |
| 1164 | 1164 | { |
| 1165 | - $color1='';$color2=''; |
|
| 1166 | - $style1='';$style2=''; |
|
| 1167 | - $string1=' ';$string2=' '; |
|
| 1168 | - $title1='';$title2=''; |
|
| 1165 | + $color1 = ''; $color2 = ''; |
|
| 1166 | + $style1 = ''; $style2 = ''; |
|
| 1167 | + $string1 = ' '; $string2 = ' '; |
|
| 1168 | + $title1 = ''; $title2 = ''; |
|
| 1169 | 1169 | if (isset($cases1[$h]) && $cases1[$h] != '') |
| 1170 | 1170 | { |
| 1171 | 1171 | //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1172 | - if (count($cases1[$h]) > 1) $title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1173 | - $string1=' '; |
|
| 1174 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1='peruser_notbusy'; |
|
| 1175 | - else $style1='peruser_busy'; |
|
| 1176 | - foreach($cases1[$h] as $id => $ev) |
|
| 1172 | + if (count($cases1[$h]) > 1) $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1173 | + $string1 = ' '; |
|
| 1174 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 = 'peruser_notbusy'; |
|
| 1175 | + else $style1 = 'peruser_busy'; |
|
| 1176 | + foreach ($cases1[$h] as $id => $ev) |
|
| 1177 | 1177 | { |
| 1178 | - if ($ev['busy']) $style1='peruser_busy'; |
|
| 1178 | + if ($ev['busy']) $style1 = 'peruser_busy'; |
|
| 1179 | 1179 | } |
| 1180 | 1180 | } |
| 1181 | 1181 | if (isset($cases2[$h]) && $cases2[$h] != '') |
| 1182 | 1182 | { |
| 1183 | 1183 | //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1184 | - if (count($cases2[$h]) > 1) $title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
|
| 1185 | - $string2=' '; |
|
| 1186 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2='peruser_notbusy'; |
|
| 1187 | - else $style2='peruser_busy'; |
|
| 1188 | - foreach($cases2[$h] as $id => $ev) |
|
| 1184 | + if (count($cases2[$h]) > 1) $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1185 | + $string2 = ' '; |
|
| 1186 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 = 'peruser_notbusy'; |
|
| 1187 | + else $style2 = 'peruser_busy'; |
|
| 1188 | + foreach ($cases2[$h] as $id => $ev) |
|
| 1189 | 1189 | { |
| 1190 | - if ($ev['busy']) $style2='peruser_busy'; |
|
| 1190 | + if ($ev['busy']) $style2 = 'peruser_busy'; |
|
| 1191 | 1191 | } |
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | - $ids1='';$ids2=''; |
|
| 1195 | - if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',',array_keys($cases1[$h])); |
|
| 1196 | - if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',',array_keys($cases2[$h])); |
|
| 1194 | + $ids1 = ''; $ids2 = ''; |
|
| 1195 | + if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); |
|
| 1196 | + if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h])); |
|
| 1197 | 1197 | |
| 1198 | - if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1199 | - else echo '<td class="'.$style.' cal_peruser'.($var?' cal_impair '.$style.'_impair':'').'">'; |
|
| 1198 | + if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1199 | + else echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1200 | 1200 | if (count($cases1[$h]) == 1) // only 1 event |
| 1201 | 1201 | { |
| 1202 | 1202 | $output = array_slice($cases1[$h], 0, 1); |
| 1203 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1204 | - if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string']; |
|
| 1203 | + $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); |
|
| 1204 | + if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; |
|
| 1205 | 1205 | if ($output[0]['color']) $color1 = $output[0]['color']; |
| 1206 | 1206 | } |
| 1207 | 1207 | else if (count($cases1[$h]) > 1) |
| 1208 | 1208 | { |
| 1209 | - $title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:''); |
|
| 1210 | - $color1='222222'; |
|
| 1209 | + $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); |
|
| 1210 | + $color1 = '222222'; |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | if (count($cases2[$h]) == 1) // only 1 event |
| 1214 | 1214 | { |
| 1215 | 1215 | $output = array_slice($cases2[$h], 0, 1); |
| 1216 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1217 | - if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string']; |
|
| 1216 | + $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); |
|
| 1217 | + if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; |
|
| 1218 | 1218 | if ($output[0]['color']) $color2 = $output[0]['color']; |
| 1219 | 1219 | } |
| 1220 | 1220 | else if (count($cases2[$h]) > 1) |
| 1221 | 1221 | { |
| 1222 | - $title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:''); |
|
| 1223 | - $color2='222222'; |
|
| 1222 | + $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); |
|
| 1223 | + $color2 = '222222'; |
|
| 1224 | 1224 | } |
| 1225 | 1225 | print '<table class="nobordernopadding" width="100%">'; |
| 1226 | 1226 | print '<tr><td '; |
| 1227 | - if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1?$color1:"888").' !important" '; |
|
| 1227 | + if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1 ? $color1 : "888").' !important" '; |
|
| 1228 | 1228 | elseif ($color1) |
| 1229 | 1229 | { |
| 1230 | - print ($color1?'style="background: #'.$color1.';"':''); |
|
| 1230 | + print ($color1 ? 'style="background: #'.$color1.';"' : ''); |
|
| 1231 | 1231 | } |
| 1232 | 1232 | print 'class="'; |
| 1233 | - print ($style1?$style1.' ':''); |
|
| 1234 | - print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_00_'.($ids1?$ids1:'none').'"'.($title1?' title="'.$title1.'"':'').'>'; |
|
| 1233 | + print ($style1 ? $style1.' ' : ''); |
|
| 1234 | + print 'onclickopenref'.($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>'; |
|
| 1235 | 1235 | print $string1; |
| 1236 | 1236 | print '</td><td '; |
| 1237 | - if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2?$color2:"888").' !important" '; |
|
| 1237 | + if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2 ? $color2 : "888").' !important" '; |
|
| 1238 | 1238 | elseif ($color2) |
| 1239 | 1239 | { |
| 1240 | - print ($color2?'style="background: #'.$color2.';"':''); |
|
| 1240 | + print ($color2 ? 'style="background: #'.$color2.';"' : ''); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | print 'class="'; |
| 1243 | - print ($style2?$style2.' ':''); |
|
| 1244 | - print 'onclickopenref'.($title1?' cursorpointer':'').'" ref="ref_'.$username->id.'_'.sprintf("%04d",$year).'_'.sprintf("%02d",$month).'_'.sprintf("%02d",$day).'_'.sprintf("%02d",$h).'_30_'.($ids2?$ids2:'none').'"'.($title2?' title="'.$title2.'"':'').'>'; |
|
| 1243 | + print ($style2 ? $style2.' ' : ''); |
|
| 1244 | + print 'onclickopenref'.($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids2 ? $ids2 : 'none').'"'.($title2 ? ' title="'.$title2.'"' : '').'>'; |
|
| 1245 | 1245 | print $string2; |
| 1246 | 1246 | print '</td></tr>'; |
| 1247 | 1247 | print '</table>'; |