function p__body(){ var self=this; this.root="p__body"; this.to_login; this.processed=false; this.navigation; this.go_back=function(){ go_back(); } this.temp=function(){ var html=''; html+=''; html+='
'; html+='
'; html+='
'; html+='
'; html+=''; html+='
'; html+='
'; html+='
'; html+=''; html+=''; html+='
'; html+='
'; html+='
'; html+=' '; html+=' '; html+=' '; html+=' '; html+='
'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+=''; html+='
'; return html; } this.process=function(){ if(!self.processed){ self.processed=true; $("#"+self.root).html(self.temp()); $('.back_button').click( self.go_back ); $(".menu_refresh").click(function() { load_url((location.pathname+location.search).substr(1)); }); $(".fa-sign-out").click(function(){ system.logout(function(){ load_url('dashboard',[]); }); }); self.navigation=new s__navigation_menu_item("#main_navigation",navigation_menu); $(".menu_toggle").click(function() { if( $("#rear_menu").hasClass('hide_menu')) $("#rear_menu").removeClass('hide_menu'); else $("#rear_menu").addClass('hide_menu'); }); vpage_name_register['p__body']=function(name){ self.set_menu_title(name); } $('.panel_icon').click(function(){ $('.panel_container').hide(); }); } $("#firm_name").html((user_profile)?user_profile.A00_name:''); $(".copyright").html((user_profile)?user_profile.A00_copyright:''); if( !$("#rear_menu").hasClass('hide_menu')) $("#rear_menu").addClass('hide_menu'); if(urls.length==0) $('.back_button').hide(); else $('.back_button').show(); self.navigation.refresh(); self.navigation.set_url(c_url); $("#main_content_top_right_bar").empty(); } this.set_navigation_pending=function(menu_item,count){ self.navigation[menu_item].set_pending_count(count); } this.set_menu_title=function(menu_title){ $(".menu_title").html(menu_title); } this.callpre=function(state,pstate,callback){ $('.profile_name').text(user_profile.A05_firstname+" "+user_profile.A05_lastname); if(self.to_login) clearInterval(self.to_login); self.to_login=setInterval(function(){ $('.profile_time').text( formatDuration(Math.round(Date.now() / 1000) -user_profile.A05_last_login)); },1000); //$('.main_content').empty(); if(typeof(callback)=="function") callback(); } } var __p__body=new p__body(); function _p__body__data( callback ) { __p__body.process(); callback(); } var _p__body__callpre=__p__body.callpre; ajaxRender.addCall(_p__body__data); function p__login(){ var self=this; this.root="p__login"; this.temp=function(){ var html=''; html+=''; html+='
'; html+='
'; html+=' '; html+='
'; html+='
'; return html; } this.process=function(){ $("#"+self.root).html(self.temp()); $(function() { $("#page_overlay").fadeOut(); $(".login_button").click(function(e) { e.preventDefault(); $(".login_warning").hide(); $(".login_button").hide(); $(".login_loading").show(); login( function(data) { console.log(data); if(data && Object.keys(data).length>0) { load_url(c_url,data); }else{ $(".login_loading").hide(); $(".login_part").fadeIn(); $(".login_button").show(); $(".login_warning").html("Invalid Login"); $(".login_warning").fadeIn(); $("#pass").val(""); $("#pass").focus(); } },$("#user").val(), $("#pass").val()); }); }); } } var __p__login=new p__login(); function _p__login__data( callback ) { __p__login.process(); callback(); } ajaxRender.addCall(_p__login__data); function c__admin_firms(){ var self=this; this.root="c__admin_firms"; this.processed=false; this.table; this.filter={}; this.register; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__admin_firms_table('#'+self.root); self.register= new k__firm_register_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_register=function(){ self.top_bar.add_top_bar_button('register','Register','register','green','pencil-square', function(){ self.register.process( function(register_option){ if(Object.keys(register_option).length>0 && register_option['A00_name']){ system.firm_register(function(data){ self.table.process(); },register_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if(user_profile.A05_firm ==-1) self.create_register(); //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__admin_firms=new c__admin_firms(); function _c__admin_firms__data( callback ) { __c__admin_firms.process(); callback(); } var _c__admin_firms__callpre=__c__admin_firms.callpre; ajaxRender.addCall(_c__admin_firms__data,"_p__body__data"); function c__dashboard(){ var self=this; this.root="c__dashboard"; this.processed=false; this.main_area=function(data){ var html=''; html+='
'; html+='
'; if(parseInt(data['project_all'])>0){ html+='

Production

'; html+='
Total: '+data['project_all']+'
'; html+='
Active: '+data['project_active']+'
'; html+='
Wrapped: '+data['project_wrapped']+'
'; html+='
Inactive: '+data['project_inactive']+'
'; html+='
'; } if(parseInt(data['production_all'])>0){ html+='
'; html+='

DPR

'; html+='
Total: '+data['production_all']+'
'; html+='
Closed: '+data['production_closed']+'
'; html+='
Open: '+data['production_open']+'
'; html+='
'; } if(parseInt(data['dtr_all'])>0 && data['dtr_all'] !=data['my_dtr_all']){ html+='
'; html+='

DTR

'; html+='
Total: '+data['dtr_all']+'
'; html+='
Closed: '+data['dtr_approved']+'
'; html+='
Open: '+data['dtr_open']+'
'; html+='
'; } if(parseInt(data['my_dtr_all'])>0){ html+='
'; html+='

My DTR

'; html+='
Total: '+data['my_dtr_all']+'
'; html+='
Closed: '+data['my_dtr_approved']+'
'; html+='
Open: '+data['my_dtr_open']+'
'; html+='
'; } html+='
'; html+=''; return html; } this.process=function(data){ if(!self.processed){ $(".main_content").append(""); self.processed=true; } $('#'+self.root).html(self.main_area(data)); } this.callpre=function(state,pstate,callback){ if(typeof(callback)=="function") callback(); } } var __c__dashboard=new c__dashboard(); function _c__dashboard__data( callback ) { get_dashboard(function(data){ __c__dashboard.process(data); callback(); }); } var _c__dashboard__callpre=__c__dashboard.callpre; ajaxRender.addCall(_c__dashboard__data,"_p__body__data"); function c__firm_departments(){ var self=this; this.root="c__firm_departments"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__firm_departments_table('#'+self.root); self.add= new k__department_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0){ system.department_add(function(data){ self.table.process(); },add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if(parseInt(user_profile.A05_priv)>=5) self.create_add(); //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__firm_departments=new c__firm_departments(); function _c__firm_departments__data( callback ) { __c__firm_departments.process(); callback(); } var _c__firm_departments__callpre=__c__firm_departments.callpre; ajaxRender.addCall(_c__firm_departments__data,"_p__body__data"); function c__firm_positions(){ var self=this; this.root="c__firm_positions"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__firm_positions_table('#'+self.root); self.add= new k__position_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0){ system.position_add(function(data){ self.table.process(); },add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if(parseInt(user_profile.A05_priv)>=5) self.create_add(); //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__firm_positions=new c__firm_positions(); function _c__firm_positions__data( callback ) { __c__firm_positions.process(); callback(); } var _c__firm_positions__callpre=__c__firm_positions.callpre; ajaxRender.addCall(_c__firm_positions__data,"_p__body__data"); function c__firm_projects(){ var self=this; this.root="c__firm_projects"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__firm_projects_table('#'+self.root); self.add= new k__project_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0){ system.project_add(function(data){ self.table.process(); },add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if(parseInt(user_profile.A05_priv)>=5) self.create_add(); //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__firm_projects=new c__firm_projects(); function _c__firm_projects__data( callback ) { __c__firm_projects.process(); callback(); } var _c__firm_projects__callpre=__c__firm_projects.callpre; ajaxRender.addCall(_c__firm_projects__data,"_p__body__data"); function c__firm_users(){ var self=this; this.root="c__firm_users"; this.processed=false; this.table; this.filter={}; this.register; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__firm_users_table('#'+self.root); self.register= new k__user_register_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_register=function(){ self.top_bar.add_top_bar_button('register','Register','register','green','pencil-square', function(){ self.register.process( function(register_option){ if(Object.keys(register_option).length>0){ system.user_register(function(data){ self.table.process(); },register_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if(parseInt(user_profile.A05_priv)>=5) self.create_register(); //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__firm_users=new c__firm_users(); function _c__firm_users__data( callback ) { __c__firm_users.process(); callback(); } var _c__firm_users__callpre=__c__firm_users.callpre; ajaxRender.addCall(_c__firm_users__data,"_p__body__data"); function c__production_comments(){ var self=this; this.root="c__production_comments"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__production_comments_table('#'+self.root); self.add= new k__comment_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0 && add_option['C04_name'] ){ system.comment_add(function(data){ self.table.process(); },global_params['project_id'],global_params['pproduction_id'],add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if(( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) && global_params['pproduction_id']) { let project_id=global_params['project_id'] || 0; let pproduction_id = global_params['pproduction_id'] || 0; if(pproduction_id && project_id){ system.get_pproduction_brief(function(data){ if(data && data.production_closed=='0' && data.project_status=='active'){ self.create_add(); } },project_id,pproduction_id); } } //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__production_comments=new c__production_comments(); function _c__production_comments__data( callback ) { __c__production_comments.process(); callback(); } var _c__production_comments__callpre=__c__production_comments.callpre; ajaxRender.addCall(_c__production_comments__data,"_p__body__data"); function c__production_locations(){ var self=this; this.root="c__production_locations"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__production_locations_table('#'+self.root); self.add= new k__location_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0 && add_option['C02_name'] ){ system.location_add(function(data){ self.table.process(); },global_params['project_id'],global_params['pproduction_id'],add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if(( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) && global_params['pproduction_id']){ let project_id=global_params['project_id'] || 0; let pproduction_id = global_params['pproduction_id'] || 0; if(pproduction_id && project_id){ system.get_pproduction_brief(function(data){ if(data && data.production_closed=='0' && data.project_status=='active'){ self.create_add(); } },project_id,pproduction_id); } } //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__production_locations=new c__production_locations(); function _c__production_locations__data( callback ) { __c__production_locations.process(); callback(); } var _c__production_locations__callpre=__c__production_locations.callpre; ajaxRender.addCall(_c__production_locations__data,"_p__body__data"); function c__production_prs(){ var self=this; this.root="c__production_prs"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__production_prs_table('#'+self.root); self.add= new k__pr_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0 && add_option['C00_user'] && global_params['project_id'] && global_params['pproduction_id']){ system.tr_add(function(data){ self.table.process(); },global_params['project_id'],global_params['pproduction_id'],add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if((global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) && global_params['pproduction_id']) self.create_add(); //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__production_prs=new c__production_prs(); function _c__production_prs__data( callback ) { __c__production_prs.process(); callback(); } var _c__production_prs__callpre=__c__production_prs.callpre; ajaxRender.addCall(_c__production_prs__data,"_p__body__data"); function c__production_sets(){ var self=this; this.root="c__production_sets"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__production_sets_table('#'+self.root); self.add= new k__set_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0 && add_option['C03_name'] && global_params['project_id']){ system.set_add(function(data){ self.table.process(); },global_params['project_id'],global_params['pproduction_id'],add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if(( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) && global_params['pproduction_id']) { let project_id=global_params['project_id'] || 0; let pproduction_id = global_params['pproduction_id'] || 0; if(pproduction_id && project_id){ system.get_pproduction_brief(function(data){ if(data && data.production_closed=='0' && data.project_status=='active'){ self.create_add(); } },project_id,pproduction_id); } } //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__production_sets=new c__production_sets(); function _c__production_sets__data( callback ) { __c__production_sets.process(); callback(); } var _c__production_sets__callpre=__c__production_sets.callpre; ajaxRender.addCall(_c__production_sets__data,"_p__body__data"); function c__production_trs(){ var self=this; this.root="c__production_trs"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__production_trs_table('#'+self.root); self.add= new k__tr_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ let project_id=user_profile.project_id || global_params['project_id'] || 0; let pproduction_id =user_profile.pproduction_id || global_params['pproduction_id'] || 0; let x=function(){ self.add.process( function(add_option){ if(project_id>0 && Object.keys(add_option).length>0 && add_option['C00_production'] ){ system.tr_add(function(data){ alert('Time report submitted'); self.table.process(); },project_id,add_option['C00_production'],add_option); } } ); } if(parseInt(user_profile.privs[0])>=2 || user_profile.privs[project_id] && parseInt(user_profile.privs[project_id])>=2) self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square',x); if(global_params['action']=='add') x(); } this.create_email=function(){ let project_id=user_profile.project_id || global_params['project_id'] || 0; let pproduction_id =user_profile.pproduction_id || global_params['pproduction_id'] || 0; /* self.top_bar.add_top_bar_button('email','Email Pending DTR','email','blue','envelope-square', function(){ if(confirm('Are you sure?')){ system.pendingdtr_sendlink(function(data){ alert('Emails sent'); },global_params['project_id'],global_params['pproduction_id'],0); } } ); */ self.top_bar.add_top_bar_button('email','Pending DTR Coordinator','email','blue','envelope-square', function(){ system.get_pendingdtr_coordinator(function(p){ let htmldep='\n'; for(var i in p){ if(p[i].email.indexOf('@')>=0){ let html=p[i].name+' - '+((p[i].position)?p[i].position:'')+' | '+((p[i].department)?p[i].department:'NA')+' '+'\n'; htmldep+=html; } } let htmlx=htmldep; if(htmlx !=''){ if(confirm('A link will be sent to:\n'+htmlx+'\n Confirm?')){ system.pendingdtr_sendlink(function(data){ alert('Emails sent'); },project_id,pproduction_id,-2); } }else alert('no user to send to'); },project_id,pproduction_id); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ let project_id=user_profile.project_id || global_params['project_id'] || 0; let pproduction_id =user_profile.pproduction_id || global_params['pproduction_id'] || 0; if(pproduction_id && project_id){ system.get_pproduction_brief(function(data){ if(data && data.production_closed=='0' && data.project_status=='active'){ if(parseInt(user_profile.privs[0])>=2 || user_profile.privs[project_id] && parseInt(user_profile.privs[project_id])>=2) { self.create_add(); } if(global_params.type=='crew' && global_params.approved==0 &&(parseInt(user_profile.privs[0])>=5 || user_profile.privs[project_id] && parseInt(user_profile.privs[project_id])>=5)) self.create_email(); } },project_id,pproduction_id); }else if(project_id){ system.get_project_status(function(s){ if( s=='active'){ self.create_add(); } },project_id); } if(user_profile.A05_id>0){ self.table.init(); self.table.process(); } } if(typeof(callback)=="function") callback(); } } var __c__production_trs=new c__production_trs(); function _c__production_trs__data( callback ) { __c__production_trs.process(); callback(); } var _c__production_trs__callpre=__c__production_trs.callpre; ajaxRender.addCall(_c__production_trs__data,"_p__body__data"); function c__project_characters(){ var self=this; this.root="c__project_characters"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__project_characters_table('#'+self.root); self.add= new k__pcharacter_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0 && add_option['B00_firstname'] && global_params['project_id']){ system.pcharacter_add(function(data){ self.table.process(); },global_params['project_id'],add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) self.create_add(); //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__project_characters=new c__project_characters(); function _c__project_characters__data( callback ) { __c__project_characters.process(); callback(); } var _c__project_characters__callpre=__c__project_characters.callpre; ajaxRender.addCall(_c__project_characters__data,"_p__body__data"); function c__project_members(){ var self=this; this.root="c__project_members"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__project_members_table('#'+self.root); self.add= new k__pmember_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0 && add_option['B01_user'] && global_params['project_id']){ system.pmember_add(function(data){ self.table.process(); },global_params['project_id'],add_option); } } ); } ); } this.send_users=function(type){ system.get_pmembers(function(pmembers){ let allusers=[]; let depheads=[]; let htmlall='\n'; let htmldep='\n'; for(var i in pmembers){ if(pmembers[i].A05_email.indexOf('@')>=0){ let html=pmembers[i].A05_firstname+' '+pmembers[i].A05_lastname+' - '+((pmembers[i].A03_name)?pmembers[i].A03_name:'')+' | '+((pmembers[i].A02_name)?pmembers[i].A02_name:'NA')+' '+'\n'; allusers.push(pmembers[i]); htmlall+=html; let priv=parseInt(pmembers[i].A05_priv)+parseInt(pmembers[i].B01_priv); if(priv>=2 && priv<5 ) { htmldep+=html; depheads.push(pmembers[i]); } } } let htmlx=(type==0)?htmlall:htmldep; if(htmlx !=''){ if(confirm('A link will be sent to:\n'+htmlx+'\n Confirm?')){ system.pmember_sendlink(function(data){ alert('Emails sent'); },global_params['project_id'],type); } }else alert('no user to send to'); },global_params['project_id'] || 0); } this.create_email=function(){ self.top_bar.add_top_bar_button('email','Everyone','email','blue','envelope-square', function(){ self.send_users(0); } ); self.top_bar.add_top_bar_button('emaildh','DTR Coordinator','emaildh','blue','envelope-square', function(){ self.send_users(-2); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) { system.get_project_status(function(s){ if( s=='active') { self.create_add(); self.create_email(); } },global_params['project_id'] ); } //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__project_members=new c__project_members(); function _c__project_members__data( callback ) { __c__project_members.process(); callback(); } var _c__project_members__callpre=__c__project_members.callpre; ajaxRender.addCall(_c__project_members__data,"_p__body__data"); function c__project_productions(){ var self=this; this.root="c__project_productions"; this.processed=false; this.table; this.filter={}; this.add; this.top_bar; this.columns={ } this.process=function(){ if(!self.processed){ $(".main_content").append(""); self.table=new s__project_productions_table('#'+self.root); self.add= new k__pproduction_add_form('.panel_content'); self.top_bar= new _top_bar(); self.processed=true; } } this.create_add=function(){ self.top_bar.add_top_bar_button('add','Add','add','green','pencil-square', function(){ self.add.process( function(add_option){ if(Object.keys(add_option).length>0 && global_params['project_id']){ system.pproduction_add(function(data){ self.table.process(); },global_params['project_id'],add_option); } } ); } ); } this.callpre=function(state,pstate,callback){ if(state !='none'){ self.table.init(); if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ){ system.get_project(function(project){ if(['inactive','wrapped'].indexOf(project.A04_status)==-1) self.create_add(); },global_params['project_id']); } //self.create_panel(); self.table.process(); } if(typeof(callback)=="function") callback(); } } var __c__project_productions=new c__project_productions(); function _c__project_productions__data( callback ) { __c__project_productions.process(); callback(); } var _c__project_productions__callpre=__c__project_productions.callpre; ajaxRender.addCall(_c__project_productions__data,"_p__body__data"); var s__admin_firms_table=function(root){ var self=this; this.root=root; this.edit= new k__firm_edit_form('.panel_content'); this.table_tpl=function(){ var html='
'; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
NameAddressCityStateCountryPhone
'; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+(data['A00_name'] ||'')+''; html +=''+(data['A00_address'] ||'')+''; html +=''+(data['A00_city'] ||'')+''; html +=''+(data['A00_state'] ||'')+''; html +=''+(data['A00_country'] ||'')+''; html +=''+(data['A00_phone'] ||'')+''; if(parseInt(user_profile.A05_priv)>=5) html +=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
'; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_firms); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ if(user_profile.A05_priv>10){ $('.edit_button').click( function(){ var firm_id=$(this).attr("data"); system.get_firm(function(firm){ self.edit.process(firm,function(edit_option){ var r={}; for(var col in edit_option){ if(firm[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.firm_update(function(data){ self.load_table(-1); },firm['A00_id'],r); } }); },firm_id); } ); } } } s__admin_firms_table.prototype=_table_display.prototype; var s__firm_departments_table=function(root){ var self=this; this.root=root; this.edit= new k__department_edit_form('.panel_content'); this.table_tpl=function(){ var html='
'; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
NameSort#
'; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+data['A02_name'].toUpperCase()+''; html +=''+data['A02_sort']+''; html +=''; if(parseInt(user_profile.A05_priv)>=5) html+=''; html+=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
'; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_departments); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ $('.edit_button').click( function(){ var id=$(this).attr("data"); system.get_department(function(department){ self.edit.process(department,function(edit_option){ var r={}; for(var col in edit_option){ if(department[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.department_update(function(data){ self.load_table(-1); },department['A02_id'],r); } }); },id); } ); } } s__firm_departments_table.prototype=_table_display.prototype; var s__firm_positions_table=function(root){ var self=this; this.root=root; this.edit= new k__position_edit_form('.panel_content'); this.table_tpl=function(){ var html='
'; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
DepartmentNameLevel
'; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+((data['A02_name'])?data['A02_name']:'')+''; html +=''+data['A03_name']+''; html +=''+data['A03_priv']+''; html +=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
'; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_positions); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ if(parseInt(user_profile.A05_priv)>=5){ $('.edit_button').click( function(){ var id=$(this).attr("data"); system.get_position(function(position){ self.edit.process(position,function(edit_option){ var r={}; for(var col in edit_option){ if(position[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.position_update(function(data){ self.load_table(-1); },position['A03_id'],r); } }); },id); } ); } } } s__firm_positions_table.prototype=_table_display.prototype; var s__firm_projects_table=function(root){ var self=this; this.root=root; this.edit= new k__project_edit_form('.panel_content'); this.table_tpl=function(){ var html='
'; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; /* html +=''; */ html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
NameDate
'; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+data['A04_name']+''; html +=''+data['A04_date_started']+''; html +='=5 || parseInt(user_profile.privs[data['A04_id']])>=5) ) html+=' class="pointer" onclick="load_url(\'project_members?project_id='+data['A04_id']+'\',\''+'undefined,undefined,'+data['A04_name']+'\')"'; html+='>'+(data['users'] || 0)+''; html +='=5 || parseInt(user_profile.privs[data['A04_id']])>=5) ) html+=' class="pointer" onclick="load_url(\'project_productions?project_id='+data['A04_id']+'\',\''+'undefined,undefined,'+data['A04_name']+'\')"'; html+='>'+(data['entrys'] || 0)+''; /* html +='=5 || parseInt(user_profile.privs[data['A04_id']])>=5) ) html+=' class="pointer" onclick="load_url(\'project_characters?project_id='+data['A04_id']+'\',\''+'undefined,undefined,'+data['A04_name']+'\')"'; html+='>'+(data['characters'] || 0)+''; */ html +=''+capitalizeFirstLetter(data['A04_status'])+''; html +=''; if( (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[data['A04_id']])>=5) ) html+=''; html+=''; if( (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[data['A04_id']])>=5) ) html +=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
'; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_projects,global_params.status || '',global_params.user_id || 0); } this.process=function(){ self.load_table(1); if(global_params['action']=='edit' ) self.__edit(global_params.project_id); } this.__edit=function(project_id){ system.get_project(function(project){ self.edit.process(project,function(edit_option){ var r={}; for(var col in edit_option){ if(project[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.project_update(function(data){ self.load_table(-1); },project['A04_id'],r); } }); },project_id); } this.row_callback=function(){ $('.link_button').click(function(){ let x=this; var token=$(this).attr("data"); var project_id=$(this).attr("project"); navigator.clipboard.writeText(location.protocol + '//' + location.host +'/production_trs?action=add&project_id='+project_id+'&token='+token); $(x).attr('src',"/icons/copy.svg"); setTimeout(function(){ $(x).attr('src',"/icons/link.png"); },1000); }); $('.edit_button').click( function(){ var project_id=$(this).attr("data"); self.__edit(project_id); } ); } } s__firm_projects_table.prototype=_table_display.prototype; var s__firm_users_table=function(root){ var self=this; this.root=root; this.edit= new k__user_edit_form('.panel_content'); this.table_tpl=function(){ var html='
'; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; // html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
NameEmailPhoneT / C / P
'; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+data['A05_firstname']+' '+data['A05_lastname']+''; html +=''+((data['A05_email'].indexOf('@')>=0)?data['A05_email']:'')+''; html +=''+((data['A05_phone'])?data['A05_phone']:'')+''; html +=''+(data['projects'] || 0)+''; /* html +=''; html+='
'+(data['tr'] || '0')+'
'; if(data['tr'] != data['approved_tr']){ html+='
/
'; html+='
'+(data['approved_tr'] || '0')+'
'; html+='
/
'; html+='
'+(data['pending_tr'] || '0')+'
'; } html+=''; */ if(parseInt(user_profile.A05_priv)>=parseInt(data['A05_priv'])) html +=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
'; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_users); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ $('.edit_button').click( function(){ var user_id=$(this).attr("data"); system.get_user(function(user){ self.edit.process(user,function(edit_option){ var r={}; for(var col in edit_option){ if(user[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.user_update(function(data){ self.load_table(-1); },user['A05_id'],r); } }); },user_id); } ); } } s__firm_users_table.prototype=_table_display.prototype; function s__navigation_menu_item(root,navigation_menu){ var self=this; var priv=-1; this.menu_tpl=function(branch,item,hide_arrow){ var html=''; html+='
  • '; html+=' '+item.display_name+' '; html+=' '; html+=' '; html+='
  • '; return html; } this.submenu_tpl=function(link,name){ var html=''; html+='
    '; html+=name; html+='
    '; return html; } this.reset_highlight_submenu_link=function(branch,item,link){ for(var submenu_item in item.submenu){ var link2=branch+"_"+submenu_item+"__link"; if(link2==link){ $("#"+link).addClass('submenu-selected'); } else { $('#'+link2).removeClass('submenu-selected'); } } } this.set_url=function(url){ let vps=url.split("_"); var br=vps.shift(); var link=''; for(var branch in navigation_menu){ item=navigation_menu[branch]; $('#'+branch+'__menu').removeClass("selected"); self.reset_menu(branch,navigation_menu[branch],true); if(typeof(item.submenu)=="undefined" && branch==url){ $('#'+branch+'__menu').addClass("selected"); }else if(br==branch && typeof(item.submenu) !="undefined"){ self.expand_menu(branch); $('#'+branch+'__submenu').show(); let submenu_item=vps.join("_"); for(var sub_item in item.submenu){ if(sub_item==submenu_item){ link=branch+"_"+submenu_item+"__link"; } } self.reset_highlight_submenu_link(branch,item,link); } } } this.load_url=function(url,branch,item){ load_url(url); } this.set_link_click=function(branch,item,link,url){ $("#"+link).click( function(){ self.reset_highlight_submenu_link(branch,item,link); self.load_url(url,branch,item); }); } this.reset_menu=function(branch,item,true_reset){ $("#"+branch+"__arrow").removeClass('fa-angle-down'); $("#"+branch+"__arrow").addClass('fa-angle-left'); if(true_reset){ $('#'+branch+'__submenu').hide(); self.reset_highlight_submenu_link(branch,item,''); } } this.expand_menu=function(branch){ $("#"+branch+"__arrow").removeClass('fa-angle-left'); $("#"+branch+"__arrow").addClass('fa-angle-down'); $('#'+branch+'__menu').addClass("selected"); } this.set_menu_hover=function(branch){ $('#'+branch+'__menu').mouseover( function(){ $('#'+branch+'__menu').addClass("is-hover"); } ); $('#'+branch+'__menu').mouseout( function(){ $('#'+branch+'__menu').removeClass("is-hover"); } ); } this.build_menu=function(branch,item){ var html=''; var urls=''; html+=''; $(root).append(html); for(var submenu_item in item.submenu){ var link=branch+"_"+submenu_item+"__link"; var url=branch+"_"+submenu_item; self.set_link_click(branch,item,link,url); //urls+="'"+branch+"_"+submenu_item+"':{'0':['c__"+branch+"_"+submenu_item+"']},\n"; urls+=url+":'"+item.submenu[submenu_item]+"',\n"; } return urls; } this.set_menu_click=function(branch,item){ $('#'+branch+"__menu").click( function(){ if(typeof(item.submenu) !="undefined"){ $('#'+branch+'__submenu').toggle(); if( $('#'+branch+'__submenu').css('display')=='none') { self.reset_menu(branch,item); }else{ self.expand_menu(branch); } }else self.load_url(branch,branch,null); } ); } this.refresh=function(){ let new_priv=( user_profile)?user_profile.A05_priv:0; if(self.priv !=new_priv){ $(root).html(''); self.process(); } } this.process=function(){ var urls=''; self.priv=( user_profile)?user_profile.A05_priv:0; for(var branch in navigation_menu){ if(!vpages_security[branch] || user_profile && user_profile.A05_priv>=vpages_security[branch]){ var item=navigation_menu[branch]; $(root).append(self.menu_tpl(branch,item,typeof(item.submenu)=="undefined")); self.set_menu_hover(branch); if(typeof(item.submenu) !="undefined"){ urls+=self.build_menu(branch,item); } self.set_menu_click(branch,item); } } //console.log(urls); } this.set_pending_count=function(count){ if(!count) count=0; if(count==0) $('#'+branch+"__pending_count").hide(); else $('#'+branch+"__pending_count").show(); $('#'+branch+"__pending_count").text(count); } self.process(); } var s__production_comments_table=function(root){ var self=this; this.root=root; this.edit= new k__comment_edit_form('.panel_content'); this.table_tpl=function(){ var html='
    '; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
    NameComment
    '; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+data['C04_name']+''; html +=''+(data['C04_comment'].substr(0,30))+((data['C04_comment'].length>30)?'...':'')+''; html +=''; if(data['A04_status']=='active' && data['B04_closed']=='0') html+=''; html+=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
    '; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_comments,global_params.project_id || 0,global_params.pproduction_id || 0); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) { $('.edit_button').click( function(){ var comment_id=$(this).attr("data"); var project_id=$(this).attr("project"); var pproduction_id=$(this).attr("production"); system.get_comment(function(comment){ self.edit.process(comment,function(edit_option){ var r={}; for(var col in edit_option){ if(comment[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.comment_update(function(data){ self.load_table(-1); },project_id,pproduction_id,comment['C04_id'],r); } }); },project_id,pproduction_id,comment_id); } ); } } } s__production_comments_table.prototype=_table_display.prototype; var s__production_locations_table=function(root){ var self=this; this.root=root; this.edit= new k__location_edit_form('.panel_content'); this.table_tpl=function(){ var html='
    '; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
    NameField 1Field 2Sort#
    '; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+data['C02_name']+''; html +=''+(data['C02_place'] || '')+''; html +=''+(data['C02_address'] || '')+''; html +=''+(data['C02_sort'] || '')+''; html +=''; if(data['A04_status']=='active' && data['B04_closed']=='0') html+=''; html+=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
    '; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_locations,global_params.project_id || 0,global_params.pproduction_id || 0); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) { $('.edit_button').click( function(){ var location_id=$(this).attr("data"); var project_id=$(this).attr("project"); var pproduction_id=$(this).attr("production"); system.get_location(function(loc){ self.edit.process(loc,function(edit_option){ var r={}; for(var col in edit_option){ if(loc[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.location_update(function(data){ self.load_table(-1); },project_id,pproduction_id,loc['C02_id'],r); } }); },project_id,pproduction_id,location_id); } ); } } } s__production_locations_table.prototype=_table_display.prototype; var s__production_prs_table=function(root){ var self=this; this.root=root; this.edit= new k__pr_edit_form('.panel_content'); this.table_tpl=function(){ var html='
    '; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
    ProductionDPRScenePreviousTodayTo DateRemaining+/-
    '; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+(data['A04_name'] || '')+''; html +=''+(data['B04_title'] || '')+''; html +=''+(data['C01_scene'] || '')+''; html +=''+(data['previous'] || '')+''; html +=''+(data['today'] || '')+''; html +=''+(data['todate'] || '')+''; html +=''+(data['remaining'] || '')+''; html +=''+(data['ert_change'] || '')+''; html +=''; if(global_params.pproduction_id && ( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) )) html+=''; html+=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
    '; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_prs,global_params.project_id || 0,global_params.pproduction_id||0); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ $('.edit_button').click( function(){ var pr_id=$(this).attr("data"); system.get_pr(function(pr){ self.edit.process(pr,function(edit_option){ var r={}; for(var col in edit_option){ if(pr[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.pr_update(function(data){ self.load_table(-1); },global_params.project_id||0,global_params.pproduction_id||0,pr['C01_id'],r); } }); },global_params.project_id||0,global_params.pproduction_id||0,pr_id); } ); } } s__production_prs_table.prototype=_table_display.prototype; var s__production_sets_table=function(root){ var self=this; this.root=root; this.edit= new k__set_edit_form('.panel_content'); this.table_tpl=function(){ var html='
    '; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
    NameSort#
    '; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+data['C03_name']+''; html +=''+data['C03_sort']+''; html +=''; if((data['A04_status']=='active' && data['B04_closed']=='0') &&(parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[data['C03_project']])>=5) ) html+=''; html+=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
    '; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_sets,global_params.project_id || 0,global_params.pproduction_id || 0); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ $('.edit_button').click( function(){ var set_id=$(this).attr("data"); var project_id=$(this).attr("project"); var pproduction_id=$(this).attr("production"); system.get_set(function(set){ self.edit.process(set,function(edit_option){ var r={}; for(var col in edit_option){ if(set[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.set_update(function(data){ self.load_table(-1); },project_id,pproduction_id,set['C03_id'],r); } }); },project_id,pproduction_id,set_id); } ); } } s__production_sets_table.prototype=_table_display.prototype; var s__production_trs_table=function(root){ var self=this; this.root=root; this.edit= new k__tr_edit_form('.panel_content'); this.pproduction_id=0; this.table_tpl=function(){ var html='
    '; html +=''; html +=''; if(global_params.type !='crew') html +=''; if(global_params.type !='background') html +=''; if(global_params.type =='background') html +=''; if(global_params.type && global_params.type !='crew') html +=''; if(global_params.type =='cast') html +=''; if(global_params.type =='crew') html +=''; if(global_params.type =='crew') html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; if(global_params.type =='background') html +=''; if(global_params.type =='crew') html +=''; html +=''; html +=''; html+=''; html+= '
    #NameRateNDBStatusDepartmentPositionProjectProductionDateInLunchOutNote
    '; return html; } this.row_tpl=function(data){ var html=''; if(self.pproduction_id !=data['C00_production']){ html+=''; html +=''; html+='
    =5 || parseInt(user_profile.privs[data['C00_project']])>=5) ) html+=' class="pointer" onclick="load_url(\'firm_projects?action=edit&project_id='+data['C00_project']+'\')"'; html+='>'; html+=data['A04_name']; html +='
       -   ' +data['B04_date']; html +='   -   
    =5 || parseInt(user_profile.privs[data['C00_project']])>=5) )html +=' class="pointer" onclick="load_url(\'project_productions?action=edit&project_id='+data['C00_project']+'&pproduction_id='+data['C00_production']+'\')"'; html+='> '+data['B04_title']+'
    '; html+=''; self.pproduction_id=data['C00_production']; } html +=''; if(global_params.type !='crew') html +=''+data['C00_no']+''; let priv=parseInt(data['A05_priv'])+parseInt(data['B01_priv']); if(global_params.type !='background') html +=''+data['A05_firstname']+' '+data['A05_lastname']+''; if(global_params.type =='background') html +=''+data['C00_rate']+''; if(global_params.type &&global_params.type !='crew') html +=''+data['C00_ndb']+''; if(global_params.type =='cast') html +=''+((data['C00_code'])?data['C00_code'].replaceAll(',',''):'')+''; if(global_params.type =='crew') html +=''+((data['A02_name'] !='ZZZ')?data['A02_name']:'')+''; if(global_params.type =='crew') html +=''+((data['A03_name'])?data['A03_name']:'')+''; html +=''+(data['A04_name'] || '')+''; html +=''+(data['B04_title'] || '')+''; html +=''+(data['B04_date'] || '')+''; if(data['C00_owncall']=='1'){ html+=' Own Call'; } else if(data['C00_nocall']=='1'){ html+=' No Call'; } else{ html +=''+(((data['C00_type']=='background')?data['call']: data['time_in']) || '')+''; html +=''+(data['lunch_start'] || '')+'-'+(data['lunch_end'] || '')+''; html +=''+(((data['C00_type']=='background')?data['wrap']: data['time_out']) || '')+''; } if(global_params.type =='crew') html +=' '; if(global_params.type =='background') html +=''+((data['C00_note'])?data['C00_note']:'')+''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
    '; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_trs,global_params.project_id || 0,global_params.pproduction_id||0,global_params.approved||-1,global_params.type||'',global_params.user_id || 0); } this.process=function(){ self.pproduction_id=0; self.load_table(1); if(global_params['action']=='edit' ) self.__edit(global_params.project_id, global_params.pproduction_id,global_params.id); } this.__edit=function(project_id,pproduction_id,id){ var x=function(){ if(project_id && pproduction_id && id){ system.get_tr(function(tr){ if(tr){ self.edit.process(tr,function(edit_option){ var r={}; for(var col in edit_option){ r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.tr_update(function(data){ alert('Time report submitted'); self.pproduction_id=0; self.load_table(-1); },project_id,pproduction_id,id,r); } },function(){ x(); self.load_table(-1); }); } },project_id,pproduction_id,id); } } x(); } this.row_callback=function(){ $('.edit_button').click( function(){ var tr_id=$(this).attr("id"); var project_id=$(this).attr("project"); var pproduction_id=$(this).attr("production"); self.__edit(project_id, pproduction_id,tr_id); } ); } } s__production_trs_table.prototype=_table_display.prototype; var s__project_characters_table=function(root){ var self=this; this.root=root; this.edit= new k__pcharacter_edit_form('.panel_content'); this.table_tpl=function(){ var html='
    '; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
    Name
    '; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+data['B00_firstname']+' '+data['B00_lastname']+''; html +=''; if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) html+=''; html+=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
    '; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_pcharacters,global_params.project_id || 0); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ){ $('.edit_button').click( function(){ var pcharacter_id=$(this).attr("data"); system.get_pcharacter(function(pcharacter){ self.edit.process(pcharacter,function(edit_option){ var r={}; for(var col in edit_option){ if(pcharacter[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.pcharacter_update(function(data){ self.load_table(-1); },global_params.project_id||0,pcharacter['B00_id'],r); } }); },global_params.project_id||0,pcharacter_id); } ); } } } s__project_characters_table.prototype=_table_display.prototype; var s__project_members_table=function(root){ var self=this; this.root=root; this.edit= new k__pmember_edit_form('.panel_content'); this.table_tpl=function(){ var html='
    '; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
    NameDepartmentPositionEmailPrivilegeT / S / PO/C
    '; return html; } this.row_tpl=function(data){ var html=''; html +=''; html +=''+data['A05_firstname']+' '+data['A05_lastname']+''; html +=''+(data['A02_name'] || '')+''; html +=''+(data['A03_name'] || '')+''; html +=''+((data['A05_email'].indexOf('@')>=0)?data['A05_email']:'' )+''; html +=''; let priv=parseInt(data['A05_priv'])+parseInt(data['B01_priv']); html+=get_priv_html(priv); html+=''; html +=''; html+='
    '+(data['tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['approved_tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['pending_tr'] || '0')+'
    '; html+=''; html +=''; html+=(data['B01_owncall']=='1')?'':''; html+=''; html +=''; if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) html+=''; html+=''; html +=''; if( data['A04_status']=='active' && global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ) html+=''; html+=''; html +=''; html +=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
    '; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_pmembers,global_params.project_id || 0); } this.process=function(){ self.load_table(1); } this.row_callback=function(){ if( global_params['project_id'] && (parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[global_params['project_id']])>=5) ){ $('.email_link').click(function(){ let x=this; var user_id=$(this).attr("data"); var project_id=$(this).attr("project"); var name=$(this).attr("name"); if(confirm('A link will be sent to '+name)){ system.pmember_sendlink(function(data){ alert('Link email has been sent to '+name); },project_id,user_id); } }); $('.link_button').click(function(){ let x=this; var token=$(this).attr("data"); var project_id=$(this).attr("project"); navigator.clipboard.writeText(location.protocol + '//' + location.host +'/production_trs?project_id='+project_id+'&token='+token); $(x).attr('src',"/icons/copy.svg"); setTimeout(function(){ $(x).attr('src',"/icons/link.png"); },1000); }); $('.edit_button').click( function(){ var pmember_id=$(this).attr("data"); system.get_pmember(function(pmember){ self.edit.process(pmember,function(edit_option){ var r={}; for(var col in edit_option){ if(pmember[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.pmember_update(function(data){ self.load_table(-1); },global_params.project_id||0,pmember['B01_id'],r); } }); },global_params.project_id||0,pmember_id); } ); } } } s__project_members_table.prototype=_table_display.prototype; var s__project_productions_table=function(root){ var self=this; this.root=root; this.project_id=0; this.edit= new k__pproduction_edit_form('.panel_content'); this.table_tpl=function(){ var html='
    '; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; html +=''; // html +=''; html +=''; html +=''; html +=''; html+=''; html+= '
    ProductionTitleDateT / S / PCREW
    T / S / P
    CAST
    T / S / P
    BG
    T / S / P
    SR CS
    '; return html; } this.row_tpl=function(data){ var html=''; let params=encodeURI(JSON.stringify({'project_id':data['B04_project'],'pproduction_id':data['B04_id']})); if(data['B04_project'] != self.project_id){ html +=''; html +='
    =5 || parseInt(user_profile.privs[data['B04_project']])>=5) ) html+=' class="pointer" onclick="load_url(\'firm_projects?action=edit&project_id='+data['B04_project']+'\')"'; html+='>'+data['A04_name']+'
    '; html +=''; // html +=''; // html +=''; // html +=''; // self.project_id=data['B04_project']; } html +=''; html +=''+data['A04_name']+''; html +=''+' '+data['B04_title']+''; let date = new Date(data['B04_date']); html +=''+data['B04_date']+''; html +=''; html+='
    '+(data['tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['approved_tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['pending_tr'] || '0')+'
    '; html +=''; html+='
    '+(data['crew_tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['approved_crew_tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['pending_crew_tr'] || '0')+'
    '; html +=''; html+='
    '+(data['cast_tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['approved_cast_tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['pending_cast_tr'] || '0')+'
    '; html +=''; html+='
    '+(data['background_tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['approved_background_tr'] || '0')+'
    '; html+='
    /
    '; html+='
    '+(data['pending_background_tr'] || '0')+'
    '; html+=''; html +=''+(data['comments'] || '0')+''; html+='
    '+((data['B04_sr'] !='')?'':'N')+'
    '; html+=''+((data['B04_cs'] !='')?'':'N')+''; html +=''+(data['locations'] || '0')+''; html +=''+(data['sets'] || '0')+''; // html +=''+(data['pr'] || '0')+''; html +=''; if((parseInt(user_profile.privs[0])>=5 || parseInt(user_profile.privs[data['B04_project']])>=5) ) html+=''; html+=''; return html; } this.foot_tpl=function(summary){ var html=''; html+='
    T=Total,S=Submitted,P=Pending
    '; html+='
    '; return html; } this.load_table=function(page_num){ self._load_table(root, system.get_pproductions,global_params.project_id || 0,global_params.closed || -1); } this.process=function(){ self.project_id=0; self.load_table(1); if(global_params['action']=='edit' ) self.__edit(global_params.project_id, global_params.pproduction_id); } this.__edit=function(project_id,pproduction_id){ var x=function(){ system.get_pproduction(function(pproduction){ self.edit.process(pproduction,function(edit_option){ var r={}; for(var col in edit_option){ if(pproduction[col] !=edit_option[col]) r[col]=edit_option[col]; } if(Object.keys(r).length>0){ system.pproduction_update(function(data){ self.project_id=0; self.load_table(-1); },project_id||0,pproduction['B04_id'],r); } },function(){ x(); self.load_table(-1); }); },project_id||0,pproduction_id); } x(); } this.row_callback=function(){ $('.edit_button').click( function(){ var pproduction_id=$(this).attr("data"); var project_id=$(this).attr("project"); self.__edit(project_id,pproduction_id); } ); } } s__project_productions_table.prototype=_table_display.prototype; var k__comment_add_form=function(root){ var self=this; var username_ok=false; var email_ok=false; var name="Add"; this.tmpl_content=function(){ var html=''; html+='
    '; html+='
    Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Comment
    '; html+=' '; html+='
    '; html+=''; return html; } this.save_test=function(){ if($('#C04_name').val() !='' && $('#C04_comment').val() !=''){ $('.action-button').prop('disabled',false); }else { $('.action-button').prop('disabled',true); } } this.process=function(__callback){ self.__process(root, (global_params['project_id'] && user_profile.privs[global_params['project_id']] )?parseInt(user_profile.privs[global_params['project_id']]): parseInt(user_profile.privs[0]) ,true,self.tmpl_content(),{},function(r){ if(! $('.action-button').prop('disabled')){ __callback(r); }else return false; },function(){ self.save_test(); $('#C04_comment').change(self.save_test); $('#C04_name').change(self.save_test); }); } } k__comment_add_form.prototype=_action_form.prototype; var k__comment_edit_form=function(root){ var self=this; var name="Submit"; this.tmpl_content=function(){ var html=''; html+=' '; html+='
    '; html+='
    Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Comment
    '; html+=' '; html+='
    '; html+=''; return html; } this.process=function(sys,__callback){ self.__process(root, (user_profile.privs[sys['C04_project']])? parseInt(user_profile.privs[sys['C04_project']]):parseInt(user_profile.privs[0]) ,false,self.tmpl_content(),sys,__callback); } } k__comment_edit_form.prototype=_action_form.prototype; var k__department_add_form=function(root){ var self=this; var name="Add"; this.tmpl_content=function(){ var html=''; html+='
    '; html+='
    Name
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Sort # (0-100)
    '; html+=' '; html+='
    '; html+=''; return html; } this.save_test=function(){ if($('#A02_name').val() !=''){ $('.action-button').prop('disabled',false); }else { $('.action-button').prop('disabled',true); } } this.process=function(__callback){ self.__process(root,user_profile.A05_priv,true,self.tmpl_content(),{},function(r){ if(! $('.action-button').prop('disabled')){ __callback(r); }else return false; },function(){ $('#A02_name').change(self.save_test); }); } } k__department_add_form.prototype=_action_form.prototype; var k__department_edit_form=function(root){ var self=this; var name="Submit"; this.tmpl_content=function(){ var html=''; html+=' '; html+='
    '; html+='
    Name
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Sort # (0-100)
    '; html+=' '; html+='
    '; html+=''; return html; } this.process=function(sys,__callback){ self.__process(root,user_profile.A05_priv,false,self.tmpl_content(),sys,__callback); } } k__department_edit_form.prototype=_action_form.prototype; var k__firm_edit_form=function(root){ var self=this; var name="Submit"; this.tmpl_content=function(){ var html=''; html+=' '; html+='
    '; html+='
    Firm Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Address
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    City
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    State
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Country
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Zip
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Phone
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Email
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Website
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Copyright
    '; html+=' '; html+='
    '; html+=''; return html; } this.process=function(sys,__callback){ self.__process(root,user_profile.A05_priv,false,self.tmpl_content(),sys,__callback); } } k__firm_edit_form.prototype=_action_form.prototype; var k__firm_register_form=function(root){ var self=this; var username_ok=false; var email_ok=false; var name="Register"; this.tmpl_content=function(){ var html=''; html+='
    '; html+='
    Admin Email
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Password
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Admin First Name
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Last Name
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Firm Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Address
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    City
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    State
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Country
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Zip
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Phone
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Website
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    Copyright
    '; html+=' '; html+='
    '; html+=''; html+='
    '; html+='
    '; html+=''; return html; } this._check_email=function(data){ if(data==0) self.email_ok=true; else self.email_ok=false; if(!self.email_ok && data==1) $('#register_email_error').html('email exists'); else $('#register_email_error').html(''); self.save_test(); } this.save_test=function(){ if(self.email_ok){ $('.action-button').prop('disabled',false); }else { $('.action-button').prop('disabled',true); } } this._check=function(type){ var x=function(data){ if(self.email_ok){ $('.action-button').prop('disabled',false); }else { $('.action-button').prop('disabled',true); } } if(type=='email' && $('#email').val() !=''){ system.check_email(self._check_email, $('#email').val()); } else self._check_email(-1); } this.process=function(__callback){ self.__process(root,user_profile.A05_priv,true,self.tmpl_content(),{},function(r){ if(! $('.action-button').prop('disabled')){ __callback(r); }else return false; },function(){ $('#email').change(function(){self._check('email')}); }); } } k__firm_register_form.prototype=_action_form.prototype; var k__location_add_form=function(root){ var self=this; var username_ok=false; var email_ok=false; var name="Add"; this.tmpl_content=function(){ var html=''; html+='
    '; html+='
    Location Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Field 1
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Field 2
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Sort#
    '; html+=' '; html+='
    '; html+=''; return html; } this.save_test=function(){ if($('#C02_name').val() !=''){ $('.action-button').prop('disabled',false); }else { $('.action-button').prop('disabled',true); } } this.process=function(__callback){ self.__process(root, (global_params['project_id'] && user_profile.privs[global_params['project_id']] )?parseInt(user_profile.privs[global_params['project_id']]): parseInt(user_profile.privs[0]) ,true,self.tmpl_content(),{},function(r){ if(! $('.action-button').prop('disabled')){ __callback(r); }else return false; },function(){ $('#C02_name').change(self.save_test); }); } } k__location_add_form.prototype=_action_form.prototype; var k__location_edit_form=function(root){ var self=this; var name="Submit"; this.tmpl_content=function(){ var html=''; html+=' '; html+='
    '; html+='
    Location Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Field 1
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Field 2
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Sort#
    '; html+=' '; html+='
    '; html+=''; return html; } this.process=function(sys,__callback){ self.__process(root, (user_profile.privs[sys['C02_project']])? parseInt(user_profile.privs[sys['C02_project']]):parseInt(user_profile.privs[0]) ,false,self.tmpl_content(),sys,__callback); } } k__location_edit_form.prototype=_action_form.prototype; var k__pcharacter_add_form=function(root){ var self=this; var username_ok=false; var email_ok=false; var name="Add"; this.tmpl_content=function(){ var html=''; html+='
    '; html+='
    First Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Last Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Bio
    '; html+=' '; html+='
    '; html+=' '; return html; } this.save_test=function(){ if($('#B00_name').val() !=''){ $('.action-button').prop('disabled',false); }else { $('.action-button').prop('disabled',true); } } this.process=function(__callback){ self.__process(root,(global_params['project_id'] && user_profile.privs[global_params['project_id']] )?parseInt(user_profile.privs[global_params['project_id']]):parseInt(user_profile.privs[0]) ,true,self.tmpl_content(),{},function(r){ if(! $('.action-button').prop('disabled')){ __callback(r); }else return false; },function(){ $('#B00_firstname').change(self.save_test); }); } } k__pcharacter_add_form.prototype=_action_form.prototype; var k__pcharacter_edit_form=function(root){ var self=this; var name="Submit"; this.tmpl_content=function(){ var html=''; html+=' '; html+='
    '; html+='
    First Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Last Name
    '; html+=' '; html+='
    '; html+=' '; html+='
    '; html+='
    Bio
    '; html+=' '; html+='
    '; html+=' '; return html; } this.process=function(sys,__callback){ self.__process(root,(user_profile.privs[sys['B00_project']])? parseInt((user_profile.privs[sys['B00_project']])):parseInt(user_profile.privs[0]),false,self.tmpl_content(),sys,__callback); } } k__pcharacter_edit_form.prototype=_action_form.prototype; var k__pmember_add_form=function(root){ var self=this; var name="Add"; var setup; this.user_exists=function(id,pusers){ let exists=false; for(var i in pusers){ if(pusers[i]['B01_user']==id) exists=true; } return exists; } this.change_type=function(){ $('#cast_1').hide(); $('#background_1').hide(); if( $('#B01_type').val()=='cast') $('#cast_1').show(); if( $('#B01_type').val()=='background') $('#background_1').show(); } this.tmpl_content=function(setup){ var html=''; html+='
    '; html+='
    User
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Name
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Email
    '; html+=' '; html+='
    '; html+='
    '; html+='
    '; html+='
    '; html+='
    Type
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Own Call
    '; html+=' '; html+='
    '; html+='
    '; html+='
    +Privileges for this project
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Cast Character
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Department
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Position
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Skip DTR
    '; html+=' '; html+='
    '; html+='
    '; html+='
    Rate
    '; html+=' '; html+='
    '; html+='
    '; return html; } this.email_ok=true; this.setup=null; this._check_email=function(data){ if(data==0) self.email_ok=true; else self.email_ok=false; if(!self.email_ok && data==1) $('#register_email_error').html('email exists'); else $('#register_email_error').html(''); self.save_test(); } this.save_test=function(){ let setup=self.setup; if(self.email_ok ){ let id=$('#B01_user').val(); if(id=='0'){ $('#name_l').show(); $('#email_l').show(); }else{ $('#name_l').hide(); $('#email_l').hide(); $('#fullname').val(''); $('#email').val(''); } if(id){ for(var i in setup['users']){ if(setup['users'][i]['A05_id']==id){ $('#email_2').html(setup['users'][i]['A05_email']) $('#B01_department').val(setup['users'][i]['A05_department']); self.set_positions(); $('#B01_position').val(setup['users'][i]['A05_position']); } } } $('.action-button').prop('disabled',false); }else { $('.action-button').prop('disabled',true); } } this.check=function(){ if( $('#email').val() !=''){ system.check_email(self._check_email, $('#email').val()); } } this.set_positions=function(){ let positions={}; $('#B01_position').empty(); $.each(self.setup['positions'], function (i, item) { $('#B01_position').append($('